Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 2 commits intomatplotlib:masterfromanntzer:module-getattr
Aug 20, 2021

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedAug 18, 2021
edited
Loading

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 indeprecation.py are (a) so that one can correctly
suppress the inferred type when deprecating properties (the new check is
coherent with theif isinstance(obj, type) and other cases) and (b) to
make single-argument__get__ work on deprecated properties
(consistently with standard properties).

Would replace#20856.

PR Summary

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@lpsinger
Copy link
Contributor

Does this method correctly distinguish between__getattr__ returningNone for an attribute that is intended to exist but be defined asNone, versus__getattr__ raising an exception for an attribute that does not exist?

@anntzer
Copy link
ContributorAuthor

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.)

@anntzeranntzerforce-pushed themodule-getattr branch 2 times, most recently from5d30b57 to87392d8CompareAugust 18, 2021 22:00
@QuLogicQuLogic added this to thev3.5.0 milestoneAug 18, 2021
@QuLogicQuLogic added Maintenance Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. status: needs rebase labelsAug 19, 2021
anntzerand others added2 commitsAugust 20, 2021 16:14
Apparently we always forget to generate the fallback AttributeError, sointroduce a helper to do so instead.The changes in `deprecation.py` are (a) so that one can correctlysuppress the inferred type when deprecating properties (the new check iscoherent with the `if isinstance(obj, type)` and other cases) and (b) tomake single-argument `__get__` work on deprecated properties(consistently with standard properties).
@tacaswell
Copy link
Member

I also cherry-picked@lpsinger 's commit from#20856 into this PR just to be sure that they did not conflict with each other.

@lpsinger
Copy link
Contributor

Would replace#20856.

I don't know that it replaces it --- that PR simply adds a unit test.

@QuLogic
Copy link
Member

Would replace#20856.

I don't know that it replaces it --- that PR simply adds a unit test.

But it does now:

I also cherry-picked@lpsinger 's commit from#20856 into this PR just to be sure that they did not conflict with each other.

@QuLogicQuLogic merged commitaf68218 intomatplotlib:masterAug 20, 2021
@anntzeranntzer deleted the module-getattr branchAugust 21, 2021 09:44
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Labels
MaintenanceRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v3.5.0
Development

Successfully merging this pull request may close these issues.

4 participants
@anntzer@lpsinger@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp