Skip to content
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

Don't WARN when a spec matches no relevant targets. #14904

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/python/pants/base/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def __bool__(self) -> bool:
class Specs:
address_specs: AddressSpecs
filesystem_specs: FilesystemSpecs
from_change_detection: bool = False

@property
def provided(self) -> bool:
Expand Down
13 changes: 12 additions & 1 deletion src/python/pants/engine/internals/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,18 @@ async def find_valid_field_sets_for_target_roots(
)
if request.no_applicable_targets_behavior == NoApplicableTargetsBehavior.error:
raise no_applicable_exception
if request.no_applicable_targets_behavior == NoApplicableTargetsBehavior.warn:
# We squelch the warning if the specs came from change detection or only from address globs,
# since in that case we interpret the user's intent as "if there are relevant matching
# targets, act on them". But we still want to warn if the specs were literal, or empty.
empty_ok = specs.from_change_detection or (
specs.address_specs.globs
and not specs.address_specs.literals
and not specs.filesystem_specs
)
if (
request.no_applicable_targets_behavior == NoApplicableTargetsBehavior.warn
and not empty_ok
):
logger.warning(str(no_applicable_exception))

result = TargetRootsToFieldSets(targets_to_applicable_field_sets)
Expand Down
6 changes: 5 additions & 1 deletion src/python/pants/init/specs_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def calculate_specs(
parameters=address_input.parameters,
)
)
return Specs(AddressSpecs(address_specs, filter_by_global_options=True), FilesystemSpecs([]))
return Specs(
AddressSpecs(address_specs, filter_by_global_options=True),
FilesystemSpecs([]),
from_change_detection=True,
)


def rules():
Expand Down