For the `pants fmt ::` goal, having enabled the `p...
# general
b
For the
pants fmt ::
goal, having enabled the
pants.backend.python.lint.black
backend, I added this to pants.toml
Copy code
[black]
args = "--line-length 100 --exclude src/path/to/excluded/file.py"
yet it is still formatted. Any thoughts?
1
c
I think pants pass the filenames explicitly to black, which will kind of trump your exclude setting. Use the
skip_black
option to not format particular sources: https://www.pantsbuild.org/docs/reference-python_sources#codeskip_blackcode See
overrides
if you have a target generator (such as
python_sources
) and want to skip a subset of files only (as well as
__defaults__
if you want to apply the same to more targets at once): https://www.pantsbuild.org/docs/targets#target-generation https://www.pantsbuild.org/docs/targets#field-default-values
e.g.
Copy code
# src/paht/to/excluded/BUILD
python_sources(
  overrides={
    "file.py": dict(skip_black=True)
  }
)
or, to skip black for all files in a subtree:
Copy code
# src/path/to/excluded/BUILD
__defaults__({(python_sources, python_source): dict(skip_black=True)})
b
Excellent. Thanks @curved-television-6568
👍 1