Closed jgarte closed 1 year ago
Good question! So if you add a pyproject.toml
file to each submodule that you want to lint (with a [tool.ruff]
section in it), Ruff will pick up the dedicated settings for each submodule, but it probably won't do quite what you want when you run ruff check .
from the top-level, because Ruff will still check the other submodules, just with Ruff's default settings rather than any submodule-specific settings.
What I might recommend is: add a ruff.toml
at the top-level of your monorepo, and explicitly set extend-exclude = ["project_to_exclude", "other_project_to_exclude"]
, etc. You could then still add per-submodule pyproject.toml
or ruff.toml
files to use different settings for different submodules, or you could put your settings in that one ruff.toml
and share them across submodules. Does that make sense? Is it feasible for your use-case?
Hi, thanks for the advice and yes, it does make sense.
or you could put your settings in that one ruff.toml and share them across submodules.
I will try putting all the settings in one ruff.toml
first and sharing them as you suggested.
I'm going to close this for bookkeeping — let us know if you have any more questions though!
Hi,
I'm working on a monorepo that follows PEP 420 Implicit Namespace Packages.
We want to introduce ruff gradually by enabling
ruff-pre-commit
on select submodules only in order to lint docstrings.In other words there are multiple independent but collaborating project submodule repositories that start from one root directory.
Would the proper way to selectively enable ruff on only select submodules be to add cascading pyproject.toml files to the submodules that I want linted as described here?
https://beta.ruff.rs/docs/configuration/#pyprojecttoml-discovery
And then ruff should pick those files up and only lint the respective submodules.
Does that sound like a good approach to take?
Any advice much appreciated.