https://pantsbuild.org/ logo
b

bitter-ability-32190

11/10/2021, 5:21 PM
Any way for
pants
to ignore linting/formatting/checking an entire directory tree? Our current build doesn't try and lint/fmt/check any directory trees that aren't XYZ, and for migration I'd like to keep this behavior. Hopefully adding a handful of
skip_ABC
in each
BUILD
isn't the way ๐Ÿ˜ฌ
Still want to do other things like
run
and
test
though!
h

hundreds-father-404

11/10/2021, 5:24 PM
The way to do that is
skip_tool
field What's the hesitation? Definitely curious how that can be improved. Some ideas that have been thrown out: 1: Make it easier to programmatically update BUILD files 2. Add an
overrides
inheritance mechanism https://docs.google.com/document/d/1bcQRJazx6ODKc0PZRUgPx_bqHc6XurpBawTMD2zhtAk/edit
b

busy-vase-39202

11/10/2021, 5:27 PM
This passage isn't included in the the incremental adoption page, so is easy to miss initially, but-- https://www.pantsbuild.org/docs/python-linters-and-formatters#skipping-a-formatter-or-linter
f

fast-nail-55400

11/10/2021, 5:27 PM
during migration, maybe just add tags to the targets to which lint/fmt/check should apply and then just filter to those tags using
--tag
?
๐Ÿ’ก 1
b

bitter-ability-32190

11/10/2021, 5:28 PM
Stop-gap might be telling those tools to ignore the files, but that does mean we're still running the tools on those files
What's the hesitation?
There's a lot of files/dirs in the not-linted locations ๐Ÿ˜ฌ But also there's a lot in the linted-locations. So opt-out or opt-in at the
BUILD
level is certainly doable, and one-time-cost but oof.
w

witty-crayon-22786

11/10/2021, 5:32 PM
@fast-nail-55400: thatโ€™s effectively what the
skip_$tool
args do, but natively
โž• 1
f

fast-nail-55400

11/10/2021, 5:33 PM
well they are the inversion of that, since youโ€™d have to mark all of the targets that should be opted out, right?
w

witty-crayon-22786

11/10/2021, 5:33 PM
ah, got it
b

bitter-ability-32190

11/10/2021, 5:34 PM
Definitely curious how that can be improved.
Pants has a config ignore.. maybe that can be extended per-tool?
[pylint].ignore=...
etc...
If y'all are down, that's an easy enough Feature Request to make and to add ๐Ÿ‘€
(might be just as much time as scrubbing my
BUILD
files to add the skip flags ๐Ÿ˜‚ )
h

hundreds-father-404

11/10/2021, 5:37 PM
Oh that's an interesting idea! Ignore by path, target, both? (Target is slightly weird because you should arguably put the metadata near where it lives)
b

bitter-ability-32190

11/10/2021, 5:38 PM
@hundreds-father-404 probably gitignore style a-la https://www.pantsbuild.org/v2.8/docs/reference-global#section-pants-ignore?
w

witty-crayon-22786

11/10/2021, 5:39 PM
it is likely that we will at some point support filesystem-hierarchical target metadata
๐Ÿฅด 1
b

bitter-ability-32190

11/10/2021, 5:40 PM
In layman's terms?
w

witty-crayon-22786

11/10/2021, 5:41 PM
a way to define target fields in a parent directory, and have it apply to children
๐Ÿ™Œ 1
with metadata in child directories overriding parents
h

hundreds-father-404

11/10/2021, 5:41 PM
what that google doc refers to
w

witty-crayon-22786

11/10/2021, 5:42 PM
yea, maybe. unclear whether it will be typed (
python_sources
) or untyped (
override
)
๐Ÿ‘ 1
c

clean-city-64472

11/10/2021, 5:45 PM
We are doing this with mypy using its
ignore_error
setting combined with ability to have config sections per module
[mypy-my.module.*]
. I wonder if the other tools that are implicated have similar settings that make it easier to ignore entire directory trees.
b

bitter-ability-32190

11/10/2021, 5:47 PM
@clean-city-64472 All do, but I've found: โ€ข Some don't respect the skip/ignore if the file is explicitly provided (
isort
does this. It's like "you told me to ignore this dir but are explicitly asking me to sort this file, so I'll sort it) โ€ข Pants will still be doing the work of invoking the tool IIUC, which is less-than-ideal
๐Ÿ‘ 2
h

hundreds-father-404

11/10/2021, 5:48 PM
And some tools like docformatter do not have the option. We want with Pants to provide a consistent interface (where reasonable) for all your different tools, regardless of language etc
๐Ÿ™Œ 1
5 Views