Add helpers for deprecating classes.
Review Request #13013 — Created May 4, 2023 and submitted
Information | |
---|---|
chipx86 | |
housekeeping | |
master | |
Reviewers | |
beanbag-misc | |
This introduces
ClassDeprecatedMixin
andClassMovedMixin
.
ClassDeprecatedMixin
marks a class as deprecated, emitting a warning
when directly instantiated or subclassed. Warnings are not emitted when
instantiating or subclassing any subclasses of the class, though.
ClassMovedMixin
is similar, but it communicates that a class has moved
elsewhere. It can either take the new class to point to as parameter, or
it can be mixxed into a class that subclasses the new class (useful when
a legacy base class needs to subclass a newer base class).These make use of
__init_subclass__
and keyword arguments in the
subclass list to handle storing state and notifying on subclass. This
gives us metaclass-like functionality without the subclass having to
define state in the class body.
Unit tests pass on all supported versions of Python.
Summary | |
---|---|
Change Summary:
Fixed an alphabetical import issue.
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+1800 -8) |
Checks run (2 succeeded)
Change Summary:
Put the examples in the README into the class docstrings.
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+1840 -8) |
Checks run (2 succeeded)
Change Summary:
Updated to use standard display formatting and new unit test helpers.
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+1696 -8) |