astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.4k stars 1.05k forks source link

formatter: `COM812`, `ISC001` warning #12085

Closed Mogost closed 3 months ago

Mogost commented 3 months ago

The following configuration triggers a warning message but shouldn't. All linter rules are enabled but warning contains rules that are in ignore section.

[tool.ruff]
line-length = 120
indent-width = 4

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
preview = true

[tool.ruff.lint]
select = ["ALL"]
ignore = [
...
    "COM812",  # https://docs.astral.sh/ruff/rules/missing-trailing-comma/
    "ISC001",  # https://docs.astral.sh/ruff/rules/single-line-implicit-string-concatenation/
]
❯ ruff format .
warning: The following rules may cause conflicts when used with the formatter: `COM812`, `ISC001`. To avoid unexpected behavior, we recommend disabling these rules, either by removing them from the `select` or `extend-select` configuration, or adding them to the `ignore` configuration.
2051 files left unchanged
MichaReiser commented 3 months ago

I tried to reproduce the issue with

[tool.ruff]
preview=true

[tool.ruff.format]
preview = true
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
    "COM812",
    "ISC001",
]

And ran

$ uv tool run ruff format
warning: `uv tool run` is experimental and may change without warning.
Resolved 1 package in 3ms
Installed 1 package in 4ms
 + ruff==0.5.0
warning: `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible. Ignoring `one-blank-line-before-class`.
warning: `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible. Ignoring `multi-line-summary-second-line`.
13 files left unchanged

I do get warnings about incompatible linter rules but not about COM812 or ISC001 being incompatible with the formatter. Do you have an other pyproject.tom in a sub folder?

Mogost commented 3 months ago

Oops. There is indeed a subdirectory with its own pyproject.toml. As soon as I removed it, the problem went away. Thanks and sorry for the inconvenience. And thanks for the awesome job!