[flake8-pyi] Always autofix duplicate-union-members (PYI016)#14270
Merged
MichaReiser merged 3 commits intoastral-sh:mainfrom Nov 13, 2024
Merged
[flake8-pyi] Always autofix duplicate-union-members (PYI016)#14270MichaReiser merged 3 commits intoastral-sh:mainfrom
flake8-pyi] Always autofix duplicate-union-members (PYI016)#14270MichaReiser merged 3 commits intoastral-sh:mainfrom
Conversation
Contributor
|
| 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 |
This was referenced Nov 11, 2024
[
flake8-pyi] Implement autofix and handle nested unions with single element (PYI041 , PYI055)
#14214
Closed
sbrugman
commented
Nov 11, 2024
crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs
Outdated
Show resolved
Hide resolved
MichaReiser
reviewed
Nov 12, 2024
Member
MichaReiser
left a comment
There was a problem hiding this comment.
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.
crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs
Outdated
Show resolved
Hide resolved
MichaReiser
reviewed
Nov 13, 2024
crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs
Outdated
Show resolved
Hide resolved
MichaReiser
approved these changes
Nov 13, 2024
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
This PR extends the autofix for
PYI016so 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