diff --git a/src/python/pants/backend/python/util_rules/pex_environment.py b/src/python/pants/backend/python/util_rules/pex_environment.py index 753be63e128..5136db99ed0 100644 --- a/src/python/pants/backend/python/util_rules/pex_environment.py +++ b/src/python/pants/backend/python/util_rules/pex_environment.py @@ -92,7 +92,7 @@ def verbosity(self) -> int: @dataclass(frozen=True) -class PythonExecutable(BinaryPath["PythonExecutable"], EngineAwareReturnType): +class PythonExecutable(BinaryPath, EngineAwareReturnType): """The BinaryPath of a Python executable for user code, along with some extras.""" append_only_caches: FrozenDict[str, str] = FrozenDict({}) diff --git a/src/python/pants/core/util_rules/system_binaries.py b/src/python/pants/core/util_rules/system_binaries.py index 21c50800d8d..3d230102a0f 100644 --- a/src/python/pants/core/util_rules/system_binaries.py +++ b/src/python/pants/core/util_rules/system_binaries.py @@ -11,7 +11,9 @@ from dataclasses import dataclass from enum import Enum from textwrap import dedent # noqa: PNT20 -from typing import Generic, Iterable, Mapping, Sequence, TypeVar +from typing import Iterable, Mapping, Sequence + +from typing_extensions import Self from pants.base.deprecated import warn_or_error from pants.core.subsystems import python_bootstrap @@ -40,11 +42,8 @@ SEARCH_PATHS = ("/usr/bin", "/bin", "/usr/local/bin", "/opt/homebrew/bin") -BinaryPathT = TypeVar("BinaryPathT", bound="BinaryPath") - - @dataclass(frozen=True) -class BinaryPath(Generic[BinaryPathT]): +class BinaryPath: path: str fingerprint: str @@ -61,8 +60,8 @@ def _fingerprint(content: bytes | bytearray | memoryview | None = None) -> str: @classmethod def fingerprinted( - cls: type[BinaryPathT], path: str, representative_content: bytes | bytearray | memoryview - ) -> BinaryPathT: + cls, path: str, representative_content: bytes | bytearray | memoryview + ) -> Self: return cls(path, fingerprint=cls._fingerprint(representative_content))