Skip to content

Refactor TOML file linting - #26806

Merged
ntBre merged 6 commits into
mainfrom
brent/refactor-toml-rules
Jul 15, 2026
Merged

Refactor TOML file linting#26806
ntBre merged 6 commits into
mainfrom
brent/refactor-toml-rules

Conversation

@ntBre

@ntBre ntBre commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR was spun off from #26772 to handle some of the refactors to RUF200. The first non-empty
commit is purely moving the implementation of RUF200 from the general lint_pyproject_toml function
into its own rule file. In #26772, lint_pyproject_toml will become lint_toml and invoke multiple
rules.

The second commit drops the overly defensive range check, as noted in #26772 (comment).

The third commit refactors the rule to use a LintContext. This not only sets up to run multiple
rules in this function, but also fixes a latent bug in rule suppression for RUF200. Because the rule
previously checked whether it was enabled via the LinterSettings::rules.enabled directly, it
didn't take into account settings like per-file-ignores (this also affects unfixable and other
fix-related settings for RUF201). The fourth commit contains a new mdtest for this that currently
fails on main.

Finally, the fifth commit moves parsing out of RUF200. We still parse into a PyProjectToml for
now, but at least this sets us up to share parsing between rules once we find the right shared
representation.

Test Plan

New mdtest mentioned above and then rebasing #26772 onto this.

ntBre added 5 commits July 14, 2026 12:16
Summary
--

This PR was spun off from #26772 to handle some of the refactors to RUF200. The first non-empty
commit is purely moving the implementation of RUF200 from the general `lint_pyproject_toml` function
into its own rule file. In #26772, `lint_pyproject_toml` will become `lint_toml` and invoke multiple
rules.

The second commit drops the overly defensive range check, as noted in #26772 (comment).

The third commit refactors the rule to use a `LintContext`. This not only sets up to run multiple
rules in this function, but also fixes a latent bug in rule suppression for RUF200. Because the rule
previously checked whether it was enabled via the `LinterSettings::rules.enabled` directly, it
didn't take into account settings like `per-file-ignores` (this also affects `unfixable` and other
fix-related settings for RUF201). The fourth commit contains a new mdtest for this that currently
fails on main.

Finally, the fifth commit moves parsing out of RUF200. We still parse into a `PyProjectToml` for
now, but at least this sets us up to share parsing between rules once we find the right shared
representation.

Test Plan
--

New mdtest mentioned above and then rebasing #26772 onto this.
@ntBre ntBre added the internal An internal refactor or improvement label Jul 14, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 94.61%. The percentage of expected errors that received a diagnostic held steady at 90.27%. The number of fully passing files held steady at 97/134.

@astral-sh-bot

astral-sh-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

@astral-sh-bot

astral-sh-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@ntBre
ntBre force-pushed the brent/refactor-toml-rules branch from 76587c0 to a465d35 Compare July 14, 2026 16:43
@ntBre
ntBre marked this pull request as ready for review July 14, 2026 17:00
@ntBre
ntBre requested a review from MichaReiser July 14, 2026 17:02

@MichaReiser MichaReiser 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.

Thank you. Also thanks for taking the time to split the change into multiple commits and writing the excellent PR summary.

@ntBre
ntBre merged commit a616e08 into main Jul 15, 2026
63 checks passed
@ntBre
ntBre deleted the brent/refactor-toml-rules branch July 15, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants