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

[pycodestyle] Add fix for multiple-imports-on-one-line (E401) #9518

Merged
merged 8 commits into from
Jan 21, 2024

Conversation

diceroll123
Copy link
Contributor

Summary

Add autofix for multiple_imports_on_one_line, E401

Test Plan

cargo test

@diceroll123 diceroll123 force-pushed the add-autofix-for-E401 branch 2 times, most recently from 7b3b35e to 69f71d2 Compare January 15, 2024 02:04
Copy link
Contributor

github-actions bot commented Jan 15, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

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

bokeh/bokeh (+0 -0 violations, +2 -0 fixes)

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

- setup.py:10:1: E401 Multiple imports on one line
+ setup.py:10:1: E401 [*] Multiple imports on one line

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
E401 2 0 0 2 0

diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
replacement,
stmt.range(),
)));
Copy link
Member

@charliermarsh charliermarsh Jan 15, 2024

Choose a reason for hiding this comment

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

Can you add test cases for, e.g.:

x = 1; import re as regex, string

import re as regex, string; x = 1

Copy link

codspeed-hq bot commented Jan 15, 2024

CodSpeed Performance Report

Merging #9518 will not alter performance

Comparing diceroll123:add-autofix-for-E401 (92df930) with main (b64aa1e)

Summary

✅ 30 untouched benchmarks

@charliermarsh charliermarsh self-requested a review January 21, 2024 16:01
@charliermarsh charliermarsh added fixes Related to suggested fixes for violations preview Related to preview mode features labels Jan 21, 2024
@charliermarsh charliermarsh changed the title [pycodestyle] - add fix for multiple_imports_on_one_line (E401) [pycodestyle] Add fix for multiple-imports-on-one-line (E401) Jan 21, 2024
Copy link
Member

@charliermarsh charliermarsh 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 had to apply some changes to fix cases like: if True: import re as regex, string

})
.join("; ");

Fix::safe_edit(Edit::range_replacement(replacement, stmt.range()))
Copy link
Member

Choose a reason for hiding this comment

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

@diceroll123 - I decided to just ; -join these for now, since it's hard to know if we're allowed to split them.

@charliermarsh charliermarsh enabled auto-merge (squash) January 21, 2024 19:46
auto-merge was automatically disabled January 21, 2024 20:02

Head branch was pushed to by a user without write access

@charliermarsh charliermarsh merged commit 8379841 into astral-sh:main Jan 21, 2024
17 checks passed
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 preview Related to preview mode features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants