Skip to content

[pycodestyle] Implement redundant-backslash (E502) - #10292

Merged
charliermarsh merged 5 commits into
astral-sh:mainfrom
augustelalande:redundant-backslash
Mar 12, 2024
Merged

[pycodestyle] Implement redundant-backslash (E502)#10292
charliermarsh merged 5 commits into
astral-sh:mainfrom
augustelalande:redundant-backslash

Conversation

@augustelalande

@augustelalande augustelalande commented Mar 8, 2024

Copy link
Copy Markdown
Contributor

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
@github-actions

github-actions Bot commented Mar 8, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@charliermarsh charliermarsh left a comment

Copy link
Copy Markdown
Member

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
@augustelalande
augustelalande deleted the redundant-backslash branch March 12, 2024 02:45
@Avasam

Avasam commented Apr 30, 2024

Copy link
Copy Markdown
Contributor

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.

3 participants