1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Rename InstallationCandidate.{project -> name} (#7328)

This commit is contained in:
Pradyun Gedam 2019-11-11 13:11:19 +05:30 committed by GitHub
commit c522381b32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 11 deletions

View file

@ -759,7 +759,7 @@ class PackageFinder(object):
return None
return InstallationCandidate(
project=link_evaluator.project_name,
name=link_evaluator.project_name,
link=link,
# Convert the Text result to str since InstallationCandidate
# accepts str.

View file

@ -9,31 +9,30 @@ from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
from pip._vendor.packaging.version import _BaseVersion
from pip._internal.models.link import Link
from typing import Any
class InstallationCandidate(KeyBasedCompareMixin):
"""Represents a potential "candidate" for installation.
"""
def __init__(self, project, version, link):
# type: (Any, str, Link) -> None
self.project = project
def __init__(self, name, version, link):
# type: (str, str, Link) -> None
self.name = name
self.version = parse_version(version) # type: _BaseVersion
self.link = link
super(InstallationCandidate, self).__init__(
key=(self.project, self.version, self.link),
key=(self.name, self.version, self.link),
defining_class=InstallationCandidate
)
def __repr__(self):
# type: () -> str
return "<InstallationCandidate({!r}, {!r}, {!r})>".format(
self.project, self.version, self.link,
self.name, self.version, self.link,
)
def __str__(self):
return '{!r} candidate (version {} at {})'.format(
self.project, self.version, self.link,
self.name, self.version, self.link,
)

View file

@ -485,7 +485,7 @@ def test_process_project_url(data):
assert len(actual) == 1
package_link = actual[0]
assert package_link.project == 'simple'
assert package_link.name == 'simple'
assert str(package_link.version) == '1.0'

View file

@ -47,7 +47,7 @@ class TestInstallationCandidate(object):
obj = candidate.InstallationCandidate(
"A", "1.0.0", "https://somewhere.com/path/A-1.0.0.tar.gz"
)
assert obj.project == "A"
assert obj.name == "A"
assert obj.version == parse_version("1.0.0")
assert obj.link == "https://somewhere.com/path/A-1.0.0.tar.gz"
@ -57,4 +57,4 @@ class TestInstallationCandidate(object):
obj = candidate.InstallationCandidate(
"A", "1.0.0", "https://somewhere.com/path/A-1.0.0.tar.gz"
)
assert obj._compare_key == (obj.project, obj.version, obj.link)
assert obj._compare_key == (obj.name, obj.version, obj.link)