__init__.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from __future__ import annotations
  2. import typing as t
  3. from .encoding import base64_decode as base64_decode
  4. from .encoding import base64_encode as base64_encode
  5. from .encoding import want_bytes as want_bytes
  6. from .exc import BadData as BadData
  7. from .exc import BadHeader as BadHeader
  8. from .exc import BadPayload as BadPayload
  9. from .exc import BadSignature as BadSignature
  10. from .exc import BadTimeSignature as BadTimeSignature
  11. from .exc import SignatureExpired as SignatureExpired
  12. from .serializer import Serializer as Serializer
  13. from .signer import HMACAlgorithm as HMACAlgorithm
  14. from .signer import NoneAlgorithm as NoneAlgorithm
  15. from .signer import Signer as Signer
  16. from .timed import TimedSerializer as TimedSerializer
  17. from .timed import TimestampSigner as TimestampSigner
  18. from .url_safe import URLSafeSerializer as URLSafeSerializer
  19. from .url_safe import URLSafeTimedSerializer as URLSafeTimedSerializer
  20. def __getattr__(name: str) -> t.Any:
  21. if name == "__version__":
  22. import importlib.metadata
  23. import warnings
  24. warnings.warn(
  25. "The '__version__' attribute is deprecated and will be removed in"
  26. " ItsDangerous 2.3. Use feature detection or"
  27. " 'importlib.metadata.version(\"itsdangerous\")' instead.",
  28. DeprecationWarning,
  29. stacklevel=2,
  30. )
  31. return importlib.metadata.version("itsdangerous")
  32. raise AttributeError(name)