Any way for `pants` to ignore linting/formatting/c...
# general
b
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
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
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
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
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
@fast-nail-55400: thatโ€™s effectively what the
skip_$tool
args do, but natively
โž• 1
f
well they are the inversion of that, since youโ€™d have to mark all of the targets that should be opted out, right?
w
ah, got it
b
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
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
@hundreds-father-404 probably gitignore style a-la https://www.pantsbuild.org/v2.8/docs/reference-global#section-pants-ignore?
w
it is likely that we will at some point support filesystem-hierarchical target metadata
๐Ÿฅด 1
b
In layman's terms?
w
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
what that google doc refers to
w
yea, maybe. unclear whether it will be typed (
python_sources
) or untyped (
override
)
๐Ÿ‘ 1
c
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
@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
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