https://pantsbuild.org/ logo
#general
Title
# general
a

abundant-analyst-12845

01/13/2023, 10:50 AM
Hi question please. I have question please, if I have an existing python project using poetry with following where i have this in my
pyproject.toml
Copy code
[tool.poetry.scripts]


[tool.black]
line-length = 120


[tool.isort]
profile = "black"
multi_line_output = 3 # Vertical Hanging Indent
line_length = 120
from_first = true
and a
tox.ini
file containing something like this
Copy code
[tox]
envlist = lint, pytest-ci, mypy, vulture
skipdist = true

[testenv:lint]
basepython = python3.9
allowlist_externals=*
list_dependencies_command=echo
commands =
    flake8 lambdas
    pylint lambdas --rcfile=.pylintrc
will pants pick up these configuration or there something I can do so it respects any of these configurations
h

happy-kitchen-89482

01/13/2023, 11:26 AM
Pants will pick up isort and black config from pyproject.toml, and also isort config from an
[isort]
section in tox.ini.
a

abundant-analyst-12845

01/13/2023, 11:26 AM
where do the tox.ini need to be located
if i have service-1 service-b do they be at the root of the project folder structure or do they need to be in each sub project (i.e. service-1), service-2
h

happy-kitchen-89482

01/13/2023, 11:28 AM
But note that it will not do anything with your
[testenv:lint]
section. That is configuration for
tox
itself, which is orthogonal to Pants
Pants uses config discovery logic that follows the config location rules of the underlying tool
So for example it'll look in the closest pyproject.toml up the filesystem that has the relevant section
for black config
same for isort, it looks like
You can also answer this question for yourself by trying it out...
1
a

abundant-analyst-12845

01/13/2023, 11:30 AM
for the
[testenv:lint]
how could I get it to run with pants?
tried it before for the tox.ini one but it blew up (probably because one of the tox.ini files was empty) at the root of the project
h

happy-kitchen-89482

01/13/2023, 11:34 AM
Those are tox commands. You need to find the equivalent Pants commands.
👀 1
For example, assuming you have set up flake8 and and pylint in pants, then
./pants lint lambas
is all you should need
a

abundant-analyst-12845

01/13/2023, 11:34 AM
that makes sense, and thanks for quick reply to my never ending questions
h

happy-kitchen-89482

01/13/2023, 11:35 AM
The pants pylint backend will automatically detect and use
.pylintrc
, again via config discovery, so you don't need to worry about specifying that
so it should just be a matter of enabling the backends for flake8 and pylint, and then
./pants lint lambdas
I assume
lambdas
is a top-level folder in your repo, yes?
a

abundant-analyst-12845

01/13/2023, 11:45 AM
yes
Copy code
root
lambdas
other-folders
6 Views