Skip to content

Commit

Permalink
Use Self backport in BinaryPath factory method. (pantsbuild#18763)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois authored Apr 19, 2023
1 parent 7522356 commit 482e9ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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({})
Expand Down
13 changes: 6 additions & 7 deletions src/python/pants/core/util_rules/system_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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))


Expand Down

0 comments on commit 482e9ac

Please sign in to comment.