astral-sh / ruff

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

Mismatched diagnostics with and without cache with hierarchical configs #12264

Closed dhruvmanila closed 1 month ago

dhruvmanila commented 1 month ago

Consider the following project structure:

.
├── baz
│   ├── egg
│   │   └── t3.py
│   ├── pyproject.toml
│   └── t2.py
├── pyproject.toml
└── t1.py

Zipped folder: foo.zip

All Python files contain the same code which raises undefined-name:

print(name)

And both pyproject.toml file contain:

[tool.ruff.lint]
ignore = ["F821"]

Steps:

  1. Make sure there's no cache: ruff clean
  2. Run a fresh ruff check . which should give no diagnostics because they're currently ignored
  3. Comment the ignore line in nested config: baz/pyproject.toml
  4. Run ruff check . and you'll see a single diagnostic for baz/egg/t3.py
  5. Run ruff check --no-cache . and you'll see two diagnostics for baz/t2.py and baz/egg/t3.py
MichaReiser commented 1 month ago

Huh, that's confusing

dhruvmanila commented 1 month ago

Huh, that's confusing

What's confusing? Is it the issue description or the issue itself? I can make it clear if it's the former :)

MichaReiser commented 1 month ago

Haha no, the description is clear. It's unclear to me how / why the cache gets into an invalid state.

MichaReiser commented 1 month ago

Hmm, I'm unable to reproduce this. Changes to the pyproject.toml are correctly reflected when running ruff check in the foo directory