-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Propose a less error-prone helper for module-level getattrs. #20857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Does this method correctly distinguish between |
45d82f5
to
382ea55
Compare
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
5d30b57
to
87392d8
Compare
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
I don't know that it replaces it --- that PR simply adds a unit test. |
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.py
are (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
pytest
passes).flake8
on changed files to check).flake8-docstrings
and 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).