Summary
Given:
.
├── projects
│ └── brown-lentil
│ ├── brown_lentil
│ │ └── subdir
│ │ └── soup.py
│ └── pyproject.toml
└── ruff.toml
where pyproject.toml is empty and ruff.toml just has [lint]\nselect = ["I"]
and where soup.py imports typing, pytest, and brown_lentil, ruff check --fix projects/brown-lentil/brown_lentil/subdir/soup.py will result in:
import typing # TODO: Does EVERY module need to import this??
import brown_lentil
import pytest # Always good to test your soup first
I think what's happening here is that:
- Ruff is using the directory containing the
ruff.toml as the "project root"
- If I put a
ruff.toml next to my pyproject.toml there, then it formats correctly
- The missing
__init__.py in brown_lentil is bypassing Ruff's "same-package" check
- IDK if this is a bug or a feature, but maybe should be documented. I'll make a separate PR
Ideally, the existence of a pyproject.toml (even one not containing [tool.ruff]) would mark this as a project root (it is called a "py project" file after all 😉)
Version
ruff 0.15.2
Summary
Given:
where
pyproject.tomlis empty andruff.tomljust has[lint]\nselect = ["I"]and where
soup.pyimportstyping,pytest, andbrown_lentil,ruff check --fix projects/brown-lentil/brown_lentil/subdir/soup.pywill result in:I think what's happening here is that:
ruff.tomlas the "project root"ruff.tomlnext to mypyproject.tomlthere, then it formats correctly__init__.pyinbrown_lentilis bypassing Ruff's "same-package" checkIdeally, the existence of a
pyproject.toml(even one not containing[tool.ruff]) would mark this as a project root (it is called a "py project" file after all 😉)Version
ruff 0.15.2