summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2021-09-26 06:50:41 -0700
committerJon Dufresne <jon.dufresne@gmail.com>2021-09-26 07:02:56 -0700
commitdadc9fc2fb1e475d4e546ed7fe772b4ee70c251d (patch)
treeb2b9677420061831e37a58432b071b157cccfe94
parentcb66b03fe65bba5e8cfa44b0cdc6935d5923d2a7 (diff)
downloadpip-dadc9fc2fb1e475d4e546ed7fe772b4ee70c251d.tar.gz
Fix new mypy failures in tests/unit/resolution_resolvelib/
Before, during, or after merge b392833a0f1cff1bbee1ac6dbe0270cccdd0c11f, new code was added that now requires typing.
-rw-r--r--news/9951f555-1210-4fd3-9a37-fc301a12e9f5.trivial.rst0
-rw-r--r--src/pip/_internal/resolution/resolvelib/provider.py2
-rw-r--r--tests/unit/resolution_resolvelib/test_provider.py19
3 files changed, 16 insertions, 5 deletions
diff --git a/news/9951f555-1210-4fd3-9a37-fc301a12e9f5.trivial.rst b/news/9951f555-1210-4fd3-9a37-fc301a12e9f5.trivial.rst
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/news/9951f555-1210-4fd3-9a37-fc301a12e9f5.trivial.rst
diff --git a/src/pip/_internal/resolution/resolvelib/provider.py b/src/pip/_internal/resolution/resolvelib/provider.py
index a3250b351..c2203933e 100644
--- a/src/pip/_internal/resolution/resolvelib/provider.py
+++ b/src/pip/_internal/resolution/resolvelib/provider.py
@@ -71,7 +71,7 @@ class PipProvider(_ProviderBase):
identifier: str,
resolutions: Mapping[str, Candidate],
candidates: Mapping[str, Iterator[Candidate]],
- information: Mapping[str, Iterator["PreferenceInformation"]],
+ information: Mapping[str, Iterable["PreferenceInformation"]],
) -> "Preference":
"""Produce a sort key for given requirement based on preference.
diff --git a/tests/unit/resolution_resolvelib/test_provider.py b/tests/unit/resolution_resolvelib/test_provider.py
index 970254280..09b887f09 100644
--- a/tests/unit/resolution_resolvelib/test_provider.py
+++ b/tests/unit/resolution_resolvelib/test_provider.py
@@ -1,21 +1,32 @@
+from typing import TYPE_CHECKING, List, Optional
+
from pip._vendor.resolvelib.resolvers import RequirementInformation
from pip._internal.models.candidate import InstallationCandidate
from pip._internal.models.link import Link
from pip._internal.req.constructors import install_req_from_req_string
+from pip._internal.resolution.resolvelib.factory import Factory
from pip._internal.resolution.resolvelib.provider import PipProvider
from pip._internal.resolution.resolvelib.requirements import SpecifierRequirement
+if TYPE_CHECKING:
+ from pip._internal.resolution.resolvelib.provider import PreferenceInformation
+
-def build_requirement_information(name, parent):
+def build_requirement_information(
+ name: str, parent: Optional[InstallationCandidate]
+) -> List["PreferenceInformation"]:
install_requirement = install_req_from_req_string(name)
- requirement_information = RequirementInformation(
- requirement=SpecifierRequirement(install_requirement), parent=parent
+ # RequirementInformation is typed as a tuple, but it is a namedtupled.
+ # https://github.com/sarugaku/resolvelib/blob/7bc025aa2a4e979597c438ad7b17d2e8a08a364e/src/resolvelib/resolvers.pyi#L20-L22
+ requirement_information: PreferenceInformation = RequirementInformation(
+ requirement=SpecifierRequirement(install_requirement), # type: ignore[call-arg]
+ parent=parent,
)
return [requirement_information]
-def test_provider_known_depths(factory):
+def test_provider_known_depths(factory: Factory) -> None:
# Root requirement is specified by the user
# therefore has an infered depth of 1
root_requirement_name = "my-package"