Visitar URL original
[`flake8-pyi`] Fix PYI034 to not trigger on metaclasses (`PYI034`) by danparizher · Pull Request #20881 · astral-sh/ruff · GitHub
Skip to content

[flake8-pyi] Fix PYI034 to not trigger on metaclasses (PYI034) - #20881

Merged
ntBre merged 8 commits into
astral-sh:mainfrom
danparizher:fix-20781
Oct 24, 2025
Merged

ntBre merged 8 commits into
astral-sh:mainfrom
danparizher:fix-20781

Conversation

@danparizher

Copy link
Copy Markdown
Contributor

Summary

Fixes #20781

@github-actions

github-actions Bot commented Oct 15, 2025 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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 AlexWaygood left a comment

Copy link
Copy Markdown
Member

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 😄

@AlexWaygood
AlexWaygood requested a review from ntBre October 24, 2025 10:33
@ntBre ntBre added bug An issue describing something that isn't working, or a PR that fixes a bug rule Implementing or modifying a lint rule labels Oct 24, 2025
@ntBre

ntBre commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

Thanks @AlexWaygood, this looks great! And you did all the hard work, I basically just copied your docstring into the rule docs 😄

@AlexWaygood

Copy link
Copy Markdown
Member

Thanks @AlexWaygood, this looks great! And you did all the hard work, I basically just copied your docstring into the rule docs 😄

Ah I have to share credit with @danparizher for that docstring, he wrote half of it!!

…type.rs

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@ntBre
ntBre enabled auto-merge (squash) October 24, 2025 13:35
@ntBre
ntBre merged commit 7576669 into astral-sh:main Oct 24, 2025
36 checks passed
@danparizher
danparizher deleted the fix-20781 branch October 24, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PYI034 should not trigger on a metaclass

3 participants