Add helpers for deprecating classes.

Review Request #13013 — Created May 4, 2023 and submitted — Latest diff uploaded

Information

housekeeping
master

Reviewers

This introduces ClassDeprecatedMixin and ClassMovedMixin.

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.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

orig
1
2
3
4

Commits

First Last Summary ID Author
Add helpers for deprecating classes.
This introduces `ClassDeprecatedMixin` and `ClassMovedMixin`. `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.
39cd53e2456e56e0b009c1d8d60624f3ba85518a Christian Hammond
README.md
housekeeping/__init__.py
housekeeping/classes.py
housekeeping/helpers.py
housekeeping/tests/test_classes.py
Loading...