Skip to content

Commit

Permalink
Deprecate the @rule_helper decorator. (pantsbuild#18330)
Browse files Browse the repository at this point in the history
Following pantsbuild#17947 the `rule_helper` decorator is no longer needed.
  • Loading branch information
kaos authored Feb 23, 2023
1 parent 8935264 commit 5f3f251
Show file tree
Hide file tree
Showing 55 changed files with 80 additions and 148 deletions.
5 changes: 1 addition & 4 deletions src/python/pants/backend/cc/util_rules/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pants.engine.internals.native_engine import EMPTY_DIGEST, Digest
from pants.engine.platform import Platform
from pants.engine.process import Process
from pants.engine.rules import Get, Rule, collect_rules, rule, rule_helper
from pants.engine.rules import Get, Rule, collect_rules, rule
from pants.engine.unions import UnionRule
from pants.util.logging import LogLevel
from pants.util.ordered_set import OrderedSet
Expand Down Expand Up @@ -69,7 +69,6 @@ def link_command(self) -> tuple[str, ...]:
return tuple(filter(None, command))


@rule_helper
async def _executable_path(binary_names: Iterable[str], search_paths: Iterable[str]) -> str:
"""Find the path to an executable by checking whether the executable supports a version
option."""
Expand All @@ -90,7 +89,6 @@ async def _executable_path(binary_names: Iterable[str], search_paths: Iterable[s
raise BinaryNotFoundError(f"Could not find any of '{binary_names}' in any of {search_paths}.")


@rule_helper
async def _setup_downloadable_toolchain(
request: CCToolchainRequest,
subsystem: ExternalCCSubsystem,
Expand Down Expand Up @@ -119,7 +117,6 @@ async def _setup_downloadable_toolchain(
)


@rule_helper
async def _setup_system_toolchain(
request: CCToolchainRequest, subsystem: CCSubsystem
) -> CCToolchain:
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/cue/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pants.engine.fs import Digest, MergeDigests, Snapshot
from pants.engine.platform import Platform
from pants.engine.process import FallibleProcessResult, Process
from pants.engine.rules import Get, rule_helper
from pants.engine.rules import Get
from pants.util.logging import LogLevel
from pants.util.strutil import pluralize

Expand All @@ -16,7 +16,6 @@ def generate_argv(*args: str, files: tuple[str, ...], cue: Cue) -> tuple[str, ..
return args + cue.args + files


@rule_helper
async def _run_cue(
*args: str, cue: Cue, snapshot: Snapshot, platform: Platform, **kwargs
) -> FallibleProcessResult:
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/go/goals/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
)
from pants.engine.internals.selectors import Get, MultiGet
from pants.engine.process import Process, ProcessResult
from pants.engine.rules import collect_rules, goal_rule, rule, rule_helper
from pants.engine.rules import collect_rules, goal_rule, rule
from pants.engine.target import Targets
from pants.option.option_types import StrListOption
from pants.option.subsystem import Subsystem
Expand Down Expand Up @@ -158,7 +158,6 @@ def _expand_env(s: str, m: Mapping[str, str]) -> str:
return buf + s[i:]


@rule_helper
async def _run_generators(
analysis: FirstPartyPkgAnalysis,
digest: Digest,
Expand Down
6 changes: 1 addition & 5 deletions src/python/pants/backend/go/goals/tailor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PutativeTargetsRequest,
)
from pants.engine.fs import DigestContents, PathGlobs, Paths
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import UnexpandedTargets
from pants.engine.unions import UnionRule
from pants.util.dirutil import group_by_dir
Expand All @@ -50,7 +50,6 @@ def has_go_mod_ancestor(dirname: str, all_go_mod_dirs: frozenset[str]) -> bool:
return any(dirname.startswith(go_mod_dir) for go_mod_dir in all_go_mod_dirs)


@rule_helper
async def _find_go_mod_targets(
all_go_mod_files: set[str], all_owned_sources: AllOwnedSources
) -> list[PutativeTarget]:
Expand All @@ -66,7 +65,6 @@ async def _find_go_mod_targets(
]


@rule_helper
async def _find_cgo_sources(
path: str, all_owned_sources: AllOwnedSources
) -> tuple[list[str], list[str]]:
Expand Down Expand Up @@ -142,7 +140,6 @@ async def find_putative_go_package_target(
)


@rule_helper
async def _find_go_package_targets(
request: PutativeGoTargetsRequest,
all_go_mod_dirs: frozenset[str],
Expand All @@ -168,7 +165,6 @@ async def _find_go_package_targets(
]


@rule_helper
async def _find_go_binary_targets(
request: PutativeGoTargetsRequest, all_go_mod_dirs: frozenset[str]
) -> list[PutativeTarget]:
Expand Down
5 changes: 1 addition & 4 deletions src/python/pants/backend/go/util_rules/build_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
PathGlobs,
)
from pants.engine.process import FallibleProcessResult, Process, ProcessResult
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.util.frozendict import FrozenDict
from pants.util.logging import LogLevel
from pants.util.resources import read_resource
Expand Down Expand Up @@ -314,7 +314,6 @@ class GoCompileActionIdResult:


# TODO(#16831): Merge this rule helper and the AssemblyPostCompilationRequest.
@rule_helper
async def _add_objects_to_archive(
input_digest: Digest,
pkg_archive_path: str,
Expand Down Expand Up @@ -421,7 +420,6 @@ async def check_for_golang_assembly(
#
# See https://github.com/golang/go/blob/1c05968c9a5d6432fc6f30196528f8f37287dd3d/src/cmd/go/internal/work/exec.go#L867-L892
# for particulars.
@rule_helper
async def _maybe_copy_headers_to_platform_independent_names(
input_digest: Digest,
dir_path: str,
Expand Down Expand Up @@ -467,7 +465,6 @@ async def _maybe_copy_headers_to_platform_independent_names(

# Gather transitive prebuilt object files for Cgo. Traverse the provided dependencies and lifts `.syso`
# object files into a single `Digest`.
@rule_helper
async def _gather_transitive_prebuilt_object_files(
build_request: BuildGoPackageRequest,
) -> tuple[Digest, frozenset[str]]:
Expand Down
6 changes: 1 addition & 5 deletions src/python/pants/backend/go/util_rules/cgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from pants.engine.internals.native_engine import EMPTY_DIGEST, Digest, MergeDigests
from pants.engine.internals.selectors import Get, MultiGet
from pants.engine.process import FallibleProcessResult, Process, ProcessResult
from pants.engine.rules import collect_rules, rule, rule_helper
from pants.engine.rules import collect_rules, rule
from pants.util.logging import LogLevel

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -326,7 +326,6 @@ async def make_cgo_compile_wrapper_script(
return CGoCompilerWrapperScript(digest=digest)


@rule_helper
async def _cc(
binary_name: str,
input_digest: Digest,
Expand Down Expand Up @@ -375,7 +374,6 @@ async def _cc(
)


@rule_helper
async def _gccld(
binary_name: str,
input_digest: Digest,
Expand Down Expand Up @@ -451,7 +449,6 @@ class _DynImportResult:
# see https://github.com/golang/go/blob/f28fa952b5f81a63afd96c9c58dceb99cc7d1dbf/src/cmd/go/internal/work/exec.go#L3020
#
# Note: Commented-out Go code remains in this function because it was not clear yet how to adapt that code.
@rule_helper
async def _dynimport(
import_path: str,
input_digest: Digest,
Expand Down Expand Up @@ -640,7 +637,6 @@ def _check_link_args_in_content(src: bytes):
check_linker_flags(flags, "go:cgo_ldflag")


@rule_helper
async def _ensure_only_allowed_link_args(
digest: Digest, dir_path: str, go_files: Iterable[str]
) -> None:
Expand Down
4 changes: 1 addition & 3 deletions src/python/pants/backend/go/util_rules/go_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pants.core.util_rules.environments import EnvironmentTarget, LocalEnvironmentTarget
from pants.engine.env_vars import EnvironmentVars, EnvironmentVarsRequest
from pants.engine.internals.selectors import Get
from pants.engine.rules import collect_rules, rule, rule_helper
from pants.engine.rules import collect_rules, rule
from pants.util.strutil import softwrap

logger = logging.getLogger(__name__)
Expand All @@ -24,7 +24,6 @@ class GoBootstrap:
go_search_paths: tuple[str, ...]


@rule_helper
async def _go_search_paths(
env_tgt: EnvironmentTarget, golang_subsystem: GolangSubsystem, paths: Iterable[str]
) -> tuple[str, ...]:
Expand Down Expand Up @@ -68,7 +67,6 @@ async def _go_search_paths(
return tuple(expanded)


@rule_helper
async def _environment_paths() -> list[str]:
"""Returns a list of paths specified by the PATH env var."""
env = await Get(EnvironmentVars, EnvironmentVarsRequest(("PATH",)))
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/go/util_rules/go_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pants.engine.engine_aware import EngineAwareParameter
from pants.engine.fs import Digest
from pants.engine.process import ProcessResult
from pants.engine.rules import Get, collect_rules, rule, rule_helper
from pants.engine.rules import Get, collect_rules, rule
from pants.engine.target import (
AllUnexpandedTargets,
HydratedSources,
Expand Down Expand Up @@ -106,7 +106,6 @@ async def find_nearest_ancestor_go_mod(
return NearestAncestorGoModResult(go_mod_targets[0].address)


@rule_helper
async def _find_explict_owning_go_mod_address(
address: Address,
field: GoOwningGoModAddressField,
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/go/util_rules/third_party_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Snapshot,
)
from pants.engine.process import FallibleProcessResult, Process, ProcessResult
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.util.dirutil import group_by_dir
from pants.util.frozendict import FrozenDict
from pants.util.logging import LogLevel
Expand Down Expand Up @@ -285,7 +285,6 @@ def _freeze_json_dict(d: dict[Any, Any]) -> FrozenDict[str, Any]:
return FrozenDict(result)


@rule_helper
async def _check_go_sum_has_not_changed(
input_digest: Digest,
output_digest: Digest,
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/helm/subsystems/post_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from pants.engine.fs import CreateDigest, Digest, FileContent
from pants.engine.internals.native_engine import MergeDigests
from pants.engine.process import Process
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import FieldSetsPerTarget, FieldSetsPerTargetRequest, Targets
from pants.engine.unions import UnionRule
from pants.util.docutil import git_url
Expand Down Expand Up @@ -168,7 +168,6 @@ def metadata(self) -> dict[str, Any] | None:
}


@rule_helper
async def _resolve_post_renderers(
address_inputs: UnparsedAddressInputs,
) -> Iterable[RunRequest]:
Expand Down
4 changes: 1 addition & 3 deletions src/python/pants/backend/helm/util_rules/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
PathGlobs,
Snapshot,
)
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import DependenciesRequest, ExplicitlyProvidedDependencies, Target, Targets
from pants.util.frozendict import FrozenDict
from pants.util.logging import LogLevel
Expand Down Expand Up @@ -128,7 +128,6 @@ async def create_chart_from_artifact(fetched_artifact: FetchedHelmArtifact) -> H
)


@rule_helper
async def _merge_subchart_digests(charts: Iterable[HelmChart]) -> Digest:
prefixed_chart_digests = await MultiGet(
Get(Digest, AddPrefix(chart.snapshot.digest, chart.name)) for chart in charts
Expand All @@ -137,7 +136,6 @@ async def _merge_subchart_digests(charts: Iterable[HelmChart]) -> Digest:
return await Get(Digest, AddPrefix(merged_digests, "charts"))


@rule_helper
async def _get_subcharts(
subtargets: Targets, *, description_of_origin: str
) -> tuple[HelmChart, ...]:
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/helm/util_rules/post_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from pants.backend.helm.target_types import HelmDeploymentFieldSet
from pants.engine.addresses import Address, Addresses
from pants.engine.engine_aware import EngineAwareParameter
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import Targets, WrappedTarget, WrappedTargetRequest
from pants.engine.unions import UnionMembership
from pants.util.logging import LogLevel
Expand All @@ -52,7 +52,6 @@ def metadata(self) -> dict[str, Any] | None:
return {"address": self.field_set.address.spec}


@rule_helper
async def _obtain_custom_image_tags(
address: Address, union_membership: UnionMembership
) -> DockerImageTags:
Expand Down
4 changes: 1 addition & 3 deletions src/python/pants/backend/helm/util_rules/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)
from pants.engine.internals.native_engine import FileDigest
from pants.engine.process import InteractiveProcess, Process, ProcessCacheScope, ProcessResult
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.util.logging import LogLevel
from pants.util.strutil import pluralize, softwrap
from pants.util.value_interpolation import InterpolationContext, InterpolationValue
Expand Down Expand Up @@ -184,7 +184,6 @@ def cacheable(self) -> bool:
return not self.post_processed


@rule_helper
async def _build_interpolation_context(helm_subsystem: HelmSubsystem) -> InterpolationContext:
interpolation_context: dict[str, dict[str, str] | InterpolationValue] = {}

Expand All @@ -194,7 +193,6 @@ async def _build_interpolation_context(helm_subsystem: HelmSubsystem) -> Interpo
return InterpolationContext.from_dict(interpolation_context)


@rule_helper
async def _sort_value_file_names_for_evaluation(
address: Address,
*,
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/helm/util_rules/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pants.engine.engine_aware import EngineAwareParameter
from pants.engine.fs import Digest, DigestSubset, MergeDigests, PathGlobs, Snapshot
from pants.engine.internals.native_engine import RemovePrefix
from pants.engine.rules import Get, MultiGet, collect_rules, rule, rule_helper
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import (
DependenciesRequest,
HydratedSources,
Expand Down Expand Up @@ -121,7 +121,6 @@ class HelmChartSourceFiles:
unrooted_files: tuple[str, ...]


@rule_helper
async def _strip_chart_source_root(
source_files: SourceFiles, chart_root: HelmChartRoot
) -> Snapshot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from pants.core.util_rules import stripped_source_files
from pants.engine.addresses import Address, Addresses
from pants.engine.internals.graph import Owners, OwnersRequest
from pants.engine.rules import Get, MultiGet, rule, rule_helper
from pants.engine.rules import Get, MultiGet, rule
from pants.engine.target import (
DependenciesRequest,
ExplicitlyProvidedDependencies,
Expand Down Expand Up @@ -257,7 +257,6 @@ class UnownedImportPossibleOwners:
value: list[tuple[Address, ResolveName]]


@rule_helper
async def _find_other_owners_for_unowned_imports(
req: UnownedImportsPossibleOwnersRequest,
) -> UnownedImportsPossibleOwners:
Expand Down Expand Up @@ -299,7 +298,6 @@ async def find_other_owners_for_unowned_import(
return UnownedImportPossibleOwners(other_owners)


@rule_helper
async def _handle_unowned_imports(
address: Address,
unowned_dependency_behavior: UnownedDependencyUsage,
Expand Down Expand Up @@ -357,7 +355,6 @@ async def _handle_unowned_imports(
raise UnownedDependencyError(msg)


@rule_helper
async def _exec_parse_deps(
field_set: PythonImportDependenciesInferenceFieldSet,
python_setup: PythonSetup,
Expand Down
3 changes: 1 addition & 2 deletions src/python/pants/backend/python/goals/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from pants.engine.internals.native_engine import AddPrefix, Digest, MergeDigests
from pants.engine.internals.selectors import Get, MultiGet
from pants.engine.process import ProcessResult
from pants.engine.rules import collect_rules, rule, rule_helper
from pants.engine.rules import collect_rules, rule
from pants.engine.target import Target
from pants.engine.unions import UnionMembership, UnionRule, union
from pants.option.option_types import BoolOption, EnumOption
Expand Down Expand Up @@ -123,7 +123,6 @@ class ExportPluginOptions:
)


@rule_helper
async def _get_full_python_version(pex_or_venv_pex: Pex | VenvPex) -> str:
# Get the full python version (including patch #).
is_venv_pex = isinstance(pex_or_venv_pex, VenvPex)
Expand Down
Loading

0 comments on commit 5f3f251

Please sign in to comment.