How to declare a module deprecated in python?
I want a warning to be printed whenever a particular module is imported or any of its functions are called.
use deprecation module to deprecate methods. deprecation is a library that enables automated deprecations. It offers the deprecated() decorator to wrap functions, providing proper warnings both in documentation and via Python's warnings system, as well as the deprecation.
Deprecated Modules is a module that will warn game masters whenever they use a module that they shouldn't be using anymore. This includes modules that have been integrated into core Foundry, modules that have been entirely replaced by other modules, and modules that have broken and are no longer being maintained.
Usage of a module may be 'deprecated', which means that it may be removed from a future Python release.
You want to warn
with a DeprecationWarning
.
Exactly how you call it doesn't matter that much, but the stdlib has a standard pattern for deprecated modules, like this:
# doc string, top-level comments, imports, __all__ =
import warnings
warnings.warn("the spam module is deprecated", DeprecationWarning,
stacklevel=2)
# normal module code
See the 2.7 sets
source for an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With