base_request.py 1.1 KB

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