deprecator

Class for recording and reporting deprecations

Deprecator(version_comparator[, warn_class, …])

Class to make decorator marking function or method as deprecated

ExpiredDeprecationError

Error for expired deprecation

Deprecator

class nibabel.deprecator.Deprecator(version_comparator, warn_class=<class 'DeprecationWarning'>, error_class=<class 'nibabel.deprecator.ExpiredDeprecationError'>)

Bases: object

Class to make decorator marking function or method as deprecated

The decorated function / method will:

  • Raise the given warning_class warning when the function / method gets called, up to (and including) version until (if specified);

  • Raise the given error_class error when the function / method gets called, when the package version is greater than version until (if specified).

Parameters
version_comparatorcallable

Callable accepting string as argument, and return 1 if string represents a higher version than encoded in the version_comparator, 0 if the version is equal, and -1 if the version is lower. For example, the version_comparator may compare the input version string to the current package version string.

warn_classclass, optional

Class of warning to generate for deprecation.

error_classclass, optional

Class of error to generate when version_comparator returns 1 for a given argument of until in the __call__ method (see below).

__init__(version_comparator, warn_class=<class 'DeprecationWarning'>, error_class=<class 'nibabel.deprecator.ExpiredDeprecationError'>)

Initialize self. See help(type(self)) for accurate signature.

is_bad_version(version_str)

Return True if version_str is too high

Tests version_str with self.version_comparator

Parameters
version_strstr

String giving version to test

Returns
is_badbool

True if version_str is for version below that expected by self.version_comparator, False otherwise.

ExpiredDeprecationError

class nibabel.deprecator.ExpiredDeprecationError

Bases: RuntimeError

Error for expired deprecation

Error raised when a called function or method has passed out of its deprecation period.

__init__($self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.