Skip to content

Commit

Permalink
version.text replaces pretty_version
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Jan 5, 2023
1 parent 5a273c3 commit 192f487
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def __init__(
self,
name: str,
version: str | Version,
pretty_version: str | None = None,
source_type: str | None = None,
source_url: str | None = None,
source_reference: str | None = None,
Expand All @@ -79,7 +78,7 @@ def __init__(
features=features,
)

self._set_version(version, pretty_version)
self._set_version(version)

self.description = ""

Expand Down Expand Up @@ -131,7 +130,7 @@ def version(self) -> Version:

@property
def pretty_version(self) -> str:
return self._pretty_version
return self._version.text

@property
def unique_name(self) -> str:
Expand All @@ -147,22 +146,22 @@ def pretty_string(self) -> str:
@property
def full_pretty_version(self) -> str:
if self.source_type in ["file", "directory", "url"]:
return f"{self._pretty_version} {self.source_url}"
return f"{self.pretty_version} {self.source_url}"

if self.source_type not in ["hg", "git"]:
return self._pretty_version
return self.pretty_version

ref: str | None
if self.source_resolved_reference and len(self.source_resolved_reference) == 40:
ref = self.source_resolved_reference[0:7]
return f"{self._pretty_version} {ref}"
return f"{self.pretty_version} {ref}"

# if source reference is a sha1 hash -- truncate
if self.source_reference and len(self.source_reference) == 40:
return f"{self._pretty_version} {self.source_reference[0:7]}"
return f"{self.pretty_version} {self.source_reference[0:7]}"

ref = self._source_resolved_reference or self._source_reference
return f"{self._pretty_version} {ref}"
return f"{self.pretty_version} {ref}"

@property
def authors(self) -> list[str]:
Expand Down Expand Up @@ -211,9 +210,7 @@ def all_requires(
for dependency in group.dependencies
]

def _set_version(
self, version: str | Version, pretty_version: str | None = None
) -> None:
def _set_version(self, version: str | Version) -> None:
from poetry.core.constraints.version import Version

if not isinstance(version, Version):
Expand All @@ -225,7 +222,6 @@ def _set_version(
)

self._version = version
self._pretty_version = pretty_version or version.text

def _get_author(self) -> dict[str, str | None]:
if not self._authors:
Expand Down

0 comments on commit 192f487

Please sign in to comment.