Skip to content
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

[flake8-pyi] Avoid flagging custom-typevar-for-self on metaclass methods (PYI019) #16141

Conversation

vladNed
Copy link
Contributor

@vladNed vladNed commented Feb 13, 2025

Summary

Function custom_type_var_instead_of_self handling PYI019 was modifying return type to Self for metaclasses as the is_metaclass check was missing form implementation.

As discussed in #16127, this is a behavior not accepted by PEP 673

Test Plan

  • Tested with a metaclass in order to check that the type is not an issue
  • Tested with a normal class to check that Self is indeed outlined when checking with ruff
  • Added a metaclass to resources py files and made a new snapshot

@vladNed vladNed requested a review from AlexWaygood as a code owner February 13, 2025 17:31
Copy link
Contributor

github-actions bot commented Feb 13, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -1 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

rotki/rotki (+0 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

- rotkehlchen/utils/mixins/enums.py:12:16: PYI019 [*] Use `Self` instead of custom TypeVar `T`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PYI019 1 0 1 0 0

@AlexWaygood AlexWaygood added bug Something isn't working rule Implementing or modifying a lint rule labels Feb 13, 2025
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you! I pushed a very minor simplification, but this is great

@AlexWaygood AlexWaygood changed the title [flake8-pyi] Avoid flagging on metaclasses (PYI019) [flake8-pyi] Avoid flagging custom-typevar-for-self on metaclass methods (PYI019) Feb 13, 2025
@AlexWaygood AlexWaygood enabled auto-merge (squash) February 13, 2025 18:42
@AlexWaygood AlexWaygood linked an issue Feb 13, 2025 that may be closed by this pull request
@AlexWaygood AlexWaygood merged commit cb8b23d into astral-sh:main Feb 13, 2025
19 of 20 checks passed
@vladNed vladNed deleted the bugfix/rule-pyi019-should-not-flag-metaclass-method branch February 14, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule PYI019 should not flag metaclass methods
2 participants