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

Complete type annotations in pip/_internal/index and pip/_internal/models #10189

Merged
merged 1 commit into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
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
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