Avoid inserting redundant None elements in UP045#23459
Merged
charliermarsh merged 1 commit intomainfrom Mar 1, 2026
Merged
Conversation
49e3165 to
aeb4480
Compare
|
amyreese
approved these changes
Feb 21, 2026
Comment on lines
+333
to
+334
| - bar: None | Optional[None | int] = None | ||
| 89 + bar: None | int | None = None |
Member
There was a problem hiding this comment.
Is this supposed to de-dupe the None here?
Member
Author
There was a problem hiding this comment.
That's a good call... I'll do it in a separate PR...
4a0a7f5 to
aeb4480
Compare
ntBre
approved these changes
Feb 23, 2026
| /// Collect all leaf elements of a chain of `BitOr` binary operations. | ||
| /// | ||
| /// For example, `a | b | c` is collected as `[a, b, c]`. | ||
| fn collect_bitor_elements(expr: &Expr) -> Vec<&Expr> { |
Contributor
There was a problem hiding this comment.
Can we use traverse_union here? It looks kind of similar.
Member
Author
There was a problem hiding this comment.
(I don't think so, since traverse_union also traverses Union[...], and we don't want to touch those here IIUC...)
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
aeb4480 to
fbad59c
Compare
fbad59c to
bf592e5
Compare
carljm
added a commit
that referenced
this pull request
Mar 2, 2026
* main: [ty] Move binary expression logic out of `builder.rs` (#23649) [ty] Limit recursion depth when displaying self-referential function types (#23647) [ty] Move comparison logic out of `builder.rs` (#23646) Avoid inserting redundant `None` elements in UP045 (#23459) [ty] Add more ParamSpec validation for `P.args` and `P.kwargs` (#23640) [ty] Sync vendored typeshed stubs (#23642) [ty] Fix inference of `t.__mro__` if `t` is an instance of `type[Any]` (#23632) [ty] Detect inconsistent generic base class specializations (#23615) [ty] Validate type variable defaults don't reference later type parameters or type parameters out of scope (#23623) [ty] Ban nested `Required`/`NotRequired`, and ban them both outside of `TypedDict` fields (#23627) [ty] Reject generic metaclasses parameterized by type variables (#23628) Update default Python version examples (#23605) fix binops with NewType of float and Unknown (#23620) [ty] Reject functions with PEP-695 type parameters that shadow type parameters from enclosing scopes (#23619) [ty] Reject ellipsis literals in odd places in type/annotation expressions (#23611) [ty] hash-cons `UseDefMap` fields (#23283)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #23429.