bazarr/libs/werkzeug/wrappers/base_response.py

37 lines
1.2 KiB
Python
Raw Normal View History

import typing as t
2019-12-02 21:46:54 +00:00
import warnings
from .response import Response
2019-12-02 21:46:54 +00:00
class _FakeSubclassCheck(type):
def __subclasscheck__(cls, subclass: t.Type) -> bool:
2019-12-02 21:46:54 +00:00
warnings.warn(
"'BaseResponse' is deprecated and will be removed in"
" Werkzeug 2.1. Use 'issubclass(cls, Response)' instead.",
DeprecationWarning,
2019-12-02 21:46:54 +00:00
stacklevel=2,
)
return issubclass(subclass, Response)
2019-12-02 21:46:54 +00:00
def __instancecheck__(cls, instance: t.Any) -> bool:
warnings.warn(
"'BaseResponse' is deprecated and will be removed in"
" Werkzeug 2.1. Use 'isinstance(obj, Response)' instead.",
DeprecationWarning,
stacklevel=2,
2019-12-02 21:46:54 +00:00
)
return isinstance(instance, Response)
2019-12-02 21:46:54 +00:00
class BaseResponse(Response, metaclass=_FakeSubclassCheck):
def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
warnings.warn(
"'BaseResponse' is deprecated and will be removed in"
" Werkzeug 2.1. 'Response' now includes the functionality"
" directly.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)