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

adorable-engine-71736

10/26/2021, 3:01 PM
Hi, i noticed there was a conversation recently about opting out of black - can anyone point me to the docs for doing that ?
c

curved-television-6568

10/26/2021, 3:03 PM
a

adorable-engine-71736

10/26/2021, 3:04 PM
ah, i meant for BUILD files
c

curved-television-6568

10/26/2021, 3:05 PM
There’s also
Copy code
$ ./pants help black

`black` subsystem options
-------------------------

The Black Python code formatter (<https://black.readthedocs.io/>).
 
Config section: [black]
 
  --[no-]black-skip
  PANTS_BLACK_SKIP
  skip
      default: False
      current value: False
      Don't use Black when running `./pants fmt` and `./pants lint`
and
Copy code
$ ./pants help python_library

python_library
--------------

Python source code.
[...]

skip_black
    type: bool
    default: False
    If true, don't run Black on this target's code.

...
ah, i meant for BUILD files
Ah, right..
a

adorable-engine-71736

10/26/2021, 3:05 PM
but, thanks anway, i want to opt out everywhere !
h

hundreds-father-404

10/26/2021, 3:06 PM
The update-build-files goal still needs to be documented. Run ./pants help update-build-files
a

adorable-engine-71736

10/26/2021, 3:06 PM
thanks...
h

hundreds-father-404

10/26/2021, 3:07 PM
For your own code, black should be opted out of unless you add the backend to pants.toml. It's only BUILD files where you have to opt out
a

adorable-engine-71736

10/26/2021, 3:07 PM
yep, i see, it hasnt run on anything apart from build files so far
c

curved-television-6568

10/26/2021, 3:08 PM
Eric beat me to it…
Copy code
$ ./pants help update-build-files
[...]
  --[no-]update-build-files-fmt
  PANTS_UPDATE_BUILD_FILES_FMT
  fmt
      default: True
      current value: True
      Format BUILD files using Black.
      
      Set `[black].args`, `[black].config`, and `[black].config_discovery` to change Black's behavior. Set `[black].interpreter_constraints` and
      `[python].interpreter_search_path` to change which interpreter is used to run Black.
a

adorable-engine-71736

10/26/2021, 3:10 PM
so after reading this i added...
Copy code
[update-build-files]
fmt = False
but i still see it running black - am i misreading something ?
h

hundreds-father-404

10/26/2021, 3:15 PM
Hm you are..? Seeing it run on build files or your own code?
a

adorable-engine-71736

10/26/2021, 3:18 PM
added above, then reran
pants update-build-files
and saw lines like...
Copy code
Updated envoy.distribution.repo/BUILD:
  - Format with Black
actually, nm
i did a
git checkout
in between and caned my toml file change - apologies for noise
h

hundreds-father-404

10/26/2021, 3:30 PM
Cool, glad it's working. Also feel free to share feedback on that goal! It's new to 2.8. Hoping to add more deprecation fixers in the future
2 Views