-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added cls.__dict__.get('__annotations__')
check
#18233
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
base: main
Are you sure you want to change the base?
Conversation
looks like you need to regenerate the JSON schema -- running |
Python < 3.10 with `typing_extensions` enabled.
34602f5
to
8669fd7
Compare
|
crates/ruff_linter/src/rules/ruff/rules/class_dict_annotations.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/class_dict_annotations.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/class_dict_annotations.rs
Outdated
Show resolved
Hide resolved
Thank you for the review @JelleZijlstra! I will work on these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
The error message might be a bit long with mentioning all the different get_annotations()
functions.
#[derive_message_formats] | ||
fn message(&self) -> String { | ||
"Use `typing_extensions.get_annotations` (Python < 3.10 with \ | ||
`typing_extensions` enabled), `inspect.get_annotations` \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"enabled" is an odd word choice, is that used elsewhere in Ruff? I'd use "installed" (this also occurs a few other times in the file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking another look @JelleZijlstra!
You're right, the original error message was a bit lengthy. I've trimmed about 25 characters off, but I'm happy to iterate on this further if you have other suggestions for conciseness.
Regarding "enabled" vs. "installed"; thanks for pointing that out. I think some distinction and mixed use might be necessary. For example, I think that:
- the module typing-extensions should be installed
- the ruff setting typing-extensions should be enabled
Does this distinction for using 'enabled' in the context of the ruff setting seem reasonable to you? I'm open to suggestions if you still feel like "installed" makes more sense or if a different term would be clearer here.
I've pushed the above changes for review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, didn't realize that was a reference to a Ruff setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's understandable, the code was a bit ambiguous regarding the typing-extensions
module vs setting. I'm hopeful that the changes in the last commit make that distinction clearer. Please let me know if it's still not quite hitting the mark! Thanks for sticking with me @JelleZijlstra!
@dylwil3 could you review this PR (as the author of the issue and it being Python 3.14 related?) |
Added
cls.__dict__.get('__annotations__')
check for Python 3.10+ and Python < 3.10 withtyping-extensions
enabled.Closes #17853
Summary
Added
cls.__dict__.get('__annotations__')
check for Python 3.10+ and Python < 3.10 withtyping-extensions
enabled.Test Plan
cargo test