Cours/venv/lib/python3.12/site-packages/pip/_internal/models/candidate.py

26 lines
753 B
Python
Raw Permalink Normal View History

2024-09-05 15:01:34 +00:00
from dataclasses import dataclass
from pip._vendor.packaging.version import Version
2024-09-02 16:55:06 +00:00
from pip._vendor.packaging.version import parse as parse_version
from pip._internal.models.link import Link
2024-09-05 15:01:34 +00:00
@dataclass(frozen=True)
class InstallationCandidate:
2024-09-02 16:55:06 +00:00
"""Represents a potential "candidate" for installation."""
__slots__ = ["name", "version", "link"]
2024-09-05 15:01:34 +00:00
name: str
version: Version
link: Link
2024-09-02 16:55:06 +00:00
def __init__(self, name: str, version: str, link: Link) -> None:
2024-09-05 15:01:34 +00:00
object.__setattr__(self, "name", name)
object.__setattr__(self, "version", parse_version(version))
object.__setattr__(self, "link", link)
2024-09-02 16:55:06 +00:00
def __str__(self) -> str:
return f"{self.name!r} candidate (version {self.version} at {self.link})"