-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[pyupgrade
] Handle nested Optional
s (UP045
)
#19770
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
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this fully solves the problem. You may also want to look at a related implementation in another rule:
ruff/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs
Lines 98 to 103 in 6b9692c
// Traverse the union, collect all diagnostic members | |
if is_optional_as_none_in_union_enabled(checker.settings()) { | |
traverse_union_and_optional(&mut check_for_duplicate_members, checker.semantic(), expr); | |
} else { | |
traverse_union(&mut check_for_duplicate_members, checker.semantic(), expr); | |
} |
crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think this is working well now. I just had a few small comments left. Could you fix the merge conflicts too? You probably just need to rerun the tests and accept the snapshots to pull in the new diagnostic format.
crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I just pushed one tiny inlining and relocated the CLI test.
pyupgrade
] Fix missing flatten_optional
import in UP045
rulepyupgrade
] Handle nested Optional
s (UP045
)
Summary
Fixes #19746