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

rapid-bird-79300

12/07/2022, 7:09 PM
Hey Pants Team, curious if there's a way to prevent options in BUILD files. Say
skip_black=True
from being set on any target. Also consider a simple plugin for this.
1
h

high-yak-85899

12/07/2022, 7:24 PM
I'm sure someone will have a better suggestion, but a macro could do the trick
If anyone sets
skip_black
, then you could raise an error
r

rapid-bird-79300

12/07/2022, 7:33 PM
Yeah a macro would definitely work. However, we used macros in the past but in time noticed it impacted our cache size and cause more frequent OOMs. So I was leaning towards a plugin or some type of post processing of peek.
c

curved-television-6568

12/07/2022, 7:35 PM
just throwing this into the mixer… as an “outside of pants” solution that could be run as part of a pre-commit hook or other lint step.. 😉
Copy code
╰─❯ ./pants peek --exclude-defaults :: | jq -r '.[]|select(.skip_mypy)|.address'
src/python/pants/backend/helm/subsystems:__k8s_parser_main
src/python/pants/backend/helm/subsystems:__post_renderer_main
src/python/pants/backend/helm/subsystems/k8s_parser_main.py:__k8s_parser_main
src/python/pants/backend/helm/subsystems/post_renderer_main.py:__post_renderer_main
Using
skip_mypy
here as skip_black was not represented. This lists all addresses that use the field at all, adjust the
jq
filter if only for a certain value.
Lists all addresses with a “truthy” value.
b

bitter-ability-32190

12/07/2022, 7:44 PM
If you're willing to monkeypatch, you could do some dirty interesting things 😂
h

high-yak-85899

12/07/2022, 7:46 PM
What's the business about caching? Do macros affect that?
h

happy-kitchen-89482

12/07/2022, 7:54 PM
I wouldn't expect a macro to affect cache size, that is weird
c

curved-television-6568

12/07/2022, 7:54 PM
I would say macros does not.. as a layer “on top” of BUILD files, it merely spits out another version of the BUILD file for you that Pants can work with….
👍 2
h

happy-kitchen-89482

12/07/2022, 7:54 PM
It may have been some specific thing the macro was doing
but in this case I think a macro makes sense
b

bitter-ability-32190

12/07/2022, 7:55 PM
My beef with Macros is nothing is compelling folks to use 'em. This kind of "thou shall not" likely belongs in something that isn't opt-in (or even opt-out)
👍 1
r

rapid-bird-79300

12/07/2022, 7:56 PM
yeah we were using macros for the migration of 2.7+ but then had to ditch them because we couldn't add an additional macros with OOM every pants run. The cache size we would need to circle back on but it was an observation before / after using them
🤔 3
😖 1
to note ended up going the plugin in route. Works fast and simple enough to maintain 👍
👍 2
3 Views