mirror of https://github.com/pypa/pip
linting
This commit is contained in:
parent
39e1102800
commit
e6333bb4d1
|
@ -16,7 +16,7 @@ from typing import Collection, Dict, List, Optional, Set, Tuple, Union
|
|||
|
||||
from pip._vendor.packaging.markers import Marker
|
||||
from pip._vendor.packaging.requirements import InvalidRequirement, Requirement
|
||||
from pip._vendor.packaging.specifiers import Specifier, SpecifierSet
|
||||
from pip._vendor.packaging.specifiers import Specifier
|
||||
|
||||
from pip._internal.exceptions import InstallationError
|
||||
from pip._internal.models.index import PyPI, TestPyPI
|
||||
|
@ -72,11 +72,7 @@ def _set_requirement_extras(req: Requirement, new_extras: Set[str]) -> Requireme
|
|||
pre: Optional[str] = match.group(1)
|
||||
post: Optional[str] = match.group(3)
|
||||
assert pre is not None and post is not None
|
||||
extras: str = (
|
||||
"[%s]" % ",".join(sorted(new_extras))
|
||||
if new_extras
|
||||
else ""
|
||||
)
|
||||
extras: str = "[%s]" % ",".join(sorted(new_extras)) if new_extras else ""
|
||||
return Requirement(pre + extras + post)
|
||||
|
||||
|
||||
|
@ -537,9 +533,7 @@ def install_req_drop_extras(ireq: InstallRequirement) -> InstallRequirement:
|
|||
"""
|
||||
return InstallRequirement(
|
||||
req=(
|
||||
_set_requirement_extras(ireq.req, set())
|
||||
if ireq.req is not None
|
||||
else None
|
||||
_set_requirement_extras(ireq.req, set()) if ireq.req is not None else None
|
||||
),
|
||||
comes_from=ireq,
|
||||
editable=ireq.editable,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from pip._vendor.packaging.specifiers import SpecifierSet
|
||||
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
||||
|
||||
from pip._internal.req.req_install import InstallRequirement
|
||||
from pip._internal.req.constructors import install_req_drop_extras
|
||||
from pip._internal.req.req_install import InstallRequirement
|
||||
|
||||
from .base import Candidate, CandidateLookup, Requirement, format_name
|
||||
|
||||
|
|
|
@ -2294,7 +2294,8 @@ def test_new_resolver_dont_backtrack_on_extra_if_base_constrained_in_requirement
|
|||
)
|
||||
|
||||
to_install: tuple[str, str] = (
|
||||
"pkg[ext1]", "pkg[ext2]==1.0" if two_extras else "pkg==1.0"
|
||||
"pkg[ext1]",
|
||||
"pkg[ext2]==1.0" if two_extras else "pkg==1.0",
|
||||
)
|
||||
|
||||
result = script.pip(
|
||||
|
@ -2331,7 +2332,8 @@ def test_new_resolver_dont_backtrack_on_conflicting_constraints_on_extras(
|
|||
)
|
||||
|
||||
to_install: tuple[str, str] = (
|
||||
"pkg[ext1]>1", "pkg[ext2]==1.0" if two_extras else "pkg==1.0"
|
||||
"pkg[ext1]>1",
|
||||
"pkg[ext2]==1.0" if two_extras else "pkg==1.0",
|
||||
)
|
||||
|
||||
result = script.pip(
|
||||
|
@ -2343,15 +2345,15 @@ def test_new_resolver_dont_backtrack_on_conflicting_constraints_on_extras(
|
|||
*(to_install if not swap_order else reversed(to_install)),
|
||||
expect_error=True,
|
||||
)
|
||||
assert "pkg-2.0" not in result.stdout or "pkg-1.0" not in result.stdout, (
|
||||
"Should only try one of 1.0, 2.0 depending on order"
|
||||
)
|
||||
assert "looking at multiple versions" not in result.stdout, (
|
||||
"Should not have to look at multiple versions to conclude conflict"
|
||||
)
|
||||
assert "conflict is caused by" in result.stdout, (
|
||||
"Resolver should be trivially able to find conflict cause"
|
||||
)
|
||||
assert (
|
||||
"pkg-2.0" not in result.stdout or "pkg-1.0" not in result.stdout
|
||||
), "Should only try one of 1.0, 2.0 depending on order"
|
||||
assert (
|
||||
"looking at multiple versions" not in result.stdout
|
||||
), "Should not have to look at multiple versions to conclude conflict"
|
||||
assert (
|
||||
"conflict is caused by" in result.stdout
|
||||
), "Resolver should be trivially able to find conflict cause"
|
||||
|
||||
|
||||
def test_new_resolver_respect_user_requested_if_extra_is_installed(
|
||||
|
|
Loading…
Reference in New Issue