bundles / astropy 7.0.1 / astropy / utils / decorators / deprecated_attribute
function
astropy.utils.decorators:deprecated_attribute
source: /astropy/utils/decorators.py :239
Signature
def deprecated_attribute ( name , since , message = None , alternative = None , pending = False , warning_type = <class 'astropy.utils.exceptions.AstropyDeprecationWarning'> , pending_warning_type = <class 'astropy.utils.exceptions.AstropyPendingDeprecationWarning'> ) Summary
Used to mark a public attribute as deprecated. This creates a property that will warn when the given attribute name is accessed. To prevent the warning (i.e. for internal code), use the private name for the attribute by prepending an underscore (i.e. self._name), or set an alternative explicitly.
Parameters
name: strThe name of the deprecated attribute.
since: strThe release at which this API became deprecated. This is required.
message: str, optionalOverride the default deprecation message. The format specifier
namemay be used for the name of the attribute, andalternativemay be used in the deprecation message to insert the name of an alternative to the deprecated function.alternative: str, optionalAn alternative attribute that the user may use in place of the deprecated attribute. The deprecation warning will tell the user about this alternative if provided.
pending: bool, optionalIf True, uses a AstropyPendingDeprecationWarning instead of
warning_type.warning_type: WarningWarning to be issued. Default is AstropyDeprecationWarning.
pending_warning_type: WarningPending warning to be issued. This only works if
pendingis set to True. Default is AstropyPendingDeprecationWarning.
Examples
:: class MyClass: # Mark the old_name as deprecated old_name = deprecated_attribute("old_name", "0.1") def method(self): self._old_name = 42 class MyClass2: old_name = deprecated_attribute( "old_name", "1.2", alternative="new_name" ) def method(self): self.new_name = 24Aliases
-
astropy.utils.deprecated_attribute