Just curious, what is the recommended way to have ...
# general
r
Just curious, what is the recommended way to have
skip_pylint
default to
False
for a project needing incremental adoption? I'd like to avoid having to create custom plugin overriding the skip default. I thought maybe macros can help but it seems a bit complicated for what we're trying to achieve.
h
The closest would be https://github.com/pantsbuild/pants/issues/12913, which I would love to see happen. I don't think it'd be very hard to implement, the main issue is figuring out the design. Then implementation is mostly mechanical Thoughts very much welcomed on the ticket for what you think the design should look like. For example, I suspect it would be a mapping of target type to field to values?
Copy code
[tailor.defaults]
python_source = { skip_pylint = True }
python_sources = { skip_pylint = True }
r
awesome! Just to note we're on
2.7.0
(hoping to upgrade soon) what would the best way to move forward. In the past, we have just made our custom plugins and override the skip flag but curious if there's something else we can do.
For example, I suspect it would be a mapping of target type to field to values?
I like that syntax a lot! One common thing that comes up in a large monolith project is some addresses would like to opt-in by default and other addresses would like to remain opt-out. For example:
Copy code
proj
  mod_x -> We want opt in!
  mod_y -> We want opt out!
how would we define that behavior in pants without having to do the manual work of setting
skip_pylint = False
in the module that wants opt-in?
h
what would the best way to move forward.
The most helpful to the Pants community would be if you're able to contribute #12913, then we could probably cherry-pick into 2.10 as a low-risk new feature. Otherwise, I think probably implementing a custom
tailor
implementation would be the fastest way to do this. On 2.7, you would basically copy and paste this code: https://github.com/pantsbuild/pants/blob/83d147d511369f85b8fa6e9345e10cd36a2729a4/src/python/pants/backend/python/goals/tailor.py#L79-L98, but change
kwargs
to include
skip_pylint=True
. Although it looks like we don't have an option to turn off the built-in
tailor
implementation....so hm. Maybe not. Would this be one-time or recurring?
I like that syntax a lot! One common thing that comes up in a large monolith project is some addresses would like to opt-in by default and other addresses would like to remain opt-out.
One limitation to be aware of is that this limitation doesn't let you set per-directory defaults. It's only per-repo defaults, based on each target. It sounds like you might want more complex?
r
Absolutely that would be a very useful feature to have in pants. Would be cool if we could write custom tailor logic too (I assume we can just create our own plugin for that now and use it over
tailor
). So we moved forward with a custom plugin for
pylint
and that works well.
Would this be one-time or recurring?
This is 4th time we're overriding default logic so we can adjust the skip field default. We also have custom
black
,
isort
,
flake8
plugins for the same work around.
It's only per-repo defaults, based on each target. It sounds like you might want more complex?
Yeah more ways to toggle how tailor operates could be helpful for incremental adoption. Maybe some type of regex pattern for addresses or it could also support syntax like:
Copy code
[tailor.SrcRoot1]
python_source = { skip_pylint = True }
python_sources = { skip_pylint = True }

[tailor.SrcRoot2]
python_source = { skip_pylint = False }
python_sources = { skip_pylint = False }
but perhaps the complexity we're looking for we can achieve with a custom plugin we can maintain ourselves.
👍 1
h
Yeah so to clarify, to change the default globally, Pants has to have a dedicated option that lets you set the global default, like this: https://www.pantsbuild.org/v2.10/docs/reference-pex-binary-defaults. Those don't exist atm for the
skip_x
tools. Otherwise, you have to explicitly set the value. And what we're talking about thus far is either using
tailor
or a macro to facilitate setting that value The final angle we could take is https://github.com/pantsbuild/pants/issues/13767, to make it less painful to explicitly set metadata for multiple directories