Skip to content

Commit

Permalink
Merge pull request #10189 from harupy/type-annotations-index-models
Browse files Browse the repository at this point in the history
Complete type annotations in `pip/_internal/index` and `pip/_internal/models`
  • Loading branch information
uranusjr authored Jul 24, 2021
2 parents 02b1855 + 6ff78f0 commit 5e86264
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def _sort_key(self, candidate: InstallationCandidate) -> CandidateSortingKey:
"""
valid_tags = self._supported_tags
support_num = len(valid_tags)
build_tag = () # type: BuildTag
build_tag: BuildTag = ()
binary_preference = 0
link = candidate.link
if link.is_wheel:
Expand Down Expand Up @@ -603,7 +603,7 @@ def __init__(
self.format_control = format_control

# These are boring links that have already been logged somehow.
self._logged_links = set() # type: Set[Link]
self._logged_links: Set[Link] = set()

# Don't include an allow_yanked default value to make sure each call
# site considers whether yanked releases are allowed. This also causes
Expand Down Expand Up @@ -699,7 +699,7 @@ def _sort_links(self, links: Iterable[Link]) -> List[Link]:
second, while eliminating duplicates
"""
eggs, no_eggs = [], []
seen = set() # type: Set[Link]
seen: Set[Link] = set()
for link in links:
if link not in seen:
seen.add(link)
Expand Down Expand Up @@ -871,7 +871,7 @@ def find_requirement(
)
best_candidate = best_candidate_result.best_candidate

installed_version = None # type: Optional[_BaseVersion]
installed_version: Optional[_BaseVersion] = None
if req.satisfied_by is not None:
installed_version = parse_version(req.satisfied_by.version)

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/models/search_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create(
# it and if it exists, use the normalized version.
# This is deliberately conservative - it might be fine just to
# blindly normalize anything starting with a ~...
built_find_links = [] # type: List[str]
built_find_links: List[str] = []
for link in find_links:
if link.startswith('~'):
new_link = normalize_path(link)
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/models/selection_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def __init__(
format_control: Optional[FormatControl] = None,
prefer_binary: bool = False,
ignore_requires_python: Optional[bool] = None,
):
# type: (...) -> None
) -> None:
"""Create a SelectionPreferences object.
:param allow_yanked: Whether files marked as yanked (in the sense
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/models/target_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
self.py_version_info = py_version_info

# This is used to cache the return value of get_tags().
self._valid_tags = None # type: Optional[List[Tag]]
self._valid_tags: Optional[List[Tag]] = None

def format_given(self) -> str:
"""
Expand Down

0 comments on commit 5e86264

Please sign in to comment.