base_response.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import typing as t
  2. import warnings
  3. from .response import Response
  4. class _FakeSubclassCheck(type):
  5. def __subclasscheck__(cls, subclass: t.Type) -> bool:
  6. warnings.warn(
  7. "'BaseResponse' is deprecated and will be removed in"
  8. " Werkzeug 2.1. Use 'issubclass(cls, Response)' instead.",
  9. DeprecationWarning,
  10. stacklevel=2,
  11. )
  12. return issubclass(subclass, Response)
  13. def __instancecheck__(cls, instance: t.Any) -> bool:
  14. warnings.warn(
  15. "'BaseResponse' is deprecated and will be removed in"
  16. " Werkzeug 2.1. Use 'isinstance(obj, Response)' instead.",
  17. DeprecationWarning,
  18. stacklevel=2,
  19. )
  20. return isinstance(instance, Response)
  21. class BaseResponse(Response, metaclass=_FakeSubclassCheck):
  22. def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
  23. warnings.warn(
  24. "'BaseResponse' is deprecated and will be removed in"
  25. " Werkzeug 2.1. 'Response' now includes the functionality"
  26. " directly.",
  27. DeprecationWarning,
  28. stacklevel=2,
  29. )
  30. super().__init__(*args, **kwargs)