Skip to content

Conversation

danparizher
Copy link
Contributor

Summary

Fixes #19746

Copy link
Contributor

github-actions bot commented Aug 5, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Contributor

@ntBre ntBre left a 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:

// 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);
}

@danparizher danparizher requested a review from ntBre August 7, 2025 23:18
Copy link
Contributor

@ntBre ntBre left a 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.

@ntBre ntBre added bug Something isn't working fixes Related to suggested fixes for violations labels Aug 14, 2025
@danparizher danparizher requested a review from ntBre August 15, 2025 19:55
Copy link
Contributor

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

I just pushed one tiny inlining and relocated the CLI test.

@ntBre ntBre changed the title [pyupgrade] Fix missing flatten_optional import in UP045 rule [pyupgrade] Handle nested Optionals (UP045) Aug 19, 2025
@ntBre ntBre merged commit e0f4cec into astral-sh:main Aug 19, 2025
35 checks passed
@danparizher danparizher deleted the fix-19746 branch August 19, 2025 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UP045 fixes Optional[Optional[x]] to x | None | None
2 participants