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

Add autofix for PYI030 #7934

Merged
merged 6 commits into from
Nov 30, 2023
Merged

Add autofix for PYI030 #7934

merged 6 commits into from
Nov 30, 2023

Conversation

diceroll123
Copy link
Contributor

@diceroll123 diceroll123 commented Oct 13, 2023

Summary

Part 2 of implementing the reverted autofix for PYI030

Also handles typing.Union and typing_extensions.Literal etc, uses the first subscript name it finds for each offensive line.

Test Plan

cargo test and manually

zanieb added a commit that referenced this pull request Oct 13, 2023
This reverts commit #7880 (d8c0360)
which does not perform the correct fix per
#7934
@diceroll123 diceroll123 marked this pull request as ready for review October 14, 2023 23:24
@diceroll123 diceroll123 changed the title Fix PYI030 bug with non-literal unions Add autofix for PYI030 Oct 14, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 14, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@zanieb
Copy link
Member

zanieb commented Oct 15, 2023

Could you gate this fix so it only applies when preview mode is enabled?

@diceroll123
Copy link
Contributor Author

I believe I've done this correctly, doesn't seem like any other fix is gated this way. 🤔 If I've done this wrong, please advise!

@zanieb zanieb self-requested a review October 16, 2023 21:28
@zanieb zanieb self-assigned this Oct 17, 2023
@zanieb
Copy link
Member

zanieb commented Oct 28, 2023

Hey sorry this is on my todo list to review but I got distracted last week – I'll try to get to this on Monday!

@diceroll123
Copy link
Contributor Author

Hey sorry this is on my todo list to review but I got distracted last week – I'll try to get to this on Monday!

Take your time!

Copy link
Contributor

github-actions bot commented Nov 24, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -0 violations, +6 -0 fixes in 41 projects)

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

ruff check --no-cache --exit-zero --preview --select ALL

- airflow/cli/commands/task_command.py:80:21: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[False, "db", "memory"]`
+ airflow/cli/commands/task_command.py:80:21: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[False, "db", "memory"]`
- airflow/models/mappedoperator.py:88:20: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal["expand", "partial"]`
+ airflow/models/mappedoperator.py:88:20: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["expand", "partial"]`
- airflow/providers_manager.py:195:24: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal["source", "package"]`
+ airflow/providers_manager.py:195:24: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["source", "package"]`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PYI030 6 0 0 6 0

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lgtm! Thanks for your patience.

@zanieb zanieb enabled auto-merge (squash) November 30, 2023 22:11
@zanieb zanieb merged commit bbad4b4 into astral-sh:main Nov 30, 2023
16 checks passed
Copy link

codspeed-hq bot commented Nov 30, 2023

CodSpeed Performance Report

Merging #7934 will improve performances by 12.27%

Comparing diceroll123:tweak-PYI030 (2f6dd84) with main (2590aa3)

Summary

⚡ 5 improvements
✅ 20 untouched benchmarks

🆕 5 new benchmarks

Benchmarks breakdown

Benchmark main diceroll123:tweak-PYI030 Change
linter/all-rules[pydantic/types.py] 80.5 ms 72.1 ms +11.63%
linter/all-rules[unicode/pypinyin.py] 17.2 ms 16.2 ms +6.12%
🆕 linter/all-with-preview-rules[unicode/pypinyin.py] N/A 17.2 ms N/A
linter/all-rules[numpy/ctypeslib.py] 37 ms 34.2 ms +8.23%
🆕 linter/all-with-preview-rules[pydantic/types.py] N/A 78.8 ms N/A
linter/all-rules[large/dataset.py] 185.7 ms 165.4 ms +12.27%
🆕 linter/all-with-preview-rules[large/dataset.py] N/A 185.8 ms N/A
linter/all-rules[numpy/globals.py] 4.1 ms 3.9 ms +5.9%
🆕 linter/all-with-preview-rules[numpy/ctypeslib.py] N/A 37.3 ms N/A
🆕 linter/all-with-preview-rules[numpy/globals.py] N/A 4.2 ms N/A

@zanieb zanieb added rule Implementing or modifying a lint rule preview Related to preview mode features labels Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants