Skip to content

Commit

Permalink
Backport changes from python-poetry/poetry#2398
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Jun 5, 2020
1 parent f98842c commit 07c0ff7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions poetry/core/packages/directory_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,14 @@ def base_pep_508_name(self): # type: () -> str
requirement += " @ {}".format(str(self.path))

return requirement

def __str__(self):
if self.is_root:
return self._pretty_name

return "{} ({} {})".format(
self._pretty_name, self._pretty_constraint, self._path
)

def __hash__(self):
return hash((self._name, self._full_path))
15 changes: 15 additions & 0 deletions poetry/core/packages/file_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def __init__(
name, "*", category=category, optional=optional, allows_prereleases=True
)

@property
def base(self):
return self._base

@property
def path(self):
return self._path
Expand Down Expand Up @@ -63,3 +67,14 @@ def base_pep_508_name(self): # type: () -> str
requirement += " @ {}".format(path)

return requirement

def __str__(self):
if self.is_root:
return self._pretty_name

return "{} ({} {})".format(
self._pretty_name, self._pretty_constraint, self._path
)

def __hash__(self):
return hash((self._name, self._full_path))
1 change: 1 addition & 0 deletions poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ def with_python_versions(self, python_versions):

def clone(self): # type: () -> Package
clone = self.__class__(self.pretty_name, self.version)
clone.description = self.description
clone.category = self.category
clone.optional = self.optional
clone.python_versions = self.python_versions
Expand Down
6 changes: 6 additions & 0 deletions poetry/core/packages/url_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ def base_pep_508_name(self): # type: () -> str

def is_url(self): # type: () -> bool
return True

def __str__(self):
return "{} ({} url)".format(self._pretty_name, self._pretty_constraint)

def __hash__(self):
return hash((self._name, self._url))
8 changes: 8 additions & 0 deletions poetry/core/packages/vcs_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,11 @@ def is_vcs(self): # type: () -> bool

def accepts_prereleases(self): # type: () -> bool
return True

def __str__(self):
return "{} ({} {})".format(
self._pretty_name, self._pretty_constraint, self._vcs
)

def __hash__(self):
return hash((self._name, self._vcs, self._branch, self._tag, self._rev))

0 comments on commit 07c0ff7

Please sign in to comment.