diff --git a/src/python/pants/backend/shell/dependency_inference.py b/src/python/pants/backend/shell/dependency_inference.py index ff01162a341..acf50a96400 100644 --- a/src/python/pants/backend/shell/dependency_inference.py +++ b/src/python/pants/backend/shell/dependency_inference.py @@ -12,7 +12,7 @@ from pants.backend.shell.lint.shellcheck.subsystem import Shellcheck from pants.backend.shell.shell_setup import ShellSetup -from pants.backend.shell.target_types import ShellSourceField +from pants.backend.shell.target_types import ShellSourcesField from pants.base.specs import AddressSpecs, DescendantAddresses from pants.core.util_rules.external_tool import DownloadedExternalTool, ExternalToolRequest from pants.engine.addresses import Address @@ -53,9 +53,9 @@ class ShellMapping: @rule(desc="Creating map of Shell file names to Shell targets", level=LogLevel.DEBUG) async def map_shell_files() -> ShellMapping: all_targets = await Get(Targets, AddressSpecs([DescendantAddresses("")])) - shell_tgts = tuple(tgt for tgt in all_targets if tgt.has_field(ShellSourceField)) + shell_tgts = tuple(tgt for tgt in all_targets if tgt.has_field(ShellSourcesField)) sources_per_target = await MultiGet( - Get(SourcesPaths, SourcesPathsRequest(tgt[ShellSourceField])) for tgt in shell_tgts + Get(SourcesPaths, SourcesPathsRequest(tgt[ShellSourcesField])) for tgt in shell_tgts ) files_to_addresses: dict[str, Address] = {} @@ -153,7 +153,7 @@ async def parse_shell_imports( class InferShellDependencies(InferDependenciesRequest): - infer_from = ShellSourceField + infer_from = ShellSourcesField @rule(desc="Inferring Shell dependencies by analyzing imports") diff --git a/src/python/pants/backend/shell/dependency_inference_test.py b/src/python/pants/backend/shell/dependency_inference_test.py index 19de2f7c6a3..72ce3ed485a 100644 --- a/src/python/pants/backend/shell/dependency_inference_test.py +++ b/src/python/pants/backend/shell/dependency_inference_test.py @@ -14,7 +14,7 @@ ParseShellImportsRequest, ShellMapping, ) -from pants.backend.shell.target_types import ShellSourceField, ShellSourcesGeneratorTarget +from pants.backend.shell.target_types import ShellSourcesField, ShellSourcesGeneratorTarget from pants.backend.shell.target_types import rules as target_types_rules from pants.core.util_rules import external_tool from pants.engine.addresses import Address @@ -131,7 +131,7 @@ def test_dependency_inference(rule_runner: RuleRunner, caplog) -> None: def run_dep_inference(address: Address) -> InferredDependencies: tgt = rule_runner.get_target(address) return rule_runner.request( - InferredDependencies, [InferShellDependencies(tgt[ShellSourceField])] + InferredDependencies, [InferShellDependencies(tgt[ShellSourcesField])] ) assert run_dep_inference(Address("a", relative_file_path="f1.sh")) == InferredDependencies( diff --git a/src/python/pants/backend/shell/lint/shell_fmt.py b/src/python/pants/backend/shell/lint/shell_fmt.py index 25b1e0c13ff..6d2dce19649 100644 --- a/src/python/pants/backend/shell/lint/shell_fmt.py +++ b/src/python/pants/backend/shell/lint/shell_fmt.py @@ -6,7 +6,7 @@ from dataclasses import dataclass from typing import Iterable -from pants.backend.shell.target_types import ShellSourceField +from pants.backend.shell.target_types import ShellSourcesField from pants.core.goals.fmt import FmtResult, LanguageFmtResults, LanguageFmtTargets from pants.core.goals.style_request import StyleRequest from pants.core.util_rules.source_files import SourceFiles, SourceFilesRequest @@ -17,7 +17,7 @@ @dataclass(frozen=True) class ShellFmtTargets(LanguageFmtTargets): - required_fields = (ShellSourceField,) + required_fields = (ShellSourcesField,) @union @@ -31,7 +31,7 @@ async def format_shell_targets( ) -> LanguageFmtResults: original_sources = await Get( SourceFiles, - SourceFilesRequest(target[ShellSourceField] for target in shell_fmt_targets.targets), + SourceFilesRequest(target[ShellSourcesField] for target in shell_fmt_targets.targets), ) prior_formatter_result = original_sources.snapshot diff --git a/src/python/pants/backend/shell/lint/shellcheck/rules.py b/src/python/pants/backend/shell/lint/shellcheck/rules.py index c40171b07e2..1e9ee2fda61 100644 --- a/src/python/pants/backend/shell/lint/shellcheck/rules.py +++ b/src/python/pants/backend/shell/lint/shellcheck/rules.py @@ -5,7 +5,7 @@ from pants.backend.shell.lint.shellcheck.skip_field import SkipShellcheckField from pants.backend.shell.lint.shellcheck.subsystem import Shellcheck -from pants.backend.shell.target_types import ShellSourceField +from pants.backend.shell.target_types import ShellSourcesField from pants.core.goals.lint import LintRequest, LintResult, LintResults from pants.core.util_rules.config_files import ConfigFiles, ConfigFilesRequest from pants.core.util_rules.external_tool import DownloadedExternalTool, ExternalToolRequest @@ -29,9 +29,9 @@ @dataclass(frozen=True) class ShellcheckFieldSet(FieldSet): - required_fields = (ShellSourceField,) + required_fields = (ShellSourcesField,) - sources: ShellSourceField + sources: ShellSourcesField dependencies: Dependencies @classmethod @@ -58,7 +58,7 @@ async def run_shellcheck(request: ShellcheckRequest, shellcheck: Shellcheck) -> SourceFiles, SourceFilesRequest( (field_set.sources for field_set in request.field_sets), - for_sources_types=(ShellSourceField,), + for_sources_types=(ShellSourcesField,), enable_codegen=True, ), ) @@ -66,7 +66,7 @@ async def run_shellcheck(request: ShellcheckRequest, shellcheck: Shellcheck) -> SourceFiles, SourceFilesRequest( (tgt.get(Sources) for dependencies in all_dependencies for tgt in dependencies), - for_sources_types=(ShellSourceField,), + for_sources_types=(ShellSourcesField,), enable_codegen=True, ), ) diff --git a/src/python/pants/backend/shell/lint/shfmt/rules.py b/src/python/pants/backend/shell/lint/shfmt/rules.py index 3f3cc5cfa49..a705bfc576d 100644 --- a/src/python/pants/backend/shell/lint/shfmt/rules.py +++ b/src/python/pants/backend/shell/lint/shfmt/rules.py @@ -6,7 +6,7 @@ from pants.backend.shell.lint.shell_fmt import ShellFmtRequest from pants.backend.shell.lint.shfmt.skip_field import SkipShfmtField from pants.backend.shell.lint.shfmt.subsystem import Shfmt -from pants.backend.shell.target_types import ShellSourceField +from pants.backend.shell.target_types import ShellSourcesField from pants.core.goals.fmt import FmtResult from pants.core.goals.lint import LintRequest, LintResult, LintResults from pants.core.util_rules.config_files import ConfigFiles, ConfigFilesRequest @@ -24,9 +24,9 @@ @dataclass(frozen=True) class ShfmtFieldSet(FieldSet): - required_fields = (ShellSourceField,) + required_fields = (ShellSourcesField,) - sources: ShellSourceField + sources: ShellSourcesField @classmethod def opt_out(cls, tgt: Target) -> bool: diff --git a/src/python/pants/backend/shell/shunit2_test_runner.py b/src/python/pants/backend/shell/shunit2_test_runner.py index ec65264fb04..8ead51fbe01 100644 --- a/src/python/pants/backend/shell/shunit2_test_runner.py +++ b/src/python/pants/backend/shell/shunit2_test_runner.py @@ -6,11 +6,11 @@ from pants.backend.shell.shell_setup import ShellSetup from pants.backend.shell.target_types import ( - ShellSourceField, + ShellSourcesField, Shunit2Shell, Shunit2ShellField, Shunit2TestsGeneratorTarget, - Shunit2TestSourceField, + Shunit2TestSourcesField, Shunit2TestTimeoutField, ) from pants.core.goals.test import ( @@ -56,9 +56,9 @@ @dataclass(frozen=True) class Shunit2FieldSet(TestFieldSet): - required_fields = (Shunit2TestSourceField,) + required_fields = (Shunit2TestSourcesField,) - sources: Shunit2TestSourceField + sources: Shunit2TestSourcesField timeout: Shunit2TestTimeoutField shell: Shunit2ShellField runtime_package_dependencies: RuntimePackageDependenciesField @@ -172,7 +172,7 @@ async def setup_shunit2_for_target( SourceFiles, SourceFilesRequest( (tgt.get(Sources) for tgt in transitive_targets.dependencies), - for_sources_types=(ShellSourceField, FilesSources, ResourcesSources), + for_sources_types=(ShellSourcesField, FilesSources, ResourcesSources), enable_codegen=True, ), ) diff --git a/src/python/pants/backend/shell/target_types.py b/src/python/pants/backend/shell/target_types.py index a348be9b8b4..81bcedae9ee 100644 --- a/src/python/pants/backend/shell/target_types.py +++ b/src/python/pants/backend/shell/target_types.py @@ -33,7 +33,7 @@ from pants.util.enums import match -class ShellSourceField(Sources): +class ShellSourcesField(Sources): # Normally, we would add `expected_file_extensions = ('.sh',)`, but Bash scripts don't need a # file extension, so we don't use this. uses_source_roots = False @@ -113,7 +113,7 @@ def compute_value(cls, raw_value: Optional[int], address: Address) -> Optional[i return value -class Shunit2TestSourceField(ShellSourceField): +class Shunit2TestSourcesField(ShellSourcesField): pass @@ -127,7 +127,7 @@ class Shunit2TestTarget(Target): alias = "shunit2_tests" # TODO(#12954): rename to `shunit_test` when ready. Update `help` too. core_fields = ( *COMMON_TARGET_FIELDS, - Shunit2TestSourceField, + Shunit2TestSourcesField, Shunit2TestDependenciesField, Shunit2TestTimeoutField, Shunit2ShellField, @@ -196,7 +196,7 @@ async def generate_targets_from_shunit2_tests( class ShellSourceTarget(Target): alias = "shell_library" # TODO(#12954): rename to `shell_source` when ready. - core_fields = (*COMMON_TARGET_FIELDS, Dependencies, ShellSourceField) + core_fields = (*COMMON_TARGET_FIELDS, Dependencies, ShellSourcesField) help = "A Bourne-based shell script, e.g. a Bash script."