From 4c9a824be72e974eaf0e081d34142e4bd61e34ee Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Thu, 24 Mar 2022 14:35:15 -0400 Subject: [PATCH] Don't WARN when a spec matches no relevant targets. 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] --- src/python/pants/core/goals/package.py | 2 -- src/python/pants/core/goals/publish.py | 3 --- src/python/pants/core/goals/test.py | 1 - src/python/pants/engine/target.py | 2 +- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/python/pants/core/goals/package.py b/src/python/pants/core/goals/package.py index 8da714d9976b..6d0b0e9773c6 100644 --- a/src/python/pants/core/goals/package.py +++ b/src/python/pants/core/goals/package.py @@ -15,7 +15,6 @@ from pants.engine.target import ( AsyncFieldMixin, FieldSet, - NoApplicableTargetsBehavior, StringField, TargetRootsToFieldSets, TargetRootsToFieldSetsRequest, @@ -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: diff --git a/src/python/pants/core/goals/publish.py b/src/python/pants/core/goals/publish.py index 3ee13b2dcc12..aa6255e922c4 100644 --- a/src/python/pants/core/goals/publish.py +++ b/src/python/pants/core/goals/publish.py @@ -39,7 +39,6 @@ async def publish_example(request: PublishToMyRepoRequest, ...) -> PublishProces from pants.engine.target import ( FieldSet, ImmutableValue, - NoApplicableTargetsBehavior, TargetRootsToFieldSets, TargetRootsToFieldSetsRequest, ) @@ -191,7 +190,6 @@ 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( @@ -199,7 +197,6 @@ async def run_publish(console: Console, publish: PublishSubsystem) -> Publish: TargetRootsToFieldSetsRequest( PublishFieldSet, goal_description="the `publish` goal", - no_applicable_targets_behavior=NoApplicableTargetsBehavior.warn, ), ), ) diff --git a/src/python/pants/core/goals/test.py b/src/python/pants/core/goals/test.py index 836f89a006d2..7eee85f35e6a 100644 --- a/src/python/pants/core/goals/test.py +++ b/src/python/pants/core/goals/test.py @@ -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( diff --git a/src/python/pants/engine/target.py b/src/python/pants/engine/target.py index 3d6831371c3a..339bb86de35c 100644 --- a/src/python/pants/engine/target.py +++ b/src/python/pants/engine/target.py @@ -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