Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[flake8-pyi, ruff] Fix traversal of nested literals and unions (PYI016, PYI051, PYI055, PYI062, RUF041)#14641

Merged
AlexWaygood merged 4 commits into
astral-sh:mainfrom
sbrugman:nested-literals-unions
Nov 28, 2024
Merged

[flake8-pyi, ruff] Fix traversal of nested literals and unions (PYI016, PYI051, PYI055, PYI062, RUF041)#14641
AlexWaygood merged 4 commits into
astral-sh:mainfrom
sbrugman:nested-literals-unions

Conversation

@sbrugman

@sbrugman sbrugman commented Nov 27, 2024

Copy link
Copy Markdown
Contributor

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.

@github-actions

github-actions Bot commented Nov 27, 2024

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.

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

Comment thread crates/ruff_python_semantic/src/model.rs Outdated
@AlexWaygood AlexWaygood added the linter Related to the linter label Nov 27, 2024
@sbrugman

Copy link
Copy Markdown
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

@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.

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
@sbrugman sbrugman deleted the nested-literals-unions branch November 28, 2024 18:08
ntBre added a commit that referenced this pull request Mar 11, 2025
Summary
--

Stabilizes RUF041. The tests are already in the right place, and the docs look
good.

Test Plan
--

0 issues, 1 [PR] fixing nested literals and unions the day after the rule was
added. No changes since then

I wonder if the fix in that PR could be relevant for
#16639, where I noticed a potential issue
with `Union`. It could be unrelated, though.

[PR]: #14641
ntBre added a commit that referenced this pull request Mar 12, 2025
Summary
--

Stabilizes RUF041. The tests are already in the right place, and the
docs look good.

Test Plan
--

0 issues, 1 [PR] fixing nested literals and unions the day after the
rule was added. No changes since then

I wonder if the fix in that PR could be relevant for
#16639, where I noticed a
potential issue with `Union`. It could be unrelated, though.

[PR]: #14641
MichaReiser pushed a commit that referenced this pull request Mar 13, 2025
Summary
--

Stabilizes RUF041. The tests are already in the right place, and the
docs look good.

Test Plan
--

0 issues, 1 [PR] fixing nested literals and unions the day after the
rule was added. No changes since then

I wonder if the fix in that PR could be relevant for
#16639, where I noticed a
potential issue with `Union`. It could be unrelated, though.

[PR]: #14641
MichaReiser pushed a commit that referenced this pull request Mar 13, 2025
Summary
--

Stabilizes RUF041. The tests are already in the right place, and the
docs look good.

Test Plan
--

0 issues, 1 [PR] fixing nested literals and unions the day after the
rule was added. No changes since then

I wonder if the fix in that PR could be relevant for
#16639, where I noticed a
potential issue with `Union`. It could be unrelated, though.

[PR]: #14641
KotlinIsland pushed a commit to KotlinIsland/basedpython that referenced this pull request May 1, 2026
Summary
--

Stabilizes RUF041. The tests are already in the right place, and the
docs look good.

Test Plan
--

0 issues, 1 [PR] fixing nested literals and unions the day after the
rule was added. No changes since then

I wonder if the fix in that PR could be relevant for
astral-sh/ruff#16639, where I noticed a
potential issue with `Union`. It could be unrelated, though.

[PR]: astral-sh/ruff#14641
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