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

Fix dropped union expressions for piped non-types in PYI055 autofix #9161

Merged
merged 2 commits into from
Dec 16, 2023

Conversation

diceroll123
Copy link
Contributor

@diceroll123 diceroll123 commented Dec 16, 2023

Summary

Fix dropped union expressions for piped non-types in PYI055 autofix

If you had type[int] | type[str] | str, it would have dropped the str, which breaks the type!

Closes #9156

Test Plan

cargo test

@diceroll123 diceroll123 force-pushed the fix-pyi055 branch 3 times, most recently from baf7f95 to 76b0e36 Compare December 16, 2023 12:33
Copy link
Contributor

github-actions bot commented Dec 16, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@diceroll123 diceroll123 changed the title Fix dropped union expressions for piped non-types in PYI055 Fix dropped union expressions for piped non-types in PYI055 autofix Dec 16, 2023
@@ -144,24 +147,32 @@ pub(crate) fn unnecessary_type_union<'a>(checker: &mut Checker, union: &'a Expr)
range: TextRange::default(),
}))
Copy link
Member

Choose a reason for hiding this comment

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

Do we not need to take the other_exprs into account in the top part of this if-else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double-check!

Copy link
Member

@charliermarsh charliermarsh 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!

@charliermarsh charliermarsh merged commit 85b27a9 into astral-sh:main Dec 16, 2023
17 checks passed
@charliermarsh charliermarsh added the bug Something isn't working label Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PYI055's "safe" fix breaks type annotation semantics
2 participants