Add helpers for deprecating functions, arguments, and values.
Review Request #13012 — Created May 4, 2023 and submitted
This introduces four functions for helping deprecate function-related
code:
-
@deprecate_non_keyword_only_args
takes a function with keyword-only
arguments and allows them to be called with positional arguments while
emitting a deprecation warning. This is a port of the code used in
RBTools and Djblets today. -
@func_deprecated
takes a function and emits a deprecation warning
when called. -
@func_moved
takes a function and emits a deprecation warning
when called, pointing to a new function elsewhere. -
deprecated_arg_value
wraps a value and emits a deprecation warning
if it's used in any way. It's useful for passing old arguments to
callbacks. This is a port of the code used in Djblets today.
Unit tests have been added for all of these functions.
All unit tests pass for all supported versions of Python.
Viewed the README in a GitHub-compatible Markdown viewer.
Summary | ID |
---|---|
e963855fc79344c4b4a5bde4b8c5ef6f329e3ad2 |
Description | From | Last Updated |
---|---|---|
'warnings' imported but unused Column: 1 Error code: F401 |
reviewbot | |
'typing.Type' imported but unused Column: 1 Error code: F401 |
reviewbot | |
line too long (80 > 79 characters) Column: 80 Error code: E501 |
reviewbot | |
'typing.Optional' imported but unused Column: 1 Error code: F401 |
reviewbot | |
'housekeeping.base.DEFAULT_STACK_LEVEL' imported but unused Column: 1 Error code: F401 |
reviewbot | |
'inspect' imported but unused Column: 1 Error code: F401 |
reviewbot |
- Change Summary:
-
- Removed unused imports.
- Fixed a line length issue.
- Commits:
-
Summary ID 29dd6f948c03ad4ba3bcd23ef42da7fbfa5a339e 962609d504dc80dfe7776a5ee78309c8e71b1280
Checks run (2 succeeded)
- Change Summary:
-
- Added a helper for standardizing formatting of class and function names.
- Fixed decorators to preserve state like names and docs.
- Removed the
func_moved()
assignment form from docs, since we can't get the name. - Standardized some function arguments.
- Added stack level arguments to everything, adjusting it for the internal functions to ensure proper stack levels.
- Added testing of stack levels as a standard part of all warning checks.
- Commits:
-
Summary ID 962609d504dc80dfe7776a5ee78309c8e71b1280 e963855fc79344c4b4a5bde4b8c5ef6f329e3ad2