Skip to content

pyproject.toml fix-only=True cannot be toggled per directory by using multiple pyproject.toml files and the extend setting. #15801

Open
@jogo-openai

Description

@jogo-openai

Description

I am trying to enable fix-only for some directories and not for others, while running ruff check . in the repo root directory.

Ruff fix-only config option doesn't seem to use the 'closest' config file for each individual file.

https://docs.astral.sh/ruff/configuration/#config-file-discovery

$ ruff --version
ruff 0.9.3
├── foo
│   ├── bar.py
│   └── pyproject.toml
└── pyproject.toml

pyproject.toml:

[tool.ruff]
lint.select = ["F"]

foo/pyproject.toml:

[tool.ruff]
extend = "../pyproject.toml"
fix-only = true

foo/bar.py:

import os

from __future__ import annotations

When running ruff check from the root directory here, I expect it to use fix-onlyfromfoo/pyproject.tomlsince it's the closest config file tofoo/bar.py` but it doesn't.

$ ruff check .
foo/bar.py:1:8: F401 [*] `os` imported but unused
  |
1 | import os
  |        ^^ F401
2 |
3 | from __future__ import annotations
  |
  = help: Remove unused import: `os`

foo/bar.py:3:1: F404 `from __future__` imports must occur at the beginning of the file
  |
1 | import os
2 |
3 | from __future__ import annotations
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404
  |

Found 2 errors.
[*] 1 fixable with the `--fix` option.

When running from the directory foo, the same command respects fix-only from foo/pyproject.toml.

$ ruff check .
Fixed 1 error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationRelated to settings and configurationneeds-decisionAwaiting a decision from a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions