arelle.utils.deprecation¶
See COPYRIGHT.md for copyright information.
Module Contents¶
Classes¶
Registry of deprecated module-level attributes. |
API¶
- class arelle.utils.deprecation.ModuleDeprecations(module_name: str)¶
Registry of deprecated module-level attributes.
Pairs with a module’s
__getattr__to emit a :class:DeprecationWarningwhen a removed attribute is accessed, while still returning its value for backward compatibility.Example usage in a module:
_DEPRECATIONS = ModuleDeprecations(__name__) _DEPRECATIONS.add("old_const", new_const, "use new_const instead") def __getattr__(name: str) -> Any: return _DEPRECATIONS.resolve(name)Initialization
Create a deprecation registry for the given module_name.
- add(name: str, value: Any, guidance: str, removal_version: str = _DEFAULT_REMOVAL_VERSION) None¶
Register a deprecated attribute that returns value on access.
- add_all(items: dict[str, Any], guidance: str, removal_version: str = _DEFAULT_REMOVAL_VERSION) None¶
Register multiple deprecated attributes sharing the same guidance.
- add_lazy(name: str, factory: collections.abc.Callable[[], Any], guidance: str, removal_version: str = _DEFAULT_REMOVAL_VERSION) None¶
Register a deprecated attribute whose value is produced by factory on access.
- add_lazy_all(items: dict[str, collections.abc.Callable[[], Any]], guidance: str, removal_version: str = _DEFAULT_REMOVAL_VERSION) None¶
Register multiple lazy deprecated attributes sharing the same guidance.
- resolve(name: str) Any¶
Look up name, emit a :class:
DeprecationWarning, and return its value.Raises :class:
AttributeErrorif name is not registered. Intended to be called from a module-level__getattr__.