MCPcopy Create free account
hub / github.com/pyca/cryptography / _ModuleWithDeprecations

Class _ModuleWithDeprecations

src/cryptography/utils.py:65–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65class _ModuleWithDeprecations(types.ModuleType):
66 def __init__(self, module: types.ModuleType):
67 super().__init__(module.__name__)
68 self.__dict__["_module"] = module
69
70 def __getattr__(self, attr: str) -> object:
71 obj = getattr(self._module, attr)
72 if isinstance(obj, _DeprecatedValue):
73 warnings.warn(obj.message, obj.warning_class, stacklevel=2)
74 obj = obj.value
75 return obj
76
77 def __setattr__(self, attr: str, value: object) -> None:
78 setattr(self._module, attr, value)
79
80 def __delattr__(self, attr: str) -> None:
81 obj = getattr(self._module, attr)
82 if isinstance(obj, _DeprecatedValue):
83 warnings.warn(obj.message, obj.warning_class, stacklevel=2)
84
85 delattr(self._module, attr)
86
87 def __dir__(self) -> typing.Sequence[str]:
88 return ["_module"] + dir(self._module)
89
90
91def deprecated(

Callers 1

deprecatedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected