-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[flake8-pyi] Fix PYI034 to not trigger on metaclasses (PYI034)
#20881
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
|
AlexWaygood
left a comment
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!
crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.pyi
Outdated
Show resolved
Hide resolved
Adds logic to identify classes with a metaclass-like __new__ method signature based on parameter count and type annotations. Updates is_metaclass to consider such signatures, improving detection of metaclasses that do not inherit from known metaclass bases.
AlexWaygood
left a comment
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, I pushed a few edits. The implementation LGTM now.
@ntBre, I think you mentioned on the issue that it might be good to document this heuristic? That does seem like it might be worthwhile. I'll punt this back to you now, if that's okay 😄
|
Thanks @AlexWaygood, this looks great! And you did all the hard work, I basically just copied your docstring into the rule docs 😄 |
crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs
Outdated
Show resolved
Hide resolved
Ah I have to share credit with @danparizher for that docstring, he wrote half of it!! |
…type.rs Co-authored-by: Alex Waygood <[email protected]>
Summary
Fixes #20781