-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
Merge validate
goal with lint
goal
#14102
Merge validate
goal with lint
goal
#14102
Conversation
…on].detail_level` (#14103) Prework for #14102. The `GoalSubsystem` will be going away so the option should live on the relevant subsystem instead. I'm not sure if `sourcefile-validation` is the best options scope for #14102, but I'm not sure what else we would call it. [ci skip-rust] [ci skip-build-wheels]
b7ed49e
to
edfd648
Compare
edfd648
to
206c91b
Compare
…k`, and `test` (#14303) Before: ``` ❯ ./pants --black-skip fmt src/python/pants/util/strutil.py 07:22:21.51 [INFO] Completed: Format with Autoflake - autoflake made no changes. 07:22:22.52 [INFO] Completed: Format with docformatter - Docformatter made no changes. 07:22:22.54 [INFO] Completed: Format with isort - isort made no changes. - Black skipped. ✓ Docformatter made no changes. ✓ autoflake made no changes. ✓ isort made no changes. ``` After: ``` ❯ ./pants --black-skip fmt src/python/pants/util/strutil.py 07:22:01.24 [INFO] Completed: Format with Autoflake - autoflake made no changes. 07:22:01.41 [INFO] Completed: Format with docformatter - Docformatter made no changes. 07:22:01.70 [INFO] Completed: Format with isort - isort made no changes. ✓ Docformatter made no changes. ✓ autoflake made no changes. ✓ isort made no changes. ``` As we've added more tools, rendering skipping is somewhat noisy. More importantly, it causes a problem when tools want to disable themselves via some complex logic that requires the Rules API. For example, with Go, we don't know if a `go_package` has tests in it or not until compiling the code and running our analyzer: https://github.com/pantsbuild/pants/blob/0488605f54ef3602797d68a5c4797dea9d706b14/src/python/pants/backend/go/goals/test.py#L192-L193 With the upcoming `regex-lint` (formerly `validate`), we want to only enable the linter if `[regex-lint].config` is set up: #14102. In both these cases, it is annoying & noisy to render the skipped tools in the summary. I wasn't anticipating these use cases when designing this summary in 2020: #9710. We will still log that the tool is skipped at `-ldebug`, which helps if users are confused why something isn't showing up. [ci skip-rust] [ci skip-build-wheels]
206c91b
to
588a05a
Compare
validate
goal with lint
goalvalidate
goal with lint
goal
[ci skip-rust] [ci skip-build-wheels]
588a05a
to
796094c
Compare
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.
Thanks! Even with the gotchas, I think that this is a step in the right direction, as it will let us incrementally improve.
"The `regex-lint` check run by the `validate` goal is now run as part of the " | ||
"`lint` goal. So long as you have set up `[regex-lint].config` " | ||
"(or the deprecated `[sourcefile-validation].config`), this checker will run.\n\n" | ||
"Note that if you were running `validate '**'` in order to check files without " | ||
"owning targets (e.g. to check BUILD file contents), then you will need to run " | ||
"`lint '**'` rather than `lint ::`. Also, `--changed-since=<sha>` will not cause " | ||
"`regex-lint` to run, same as it how `validate` worked. We are exploring how to remove " | ||
"both these gotchas." |
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.
Is it worth referring to a ticket in the help as part of the explanation of the gotchas? Improving the --changed
behavior is possibly related to #13757 (i.e., the need to refactor Specs
calculation to move it into a single call to the engine).
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.
I think the most relevant thing is my design doc from November. Should I reference that? Fwit, that remains one of the most pressing projects I personally want to work on.
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.
I think it's fine as is. We've always had these gotchas since adding validate
in 2020.
@@ -199,43 +212,63 @@ async def lint( | |||
console: Console, | |||
workspace: Workspace, | |||
targets: Targets, | |||
specs_snapshot: SpecsSnapshot, | |||
lint_subsystem: LintSubsystem, |
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.
Commenting in the wrong place, but: is it possible to update required_union_implementations
for this case? Seems like it would need both AND and OR perhaps.
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.
This has been a problem for generate-lockfiles
, too. We want to OR whereas it's implemented as AND.
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.
Thanks! Even with the gotchas, I think that this is a step in the right direction, as it will let us incrementally improve.
b7e7b5f
to
ba4244d
Compare
…-merge [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
#14102 added `LintFilesRequest`, so now `LintRequest` is poorly named. I don't yet rename `FmtRequest` to `FmtTargetsRequest` because that API is still in flux until we figure out how to safely have target-less formatters. No need to rename `CheckRequest` because we need dependencies information there, so we will need targets (possibly inferred). [ci skip-rust] [ci skip-build-wheels]
This adds generic support for
lint
implementations that do not deal with targets. That allows us to mergevalidate
intolint
, which is much cleaner.CLI specs
As before with the
validate
goal, it's not very intuitive how to get Pants to run on files not owned by targets, which you want forvalidate
.::
only matches files owned by targets, whereas**
matches all files regardless of targets.So, users of
regex-lint
should typically use./pants lint '**'
rather than./pants lint ::
, which is not intuitivehttps://docs.google.com/document/d/1WWQM-X6kHoSCKwItqf61NiKFWNSlpnTC5QNu3ul9RDk/edit#heading=h.1h4j0d5mazhu proposes changing
::
to match all files, so you can simply use./pants lint ::
. I don't think we need to block on this proposal? This is still forward progress, and alsovalidate
/regex-lint
is not used very much fwict.Batching
We don't yet batch per #14186, although it would be trivial for us to hook up. I'm only waiting to do it till we can better reason about if it makes sense to apply here too.
The
fmt
goalNote that we need more design for
fmt
before we can apply this same change there. fmt is tricky because we run each formatter for a certain language sequentially so that they don't overwrite each other; but we run distinct languages in parallel. We would need some way to know which "language" target-less files are for."Inferred targets"
A related technology would be inferred targets, where you don't need a BUILD flie but we still have a target: #14074.
This is a complementary technology. The main difference here is that we can operate on files that will never have an owning target, such as a BUILD file itself.
[ci skip-rust]
[ci skip-build-wheels]