Hey Pants Team, curious if there's a way to preven...
# general
r
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
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
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
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
If you're willing to monkeypatch, you could do some dirty interesting things 😂
h
What's the business about caching? Do macros affect that?
h
I wouldn't expect a macro to affect cache size, that is weird
c
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
It may have been some specific thing the macro was doing
but in this case I think a macro makes sense
b
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
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