Hi All! Just getting started with pants and I have...
# general
t
Hi All! Just getting started with pants and I have a pretty basic question. I have multiple python projects in my system, and when I run
pants lint ::
or
pants fmt ::
the black/isort configs in the respective
pyproject.toml
files aren't used, (at least for the line length case), and when I run
pants lint myproject
I get the correct linting. Can anyone advise on this? I am using
marker_filenames=["pyproject.toml"]
to detect the roots
r
I don't think you can have separate config for each sub-project. You need to define a single config for whole repo for all of the linters/formatters. You can use a
pyproject.toml
for this. By default pants reads this from repo root where
pants.toml
is stored. You can see an example of this inside pants own repo The other option to set-up custom config path for each formatter and linter as mentioned in the docs
t
Which is recommended? putting a
pyproject.toml
in the root of the main dir seems to go against the purpose of the toml file since usually it would define a python project, but if that's the recommended pattern I'm happy to follow it
r
Just think if it as another config file. Otherwise you will need to define multiple config files for each tool i.e. config for black, config for isort, config for mypy etc. I think the only tool for which pyproject based config isn't supported is flake8. That's
flake8
own issue. Although there is some plugin to support pyproject.
t
will the subproject
pyproject.toml
files still be used for other things like dependencies?
r
yes
t
Ok great, so this root pyproject file would just be for linting? Just to be explicit
r
yes in this case. On a different note, you can also consolidate all of the pyproject.toml into a single one.
t
But if I did that I'd lose the dependencies right?
Or would I just use reqs files?
r
But if I did that I'd lose the dependencies right?
No you won't. Underneath pants is actually going to read all of them and basically creates a single universe of dependencies from all such dependencies. pants does support
pyproject.toml
for dependencies also.
t
Sorry I think I'm missing something. You're suggesting that I just use one
pyproject.yaml
to define dependencies included in any potential project? And then pants will build each project with the necessary dependencies for that individual project?
r
yep exactly
t
Gotcha -- that makes a lot more sense, thanks for the explanation
And with the PR that you linked -- pyproject.yamls will also be pulled to create dependencies as well correct?
r
By the way proper doc Yeah it should. Although I haven't tried it myself.