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, ruff] Fix traversal of nested literals and unions (PYI016, PYI051, PYI055, PYI062, RUF041) #14641

Merged
merged 4 commits into from
Nov 28, 2024

Conversation

sbrugman
Copy link
Contributor

@sbrugman sbrugman commented Nov 27, 2024

Summary

In previous work on PYI rules we found that the current traversal misses nested literals and unions.
These are rare but valid. As mentioned before, correctly handling these cases might be relevant for auto-generated stubs.

Test Plan

Added test cases in an earlier PR. Snapshots are updated and show nested literals and unions are now handled as expected.
No ecosystem changes.

Copy link
Contributor

github-actions bot commented Nov 27, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

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!! Most of the snapshot changes look great, but I spotted a couple of issues and I'm not sure I fully understand the changes you're making to the methods on SemanticModel

@AlexWaygood AlexWaygood added the linter Related to the linter label Nov 27, 2024
@sbrugman
Copy link
Contributor Author

Thanks Alex! I'll pick this up tomorrow.

@sbrugman sbrugman force-pushed the nested-literals-unions branch from 5899085 to b31732f Compare November 28, 2024 17:55
@sbrugman sbrugman force-pushed the nested-literals-unions branch from b31732f to e3b0f5f Compare November 28, 2024 17:55
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!!

@AlexWaygood AlexWaygood added the bug Something isn't working label Nov 28, 2024
@AlexWaygood AlexWaygood changed the title Fix traversal of nested literals and unions [flake8-pyi, ruff] Fix traversal of nested literals and unions (PYI016, PYI051, PYI055, PYI062, RUF041) Nov 28, 2024
@AlexWaygood AlexWaygood merged commit dc29f52 into astral-sh:main Nov 28, 2024
21 checks passed
@sbrugman sbrugman deleted the nested-literals-unions branch November 28, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linter Related to the linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants