Skip to content

Reuse a callee's qualified name across lint rules - #29916

Merged
MichaReiser merged 2 commits into
mainfrom
micha/reuse-callee-qualified-name
Nov 3, 2026
Merged

MichaReiser merged 2 commits into
mainfrom
micha/reuse-callee-qualified-name

Conversation

@MichaReiser

@MichaReiser MichaReiser commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Several lint rules can resolve the same callee while checking a single call. For example, with import numpy as np, they can each look up np.random.randint in np.random.randint(10). The call checker now resolves the callee once if any rule in the group is enabled, skips the group if resolution fails, and passes the qualified name to each enabled handler.

The first three rows count native arm64 instructions spent linting Ruff’s five benchmark files, with parsing and setup excluded. The last row counts the whole ruff check process over 686 Python 3.12 standard-library files with default rules and caching disabled.

Workload Before (million instructions) After (million instructions) Change
Lint, default rules 29.02 27.41 βˆ’5.53%
Lint, all stable rules 58.34 53.06 βˆ’9.05%
Lint, all rules with preview 71.65 66.24 βˆ’7.54%
Full standard-library check 3,308.72 3,236.85 βˆ’2.17%

Test Plan

The linter and semantic-model tests passed, and 1,711 rule fixtures produced the same diagnostics and applied fixes, allowing for display order at tied source offsets.

@MichaReiser MichaReiser added performance Potential performance improvement linter Related to the Ruff linter labels Nov 2, 2026
@astral-automations-bot

astral-automations-bot Bot commented Nov 2, 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 44142d2 Β· Workflow run

@MichaReiser
MichaReiser added this pull request to stack #29918 November 2, 2026 18:38
@codspeed

codspeed Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 7.28%

⚑ 5 improved benchmarks
βœ… 55 untouched benchmarks
⏩ 242 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚑ CPU Simulation linter/all-rules[large/dataset.py] 33.2 ms 29.7 ms +11.66%
⚑ CPU Simulation linter/all-with-preview-rules[large/dataset.py] 39.5 ms 36.2 ms +9.33%
⚑ CPU Simulation linter/default-rules[large/dataset.py] 16.9 ms 16.1 ms +5.48%
⚑ CPU Simulation linter/all-rules[pydantic/types.py] 15.7 ms 14.9 ms +5.44%
⚑ CPU Simulation linter/all-with-preview-rules[pydantic/types.py] 18.4 ms 17.6 ms +4.65%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing micha/reuse-callee-qualified-name (44142d2) with main (08cab22)

Open in CodSpeed

Footnotes

  1. 242 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@MichaReiser
MichaReiser marked this pull request as ready for review November 3, 2026 08:53
@MichaReiser
MichaReiser merged commit a63fe40 into main Nov 3, 2026
56 checks passed
@MichaReiser
MichaReiser deleted the micha/reuse-callee-qualified-name branch November 3, 2026 15:33

This branch was previously deployed

1 inactive deployment
automations β€” 44142d2d Deployed Nov 3, 2026 by MichaReiser via security-review / security review #96732
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linter Related to the Ruff linter performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants