Skip to content
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

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

sbrugman
Copy link
Contributor

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)

-`int | (str)`
+`int | str`

The fix now also marks as unsafe when comments are present.

Test Plan

Copy link
Contributor

github-actions bot commented Nov 11, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +0 -2 fixes in 1 projects; 53 projects unchanged)

apache/airflow (+0 -0 violations, +0 -2 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ providers/src/airflow/providers/microsoft/azure/operators/container_instances.py:253:43: PYI016 Duplicate union member `VolumeMount`
- providers/src/airflow/providers/microsoft/azure/operators/container_instances.py:253:43: PYI016 [*] Duplicate union member `VolumeMount`

Changes by rule (1 rules affected)

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

@AlexWaygood AlexWaygood added rule Implementing or modifying a lint rule fixes Related to suggested fixes for violations labels Nov 11, 2024
Copy link
Member

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

@MichaReiser MichaReiser enabled auto-merge (squash) November 13, 2024 16:39
@MichaReiser MichaReiser merged commit eb55b9b into astral-sh:main Nov 13, 2024
19 checks passed
@sbrugman sbrugman deleted the pyi016-always-autofix branch November 13, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants