Skip to content

Commit

Permalink
Don't WARN when a spec matches no relevant targets.
Browse files Browse the repository at this point in the history
This warning has its uses (e.g., if you accidentally ran on the wrong target),
but on balance, with hindsight, it seems more distracting and confusing than useful.

This is especially true with glob specs: "Run all the tests under foo/::" can
be satisfied vacuously if there are no tests under foo/::, so it's weird to
issue a warning.

In such cases we should adhere to the principle that "the empty set is not a
special case", and just let things hold vacuously.

Of course we can still ERROR when a goal absolutely needs a target in order
to make any sense at all.

[ci skip-rust]

[ci skip-build-wheels]
  • Loading branch information
benjyw committed Mar 24, 2022
1 parent dc59219 commit 4c9a824
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 7 deletions.
2 changes: 0 additions & 2 deletions src/python/pants/core/goals/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from pants.engine.target import (
AsyncFieldMixin,
FieldSet,
NoApplicableTargetsBehavior,
StringField,
TargetRootsToFieldSets,
TargetRootsToFieldSetsRequest,
Expand Down Expand Up @@ -96,7 +95,6 @@ async def package_asset(workspace: Workspace, dist_dir: DistDir) -> Package:
TargetRootsToFieldSetsRequest(
PackageFieldSet,
goal_description="the `package` goal",
no_applicable_targets_behavior=NoApplicableTargetsBehavior.warn,
),
)
if not target_roots_to_field_sets.field_sets:
Expand Down
3 changes: 0 additions & 3 deletions src/python/pants/core/goals/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ async def publish_example(request: PublishToMyRepoRequest, ...) -> PublishProces
from pants.engine.target import (
FieldSet,
ImmutableValue,
NoApplicableTargetsBehavior,
TargetRootsToFieldSets,
TargetRootsToFieldSetsRequest,
)
Expand Down Expand Up @@ -191,15 +190,13 @@ async def run_publish(console: Console, publish: PublishSubsystem) -> Publish:
PackageFieldSet,
goal_description="",
# Don't warn/error here because it's already covered by `PublishFieldSet`.
no_applicable_targets_behavior=NoApplicableTargetsBehavior.ignore,
),
),
Get(
TargetRootsToFieldSets,
TargetRootsToFieldSetsRequest(
PublishFieldSet,
goal_description="the `publish` goal",
no_applicable_targets_behavior=NoApplicableTargetsBehavior.warn,
),
),
)
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/core/goals/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ async def run_tests(
TargetRootsToFieldSetsRequest(
TestFieldSet,
goal_description=f"the `{test_subsystem.name}` goal",
no_applicable_targets_behavior=NoApplicableTargetsBehavior.warn,
),
)
results = await MultiGet(
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/engine/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ def __init__(
field_set_superclass: Type[_FS],
*,
goal_description: str,
no_applicable_targets_behavior: NoApplicableTargetsBehavior,
no_applicable_targets_behavior: NoApplicableTargetsBehavior = NoApplicableTargetsBehavior.ignore,
expect_single_field_set: bool = False,
) -> None:
self.field_set_superclass = field_set_superclass
Expand Down

0 comments on commit 4c9a824

Please sign in to comment.