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
Support V2 linters running on Python 2 and Python 3 targets at the same time #9870
Support V2 linters running on Python 2 and Python 3 targets at the same time #9870
Conversation
[ci skip-rust-tests] [ci skip-jvm-tests]
…n one run [ci skip-rust-tests] [ci skip-jvm-tests]
# Delete this line to force CI to run Clippy and the Rust tests. [ci skip-rust-tests] # Delete this line to force CI to run the JVM tests. [ci skip-jvm-tests]
# Delete this line to force CI to run Clippy and the Rust tests. [ci skip-rust-tests] # Delete this line to force CI to run the JVM tests. [ci skip-jvm-tests]
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.
Apologies that this is large. I recommend going commit-by-commit.
# Delete this line to force CI to run Clippy and the Rust tests. [ci skip-rust-tests] # Delete this line to force CI to run the JVM tests. [ci skip-jvm-tests]
Is this actually the case for the usecases we recommend? ie, EDIT: And also whether it continues to be the case as we further optimize process execution via |
Likely, some cases are faster with But, overall, we decided to default to For that first-time user, we want We can replace the warning in https://pants.readme.io/v1.28/docs/python-lint-goal with a new green "Benefits of Pants" box about how you can run your linters on incompatible targets. |
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.
Change looks reasonable: thanks.
As discussed, I think that we should reconsider this default though. We would never recommend that someone should run ./pants lint ::
, but if they did run it, more egregious than the first run taking a long time would be none of the subsequent runs doing any caching at all due to all of the files having been batched. People should rely on our caching behavior, and it's easily broken with batching. Even in the case of --changed-parent=master
, folks are going to end up running these tools multiple times: those additional runs should mostly hit local caches.
I still think the solution to the caching issue is to cache successes (and only successes) on per-file basis, after running in a single batch. Ideally there would be an intrinsic to poke data into the CAS without running a process (although we could start out by just caching the result of |
This should be straightforward because we're not caching any data that need to be split out, we're just caching the fact "this file passed lint". |
Problem
When using the default
--no-per-target-caching
,./v2 lint ::
will fail if you have any targets with conflicting Python interpreter constraints, e.g. Python 2-only targets mixed with Python 3-only targets. This is a common problem due to Python 3 migrations.It is not acceptable to say "just use
--per-target-caching
" because we want./pants lint ::
to work regardless of this setting.Solution
The main change is for linter rules to now return
LintResults
, rather than a singleLintResult
. Typically, this will only have one element, but it can include more, such as partitioning by interpreter constraints. In JVM land, we might partition by JVM compatibility, for example.Then, Pylint, Bandit, and Flake8 are rewritten to have new rules that take a
Partition
of the original input targets and return a singleLintResult
. Another rule does the partitioning and aggregates these results.Result
./v2 lint ::
works on any Python codebase, regardless of interpreter constraints.