API¶
The currently documented publicly exposed API’s for usage in your project are defined below.
Warning
External usage of internal utility functions and modules should be kept to a minimum as they may be altered, refactored or moved to other locations without notice (and without the typical deprecation cycle).
Helpers¶
-
debtcollector.
deprecate
(prefix, postfix=None, message=None, version=None, removal_version=None, stacklevel=3, category=<type 'exceptions.DeprecationWarning'>)[source]¶ Helper to deprecate some thing using generated message format.
Parameters: - prefix – prefix string used as the prefix of the output message
- postfix – postfix string used as the postfix of the output message
- message – message string used as ending contents of the deprecate message
- version – version string (represents the version this deprecation was created in)
- removal_version – version string (represents the version this deprecation will be removed in); a string of ‘?’ will denote this will be removed in some future unknown version
- stacklevel – stacklevel used in the
warnings.warn()
function to locate where the users code is in thewarnings.warn()
call - category – the
warnings
category to use, defaults toDeprecationWarning
if not provided
Moves¶
-
debtcollector.moves.
moved_function
(new_func, old_func_name, old_module_name, message=None, version=None, removal_version=None, stacklevel=3, category=None)[source]¶ Deprecates a function that was moved to another location.
This generates a wrapper around
new_func
that will emit a deprecation warning when called. The warning message will include the new location to obtain the function from.
-
class
debtcollector.moves.
moved_read_only_property
(old_name, new_name, version=None, removal_version=None, stacklevel=3, category=None)[source]¶ Bases:
object
Descriptor for read-only properties moved to another location.
This works like the
@property
descriptor but can be used instead to provide the same functionality and also interact with thewarnings
module to warn when a property is accessed, so that users of those properties can know that a previously read-only property at a prior location/name has moved to another location/name.Parameters: - old_name – old attribute location/name
- new_name – new attribute location/name
- version – version string (represents the version this deprecation was created in)
- removal_version – version string (represents the version this deprecation will be removed in); a string of ‘?’ will denote this will be removed in some future unknown version
- stacklevel – stacklevel used in the
warnings.warn()
function to locate where the users code is when reporting the deprecation call (the default being 3) - category – the
warnings
category to use, defaults toDeprecationWarning
if not provided
-
debtcollector.moves.
moved_method
(new_method_name, message=None, version=None, removal_version=None, stacklevel=3, category=None)[source]¶ Decorates an instance method that was moved to another location.
-
debtcollector.moves.
moved_property
(new_attribute_name, message=None, version=None, removal_version=None, stacklevel=3, category=None)[source]¶ Decorates an instance property that was moved to another location.
-
debtcollector.moves.
moved_class
(new_class, old_class_name, old_module_name, message=None, version=None, removal_version=None, stacklevel=3, category=None)[source]¶ Deprecates a class that was moved to another location.
This creates a ‘new-old’ type that can be used for a deprecation period that can be inherited from. This will emit warnings when the old locations class is initialized, telling where the new and improved location for the old class now is.