Propose a less error-prone helper for module-level getattrs.#20857
Merged
QuLogic merged 2 commits intomatplotlib:masterfrom Aug 20, 2021
Merged
Propose a less error-prone helper for module-level getattrs.#20857QuLogic merged 2 commits intomatplotlib:masterfrom
QuLogic merged 2 commits intomatplotlib:masterfrom
Conversation
Contributor
|
Does this method correctly distinguish between |
45d82f5 to
382ea55
Compare
Contributor
Author
|
Yes. (In fact, that's the reason why I switched to a class-based approach, as a function-based approach would have trouble distinguishing either between missing globals and globals set to None, or between genuine AttributeErrors and AttributeErrors arising because of a bug in the calculation of the dynamically generated value.) |
382ea55 to
971a904
Compare
QuLogic
reviewed
Aug 18, 2021
5d30b57 to
87392d8
Compare
QuLogic
approved these changes
Aug 18, 2021
Apparently we always forget to generate the fallback AttributeError, so introduce a helper to do so instead. The changes in `deprecation.py` are (a) so that one can correctly suppress the inferred type when deprecating properties (the new check is coherent with the `if isinstance(obj, type)` and other cases) and (b) to make single-argument `__get__` work on deprecated properties (consistently with standard properties).
87392d8 to
d427153
Compare
tacaswell
approved these changes
Aug 20, 2021
Member
7 tasks
Contributor
I don't know that it replaces it --- that PR simply adds a unit test. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apparently we always forget to generate the fallback AttributeError (#20822, #20855), so
introduce a helper to do so instead. (I'm not wedded to the exact API...)
The changes in
deprecation.pyare (a) so that one can correctlysuppress the inferred type when deprecating properties (the new check is
coherent with the
if isinstance(obj, type)and other cases) and (b) tomake single-argument
__get__work on deprecated properties(consistently with standard properties).
Would replace #20856.
PR Summary
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).