Add D203 to rules that conflict with the formatter#25044
Merged
Conversation
Noticed the warning below when running `ruff format`, which wasn't documented in https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules. ``` ruff format --check warning: The following rule may cause conflicts when used with the formatter: `D203`. To avoid unexpected behavior, we recommend disabling this rule, either by removing it from the `lint.select` or `lint.extend-select` configuration, or adding it to the `lint.ignore` configuration. ```
|
D203 to rules that conflict with the formatter
MichaReiser
added a commit
that referenced
this pull request
May 13, 2026
When fixing #25044 and review what other rules might not be documented, I've stumbled upon https://docs.astral.sh/ruff/rules/prohibited-trailing-comma/ which is documented, but it seems to be more than just redundant. Using this rule changes the meaning of using magic comma in some cases. E.g. `foo = (1, 2, 3,)` - if user would run `ruff check` first, then it would strip the magic comma and `ruff format` would do nothing. And if we'd do `ruff format` first, then it would expand this to multiple lines and then `ruff check` would do nothing. Given that when you're writing code you might leave this magic command, knowing that it will expand later in an expected way, - with COM819 it might if you run linter first. So I've added a warning when this rule is enabled and adjusted the documentation. I've executed the tests and adjusted the ones that were testing `ALL`. All tests seems to be fine now, besides that one (seems unrelated to PR) and bunch of other tests that seems to conflict with my global ruff settings, I'll report it as an issue separately (see #25046). ``` Reviewing [1/6] [email protected]: Snapshot: semantic_syntax_errors Source: crates/ruff/tests/cli/lint.rs:3553 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── program: ruff args: - check - "--output-format" - concise - "--preview" - "--quiet" ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── -old snapshot +new results ────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 1 1 │ success: false 2 2 │ exit_code: 1 3 3 │ ----- stdout ----- 4 4 │ main.py:1:3: error[invalid-syntax] assignment expression cannot rebind comprehension variable 5 │-main.py:1:20: error[F821] Undefined name `foo` 6 5 │ 7 6 │ ----- stderr ----- ────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ``` --------- Co-authored-by: Micha Reiser <[email protected]>
thejchap
pushed a commit
to thejchap/ruff
that referenced
this pull request
May 23, 2026
Noticed the warning below when running `ruff format`, which wasn't documented in https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules. ``` ruff format --check # warning: The following rule may cause conflicts when used with the formatter: `D203`. # To avoid unexpected behavior, we recommend disabling this rule, either by removing it from the `lint.select` or `lint.extend-select` configuration, or adding it to the `lint.ignore` configuration. ```
thejchap
pushed a commit
to thejchap/ruff
that referenced
this pull request
May 23, 2026
When fixing astral-sh#25044 and review what other rules might not be documented, I've stumbled upon https://docs.astral.sh/ruff/rules/prohibited-trailing-comma/ which is documented, but it seems to be more than just redundant. Using this rule changes the meaning of using magic comma in some cases. E.g. `foo = (1, 2, 3,)` - if user would run `ruff check` first, then it would strip the magic comma and `ruff format` would do nothing. And if we'd do `ruff format` first, then it would expand this to multiple lines and then `ruff check` would do nothing. Given that when you're writing code you might leave this magic command, knowing that it will expand later in an expected way, - with COM819 it might if you run linter first. So I've added a warning when this rule is enabled and adjusted the documentation. I've executed the tests and adjusted the ones that were testing `ALL`. All tests seems to be fine now, besides that one (seems unrelated to PR) and bunch of other tests that seems to conflict with my global ruff settings, I'll report it as an issue separately (see astral-sh#25046). ``` Reviewing [1/6] [email protected]: Snapshot: semantic_syntax_errors Source: crates/ruff/tests/cli/lint.rs:3553 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── program: ruff args: - check - "--output-format" - concise - "--preview" - "--quiet" ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── -old snapshot +new results ────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 1 1 │ success: false 2 2 │ exit_code: 1 3 3 │ ----- stdout ----- 4 4 │ main.py:1:3: error[invalid-syntax] assignment expression cannot rebind comprehension variable 5 │-main.py:1:20: error[F821] Undefined name `foo` 6 5 │ 7 6 │ ----- stderr ----- ────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ``` --------- Co-authored-by: Micha Reiser <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed the warning below when running
ruff format, which wasn't documented in https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules.