From 9b25cd512b0c3c2611c280bb0bcd4202e81246e1 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sat, 9 Nov 2019 11:47:03 +0530 Subject: [PATCH] Rename InstallationCandidate.{project -> name} --- src/pip/_internal/index/package_finder.py | 2 +- src/pip/_internal/models/candidate.py | 13 ++++++------- tests/unit/test_finder.py | 2 +- tests/unit/test_models.py | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/pip/_internal/index/package_finder.py b/src/pip/_internal/index/package_finder.py index 5be1c1488..188f571c7 100644 --- a/src/pip/_internal/index/package_finder.py +++ b/src/pip/_internal/index/package_finder.py @@ -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. diff --git a/src/pip/_internal/models/candidate.py b/src/pip/_internal/models/candidate.py index 4d49604dd..850825f6a 100644 --- a/src/pip/_internal/models/candidate.py +++ b/src/pip/_internal/models/candidate.py @@ -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 "".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, ) diff --git a/tests/unit/test_finder.py b/tests/unit/test_finder.py index a3b0da39a..ddfcc7860 100644 --- a/tests/unit/test_finder.py +++ b/tests/unit/test_finder.py @@ -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' diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py index c922dc773..f63633677 100644 --- a/tests/unit/test_models.py +++ b/tests/unit/test_models.py @@ -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)