Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add D203 to rules that conflict with the formatter#25044

Merged
ntBre merged 1 commit into
astral-sh:mainfrom
Andrej730:docs-d203-formatter-conflicts
May 11, 2026
Merged

Add D203 to rules that conflict with the formatter#25044
ntBre merged 1 commit into
astral-sh:mainfrom
Andrej730:docs-d203-formatter-conflicts

Conversation

@Andrej730
Copy link
Copy Markdown
Contributor

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.

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.
```
@astral-sh-bot astral-sh-bot Bot requested a review from ntBre May 8, 2026 11:31
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented May 8, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre added the documentation Improvements or additions to documentation label May 11, 2026
Copy link
Copy Markdown
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thank you!

@ntBre ntBre changed the title docs: Add D203 to formatter conflicting rules Add D203 to rules that conflict with the formatter May 11, 2026
@ntBre ntBre merged commit 89b45a9 into astral-sh:main May 11, 2026
44 checks passed
@Andrej730 Andrej730 deleted the docs-d203-formatter-conflicts branch May 12, 2026 19:22
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants