|
| 1 | +from typing import TYPE_CHECKING, List, Optional |
| 2 | + |
1 | 3 | from pip._vendor.resolvelib.resolvers import RequirementInformation
|
2 | 4 |
|
3 | 5 | from pip._internal.models.candidate import InstallationCandidate
|
4 | 6 | from pip._internal.models.link import Link
|
5 | 7 | from pip._internal.req.constructors import install_req_from_req_string
|
| 8 | +from pip._internal.resolution.resolvelib.factory import Factory |
6 | 9 | from pip._internal.resolution.resolvelib.provider import PipProvider
|
7 | 10 | from pip._internal.resolution.resolvelib.requirements import SpecifierRequirement
|
8 | 11 |
|
| 12 | +if TYPE_CHECKING: |
| 13 | + from pip._internal.resolution.resolvelib.provider import PreferenceInformation |
| 14 | + |
9 | 15 |
|
10 |
| -def build_requirement_information(name, parent): |
| 16 | +def build_requirement_information( |
| 17 | + name: str, parent: Optional[InstallationCandidate] |
| 18 | +) -> List["PreferenceInformation"]: |
11 | 19 | install_requirement = install_req_from_req_string(name)
|
12 |
| - requirement_information = RequirementInformation( |
13 |
| - requirement=SpecifierRequirement(install_requirement), parent=parent |
| 20 | + # RequirementInformation is typed as a tuple, but it is a namedtupled. |
| 21 | + # https://github.com/sarugaku/resolvelib/blob/7bc025aa2a4e979597c438ad7b17d2e8a08a364e/src/resolvelib/resolvers.pyi#L20-L22 |
| 22 | + requirement_information: PreferenceInformation = RequirementInformation( |
| 23 | + requirement=SpecifierRequirement(install_requirement), # type: ignore[call-arg] |
| 24 | + parent=parent, |
14 | 25 | )
|
15 | 26 | return [requirement_information]
|
16 | 27 |
|
17 | 28 |
|
18 |
| -def test_provider_known_depths(factory): |
| 29 | +def test_provider_known_depths(factory: Factory) -> None: |
19 | 30 | # Root requirement is specified by the user
|
20 | 31 | # therefore has an infered depth of 1
|
21 | 32 | root_requirement_name = "my-package"
|
|
0 commit comments