Skip to content

Rename InstallationCandidate.{project -> name} #7328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def get_install_candidate(self, link_evaluator, link):
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.
Expand Down
13 changes: 6 additions & 7 deletions src/pip/_internal/models/candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,30 @@
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,
)
2 changes: 1 addition & 1 deletion tests/unit/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_sets_correct_variables(self):
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"

Expand All @@ -57,4 +57,4 @@ def test_sets_the_right_key(self):
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)