diff options
author | Pradyun Gedam <pradyunsg@gmail.com> | 2021-09-26 18:37:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 18:37:50 +0100 |
commit | c3d3a9873344dd5546d74a454c2fa755effdb48d (patch) | |
tree | b2b9677420061831e37a58432b071b157cccfe94 | |
parent | cb66b03fe65bba5e8cfa44b0cdc6935d5923d2a7 (diff) | |
parent | dadc9fc2fb1e475d4e546ed7fe772b4ee70c251d (diff) | |
download | pip-c3d3a9873344dd5546d74a454c2fa755effdb48d.tar.gz |
Merge pull request #10508 from jdufresne/fix-types
Fix new mypy failures in tests/unit/resolution_resolvelib/
-rw-r--r-- | news/9951f555-1210-4fd3-9a37-fc301a12e9f5.trivial.rst | 0 | ||||
-rw-r--r-- | src/pip/_internal/resolution/resolvelib/provider.py | 2 | ||||
-rw-r--r-- | tests/unit/resolution_resolvelib/test_provider.py | 19 |
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" |