Skip to content

Warn users of Python 3.14+ against cls.__dict__.get("__annotations__", {}) #17853

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

Open
dylwil3 opened this issue May 5, 2025 · 1 comment · May be fixed by #18233
Open

Warn users of Python 3.14+ against cls.__dict__.get("__annotations__", {}) #17853

dylwil3 opened this issue May 5, 2025 · 1 comment · May be fixed by #18233
Labels
help wanted Contributions especially welcome python314 Related to Python 3.14 rule Implementing or modifying a lint rule

Comments

@dylwil3
Copy link
Collaborator

dylwil3 commented May 5, 2025

Summary

cf #17658 (review) and #17658 (comment)

@dylwil3 dylwil3 added the rule Implementing or modifying a lint rule label May 5, 2025
@AlexWaygood AlexWaygood changed the title Warn user's of Python 3.14+ against cls.__dict__.get("__annotations__", {}) Warn users of Python 3.14+ against cls.__dict__.get("__annotations__", {}) May 5, 2025
@AlexWaygood
Copy link
Member

It might actually be good to emit this warning regardless of the target-version that Ruff infers. Just because somebody has target-version = "py38" in their config file doesn't mean that they're uninterested in their code working on Python 3.14. And there are more bulletproof ways of accessing the class's annotations that will work on all Python versions (either inspect.get_annotations or the typing_extensions backport of annotationlib.get_annotations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions especially welcome python314 Related to Python 3.14 rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants