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] Implement redundant-backslash (E502) #10292

Merged
merged 5 commits into from Mar 12, 2024

Conversation

augustelalande
Copy link
Contributor

@augustelalande augustelalande commented Mar 8, 2024

Summary

Implements the redundant-backslash rule (E502) from pycodestyle.

Test Plan

New fixture has been added

Part of #2402

@augustelalande augustelalande changed the title [pycodestyle] Implement redundant-backslash (E502`) [pycodestyle] Implement redundant-backslash (E502) Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

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

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

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

+ src/bokeh/io/webdriver.py:198:105: E502 [*] Redundant backslash
+ src/bokeh/io/webdriver.py:199:105: E502 [*] Redundant backslash
+ src/bokeh/server/contexts.py:304:102: E502 [*] Redundant backslash
+ src/bokeh/server/session.py:90:96: E502 [*] Redundant backslash

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
E502 4 4 0 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

}
cursor += c.len_utf8();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

We have a struct called Indexer that already stores the locations of all continuations (i.e., the line positions following a \). I'm wondering if we could instead iterate over the token stream, identify parenthesized ranges, and then search for continuation_lines offsets within parenthesized ranges?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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, this looks good to me.

@charliermarsh charliermarsh added preview Related to preview mode features rule Implementing or modifying a lint rule labels Mar 12, 2024
@charliermarsh charliermarsh merged commit c746912 into astral-sh:main Mar 12, 2024
17 checks passed
@augustelalande augustelalande deleted the redundant-backslash branch March 12, 2024 02:45
@Avasam
Copy link

Avasam commented Apr 30, 2024

One more step towards #9057 🎉

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

3 participants