You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

candidate.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # The following comment should be removed at some point in the future.
  2. # mypy: disallow-untyped-defs=False
  3. from pip._vendor.packaging.version import parse as parse_version
  4. from pip._internal.utils.models import KeyBasedCompareMixin
  5. from pip._internal.utils.typing import MYPY_CHECK_RUNNING
  6. if MYPY_CHECK_RUNNING:
  7. from pip._vendor.packaging.version import _BaseVersion
  8. from pip._internal.models.link import Link
  9. from typing import Any
  10. class InstallationCandidate(KeyBasedCompareMixin):
  11. """Represents a potential "candidate" for installation.
  12. """
  13. def __init__(self, project, version, link):
  14. # type: (Any, str, Link) -> None
  15. self.project = project
  16. self.version = parse_version(version) # type: _BaseVersion
  17. self.link = link
  18. super(InstallationCandidate, self).__init__(
  19. key=(self.project, self.version, self.link),
  20. defining_class=InstallationCandidate
  21. )
  22. def __repr__(self):
  23. # type: () -> str
  24. return "<InstallationCandidate({!r}, {!r}, {!r})>".format(
  25. self.project, self.version, self.link,
  26. )
  27. def __str__(self):
  28. return '{!r} candidate (version {} at {})'.format(
  29. self.project, self.version, self.link,
  30. )