Skip to content

Commit

Permalink
Add some missing types to PythonIdentity.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Jan 24, 2025
1 parent b8474a2 commit 690f084
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pex/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ def iter_tags():

@classmethod
def _find_interpreter_name(cls, python_tag):
# type: (str) -> str
for abbr, interpreter in cls.ABBR_TO_INTERPRETER_NAME.items():
if python_tag.startswith(abbr):
return interpreter
Expand Down Expand Up @@ -453,6 +454,7 @@ def __init__(
self._configured_macosx_deployment_target = configured_macosx_deployment_target

def encode(self):
# type: () -> str
site_packages = [] # type: List[str]
purelib = None # type: Optional[str]
platlib = None # type: Optional[str]
Expand Down Expand Up @@ -494,6 +496,7 @@ def encode(self):

@property
def binary(self):
# type: () -> str
return self._binary

@property
Expand Down Expand Up @@ -533,14 +536,17 @@ def paths(self):

@property
def python_tag(self):
# type: () -> str
return self._python_tag

@property
def abi_tag(self):
# type: () -> str
return self._abi_tag

@property
def platform_tag(self):
# type: () -> str
return self._platform_tag

@property
Expand Down Expand Up @@ -589,6 +595,7 @@ def configured_macosx_deployment_target(self):

@property
def interpreter(self):
# type: () -> str
return self._interpreter_name

def iter_supported_platforms(self):
Expand Down Expand Up @@ -651,12 +658,14 @@ def __repr__(self):
)

def _tup(self):
# type: () -> Tuple[str, str, str, str, Tuple[int, int, int]]
return self._binary, self._python_tag, self._abi_tag, self._platform_tag, self._version

def __eq__(self, other):
if type(other) is not type(self):
return NotImplemented
return self._tup() == other._tup()
# type: (Any) -> bool
if isinstance(other, PythonIdentity):
return self._tup() == other._tup()
return NotImplemented

def __hash__(self):
# type: () -> int
Expand Down

0 comments on commit 690f084

Please sign in to comment.