Skip to content

Skip invalid string character checks when the source contains none - #29883

Merged
MichaReiser merged 2 commits into
mainfrom
micha/skip-absent-invalid-string-characters
Nov 2, 2026
Merged

MichaReiser merged 2 commits into
mainfrom
micha/skip-absent-invalid-string-characters

Conversation

@MichaReiser

@MichaReiser MichaReiser commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Skip the token walk for PLE2510 and PLE2512–PLE2515 when the source contains none of the five characters these rules report. Files containing a candidate character use the existing token checks and interpolation tracking.

On boxed main (049c351bef), the change reduced instructions in all 15 eligible linter benchmarks. Ten cases used at least 2% fewer instructions, and the pooled reduction was 2.38%. The five default-rule cases used 3.44–13.30% fewer instructions.

On the Python 3.12 standard library, end-to-end Ruff lint used 2,942,099,033 → 2,821,572,978 instructions (−4.10%) compared with this PR’s boxed parent (9623e698ec). Both builds enabled the same 407 rules, including all five affected rules, and produced identical diagnostics across three paired runs.

Test Plan

The six invalid-character rule tests passed.

@MichaReiser MichaReiser added the performance Potential performance improvement label Nov 1, 2026
@MichaReiser
MichaReiser added this pull request to stack #29884 November 1, 2026 18:56
@astral-automations-bot

astral-automations-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Linter (stable) · Linter (preview)


Results for e665900 · Workflow run

@MichaReiser
MichaReiser removed this pull request from stack #29884 November 1, 2026 22:35
@MichaReiser
MichaReiser added this pull request to stack #29893 November 1, 2026 22:36
@MichaReiser
MichaReiser marked this pull request as ready for review November 2, 2026 10:27
@MichaReiser
MichaReiser removed this pull request from stack #29893 November 2, 2026 10:51
@MichaReiser
MichaReiser added this pull request to stack #29900 November 2, 2026 10:52
Base automatically changed from micha/ty-top-level-imports to main November 2, 2026 11:30
@MichaReiser
MichaReiser requested a review from a team as a code owner November 2, 2026 11:30
@MichaReiser
MichaReiser force-pushed the micha/skip-absent-invalid-string-characters branch from e261d3b to 702416e Compare November 2, 2026 11:30
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@MichaReiser
MichaReiser force-pushed the micha/skip-absent-invalid-string-characters branch from 8cf6493 to e665900 Compare November 2, 2026 13:48
@MichaReiser
MichaReiser merged commit 19b23fa into main Nov 2, 2026
54 of 55 checks passed
@MichaReiser
MichaReiser deleted the micha/skip-absent-invalid-string-characters branch November 2, 2026 13:56

This branch was previously deployed

1 inactive deployment
automations — e665900b Deployed Nov 2, 2026 by MichaReiser via security-review / security review #96553
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants