Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some missing types to PythonIdentity. #2649

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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