-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[flake8-pyi
] Always autofix duplicate-union-members
(PYI016
)
#14270
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PYI016 | 2 | 0 | 0 | 0 | 2 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +8 -0 fixes in 2 projects; 52 projects unchanged)
apache/superset (+0 -0 violations, +2 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
- superset/models/helpers.py:900:39: PYI016 Duplicate union member `str` + superset/models/helpers.py:900:39: PYI016 [*] Duplicate union member `str`
bokeh/bokeh (+0 -0 violations, +6 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
- src/bokeh/core/property/factors.py:51:56: PYI016 Duplicate union member `tuple[str, str]` + src/bokeh/core/property/factors.py:51:56: PYI016 [*] Duplicate union member `tuple[str, str]` - src/bokeh/core/property/factors.py:52:85: PYI016 Duplicate union member `tp.Sequence[tuple[str, str]]` + src/bokeh/core/property/factors.py:52:85: PYI016 [*] Duplicate union member `tp.Sequence[tuple[str, str]]` - src/bokeh/plotting/contour.py:43:88: PYI016 Duplicate union member `ContourColor` + src/bokeh/plotting/contour.py:43:88: PYI016 [*] Duplicate union member `ContourColor`
Changes by rule (1 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PYI016 | 8 | 0 | 0 | 8 | 0 |
flake8-pyi
] Implement autofix and handle nested unions with single element (PYI041
, PYI055
)
#14214
crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.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.
This is great. I have about the same comments as on the other PR:
- Using text-edits over generator has the advantage that the fix preserves (more) comments and the formatting. Is there a specific reason why you chose to rewrite the fix to being generator based
- I need to go through some other rules but I think we decided not to mark fixes as unsafe just because they could drop comments.
Summary
This PR extends the autofix for
PYI016
so that it's always available.It also improves the fix for a few cases where the previous fix would give awkward (but valid) results:
int | (str | int)
The fix now also marks as unsafe when comments are present.
Test Plan