-
-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Black into a plugin to enable turning it on and off via backend_plugins
#8683
Move Black into a plugin to enable turning it on and off via backend_plugins
#8683
Conversation
Just a note, but |
"internal_backend.rules_for_testing", | ||
"internal_backend.repositories", | ||
"internal_backend.sitegen", | ||
"internal_backend.utilities", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good change!
Agreed with John: re "backend packages" vs "plugins". If we could lower the overhead of plugins and just do things that way, that would be ideal. But this nonetheless feels like a step forward (especially if we think that we can preserve the package name across a transition from "backend package" to "plugin", which it sounds like we could if we dropped the |
Another set of thoughts at #8686! |
…egration tests (#8684) Traditionally, we'd write integration tests via `PantsRunIntegrationTest`, which has the cost of starting a new Pants process and is also not very isolated/hermetic. Instead, with V2 rules, we can write integration tests using `self.scheduler.product_request()`. This is preferable because it runs faster and better isolates the rule we are testing away from other parts of Pants. For example, in #8683, we are going to default to Black not being turned on as a plugin within our codebase. That causes the integration tests to fail because they are no longer able to recognize the plugin. While we could work around that via setting up the Pants config within the ITs themself, the more sound solution is to use our `self.scheduler.product_request()`-based tests, which have a similar effect of integration tests but in a more controlled and reusable way.
a000041
to
6b9c394
Compare
Agreed with this all. I think there is still much room to improve this user experience, especially with discoverability. But, this is a good foundation (much better than the An additional open question is how to approach migrating towards this approach for V1? Do we want to deprecate the current mixed approach of sometimes being auto-installed and having to disable via
|
I think [This is separate from, but related to, the question of whether any backends ship in the core Basically, I think will make sense to publish multiple backends (i.e., |
Problem
We need some mechanism to turn off autoformatters and linters in V2 other than the current
--fmt-{isort,scalafmt,etc}-skip
, which doesn't work because that uses a task-specific option system.Ideally, the option will be tool-specific, so you can say something like:
However, the solution should also be hygienic. If, for example, someone doesn't want to use Black, then we don't want Black's rules to pollute the rule graph. Nor do we want to make rule authors provide a no-op implementation.
Solution
We decided in #8346 to turn each linter into its own plugin, meaning it may be enabled via the
backend_packages
option like this:When specified, that plugin will be enabled, meaning that its options may be configured and its rules will be automatically registered against
fmt
andlint
.Result
We have a scalable and explicit mechanism for users to enable formatters and linters in a way that also makes it effortless for rule authors to have a way to opt-out of their tool.
This only implements Black. In a followup, we will implement isort under the plugin
pants.backend.python.lint.isort
.For now, V1 tasks will keep the same mechanism as before. We could move them towards this new plugin system, but save that for a followup if we choose to make the deprecations necessary to move V1 users towards the new system.