astral-sh / astral-sh/ruff

ruff check src/ --fix fails to discover some nested files but works when ran directly on that file

Open
#9,504 4 comments 0 reactions 1 assignee Claimed by @charliermarsh View on GitHub
bug isort
Dominant language
Rust
Stars
49.6k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
445

Description

```console
$ ruff --version
ruff 0.1.13
```

1. clone [`nerfstudio`](https://github.com/nerfstudio-project/nerfstudio).
2. Use this `ruff` config:
```toml
[tool.ruff]
line-length = 120
select = [
"E", # pycodestyle errors.
"F", # Pyflakes rules.
"I", # isort formatting.
"PLC", # Pylint convention warnings.
"PLE", # Pylint errors.
"PLR", # Pylint refactor recommendations.
"PLW", # Pylint warnings.
]
ignore = [
"E501", # Line too long.
"F722", # Forward annotation false positive from jaxtyping. Should be caught by pyright.
"F821", # Forward annotation false positive from jaxtyping. Should be caught by pyright.
"PLR2004", # Magic value used in comparison.
"PLR0915", # Too many statements.
"PLR0913", # Too many arguments.
"PLC0414", # Import alias does not rename variable. (this is used for exporting names)
"PLC1901", # Use falsey strings.
"PLR5501", # Use `elif` instead of `else if`.
"PLR0911", # Too many return statements.
"PLR0912", # Too many branches.
"PLW0603", # Globa statement updates are discouraged.
"PLW2901", # For loop variable overwritten.
]

[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = ["nerfstudio"]
split-on-trailing-comma = false
```
3. Apply `ruff` import formatting
```console
$ ruff check nerfstudio/ docs/ tests/ --fix
```
4. Use this `isort` config:
```toml
[tool.isort]
combine_as_imports = true
line_length = 120
known_first_party = ["nerfstudio"]
profile = "black"
```
5. `isort` discovers a missed fix
```console
$ isort nerfstudio/ docs/ tests/
Fixing /Users/ringo/Repositories/nerfstudio/nerfstudio/scripts/downloads/download_data.py
```
6. Strangely enough:
```console
$ ruff check nerfstudio/scripts --fix
Found 1 error (1 fixed, 0 remaining).
```
or
```console
$ ruff check nerfstudio/scripts/downloads/download_data.py --fix
Found 1 error (1 fixed, 0 remaining).
```

And also, `ruff` succeeds at finding and fixing other scripts in this folder.

```console
$ tree nerfstudio/scripts/
nerfstudio/scripts/
├── __init__.py
├── completions
│ ├── __init__.py
│ ├── install.py
├── downloads
│ ├── __init__.py
│ └── download_data.py // <- only one that is missed?
├── process_data.py
├── render.py
└── viewer
├── __init__.py
└── run_viewer.py
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.