Can I tell pants fmt to ignore a directory? I have...
# general
p
Can I tell pants fmt to ignore a directory? I have some code generation with pants that i don't want to have black run against
That ignores it completely.
p
I don't think that is it. I generate some code and treat it as a pants source root
f
For just
fmt
, use
skip_black=True
p
Can I do that for a source root?
I have • A/ • B/ • C/ I want black to ignore C
f
You can set
__defaults__
in that source root to set
skip_black
on everything below the source root.
p
ooo thanks =D
p
Hmm.. this doesn't seem to be working?
Copy code
__defaults__(all=dict(skip_black=True, skip_isort=True, skip_pylint=True))
black still affects the source under the BUILD file that is placed in šŸ¤”
h
Are you setting that at the source root level?
l
Gee, as an example (sorry I am having black ignore B rather than C):
Copy code
.
ā”œā”€ā”€ A
│   ā”œā”€ā”€ BUILD
│   └── moda.py
ā”œā”€ā”€ B
│   ā”œā”€ā”€ BUILD
│   ā”œā”€ā”€ modb.py
│   └── subpkg
│       ā”œā”€ā”€ BUILD
│       └── bb.py
└── pants.toml
with A/BUILD:
Copy code
python_sources()
B/BUILD:
Copy code
__defaults__(all=dict(skip_black=True))
python_sources()
B/subpkg/BUILD:
Copy code
python_sources()
and pants.toml
Copy code
[GLOBAL]
pants_version = "2.16.0"

backend_packages = [
    "pants.backend.python",
    "pants.backend.python.lint.black",
]
and all the
*.py
being poorly formatted. With this setup,
pants fmt ::
only tries to fix
moda.py
. If you remove the
__default__
line, it will fix all of them.
ā¤ļø 1