Open cognifloyd opened 1 year ago
I'm not a fan of too much special casing update-build-files
here. These kind of dependencies is all over the place, not just for this. Worth noting is that the backend is not enabled, although the rules it would provide is in use by another.. To me seeing there is a backend, that is not enabled, for formatting build files with black tells me there is something available that I'm not using.
This is seen if you inspect the rules themselves, digging out one of the update build file rules for instance, reveals it is enabled by pants.core (i.e. by default and can't be disabled)
$ pants help-advanced FixResult
`pants.core.goals.fix.FixResult` api type
-----------------------------------------
FixResult(input: 'Snapshot', output: 'Snapshot', stdout: 'str', stderr: 'str', tool_name: 'str')
activated by : pants.backend.python.lint.black, pants.backend.python.lint.isort, pants.backend.shell.lint.shfmt, pants.core
dependencies : builtins
pants.backend.python
pants.engine.fs
pants.engine.platform
pants.engine.process
dependents : pants.core
returned by 5 rules: pants.backend.build_files.fix.deprecations.renamed_fields_rules.fix
pants.backend.build_files.fix.deprecations.renamed_targets_rules.fix
pants.backend.python.lint.black.rules.black_fmt
pants.backend.python.lint.isort.rules.isort_fmt
pants.backend.shell.lint.shfmt.rules.shfmt_fmt
consumed by 1 rule : pants.core.goals.fix.convert_fix_result_to_lint_result
used in 1 rule : pants.core.goals.fix.fix_batch
$ pants pants.backend.build_files.fix.deprecations.renamed_fields_rules.fix --help-advanced
`pants.backend.build_files.fix.deprecations.renamed_fields_rules.fix` rule
--------------------------------------------------------------------------
Fix deprecated field names
Undocumented.
activated by : pants.core
returns : FixResult
takes 1 input: Batch
awaits 3 gets: Get(DigestContents, Digest, ..)
Get(FixedBUILDFile, RenameFieldsInFileRequest, ..)
Get(Snapshot, CreateDigest, ..)
Hmm. Well then the help text should not be specific to update-build-files
. I would like an indicator if a backend is enabled even if I did not explicitly enable it. If pants.core
always activates it, then that counts as enabled.
Hmm. Well then the help text should not be specific to
update-build-files
. I would like an indicator if a backend is enabled even if I did not explicitly enable it. Ifpants.core
always activates it, then that counts as enabled.
The thing is, it is not the backend that is enabled, it is only that some of the rules gets pulled in; in other words, there are some rules that gets activated by more than one backend. Most (all?) of them have a principal backend they "belong" to logically but as they may be used from any number of backend I don't think it would make sense (nor be correct) to indicate a backend as implicitly enabled whenever any of it's rules are activated. If the indicator meant "some rules from this backend is in use by another backend" that would be accurate, but I wonder how useful this information really is (i.e. how bad surprise was this for you?)
What would make more sense to me is to be able to list everything that is registered from a certain backend, for introspection.
Is your feature request related to a problem? Please describe.
./pants help backends
shows thatpants.backend.build_files.fix.deprecations
andpants.backend.build_files.fmt.black
are NOT enabled by default. That surprised me because theupdate-build-files
goal definitely uses black.Describe the solution you'd like In the
help backends
output:Let's add another character, maybe
-
, to show that a backend is conditionally enabled.The
update-build-files
goal will use a formatter backend without regard to the[GLOBAL].backend_packages
setting. By default, it usespants.backend.build_files.fmt.black
andpants.backend.build_files.fix.deprecations
.The formatter can be switched from
black
toyapf
orbuildifier
based on the[update-build-files].formatter
setting.Using
fix.deprecations
backend is controlled by the[update-build-files].fix_safe_deprecations
setting (eitherTrue
orFalse
).So, these goal-specific backends should get a
-
indicator to show that it is enabled, but only for that one special-purpose goal based on different settings.Describe alternatives you've considered Just remove the backends from the output? That would be confusing too, because the backends exist. Also, you can enable the
pants.backend.build_files.fix.deprecations
backend so that it ALSO runs during thefix
goal, not just duringupdate-build-files
.Additional context
current output
proposed output