Allow skipping warnings on subclasses and deferring warning classes.

Review Request #13123 — Created June 22, 2023 and submitted — Latest diff uploaded

Information

housekeeping
master

Reviewers

While converting Djblets to housekeeping, we hit an interesting case
where we needed to allow a deprecated base class to remain a base class
for now, but to warn when otherwise used. Furthermore, the base class
was for deprecation warnings, and needed to use a versioned warning
class when otherwise subclassed.

To handle that, two additions were made:

  1. Subclasses of a ClassDeprecatedMixin or ClassMovedMixin can now
    set housekeeping_skip_warning = True to avoid a warning being
    emitted.

  2. All warning_cls parameters can now take a callable that returns a
    warning class when it's time to emit. This can help avoid circular
    reference issues in this particular type of case.

Unit tests pass.

Tested this with upcoming work on moving Djblets to housekeeping.

Diff Revision 1

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

orig
1
2

Commits

First Last Summary ID Author
Allow skipping warnings on subclasses and deferring warning classes.
While converting Djblets to housekeeping, we hit an interesting case where we needed to allow a deprecated base class to remain a base class for now, but to warn when otherwise used. Furthermore, the base class was for deprecation warnings, and needed to use a versioned warning class when otherwise subclassed. To handle that, two additions were made: 1. Subclasses of a `ClassDeprecatedMixin` or `ClassMovedMixin` can now set `housekeeping_skip_warning = True` to avoid a warning being emitted. 2. All `warning_cls` parameters can now take a callable that returns a warning class when it's time to emit. This can help avoid circular reference issues in this particular type of case.
f6d813a9f982290b7a5ee05cbadac88577eda725 Christian Hammond
housekeeping/base.py
housekeeping/classes.py
housekeeping/functions.py
housekeeping/helpers.py
housekeeping/modules.py
housekeeping/tests/test_classes.py
housekeeping/tests/test_functions.py
housekeeping/tests/test_modules.py
Loading...