Skip to content

Commit

Permalink
Merge pull request #90 from abn/dependency-set-constraint
Browse files Browse the repository at this point in the history
dependency: allow constraint to be set
  • Loading branch information
sdispater authored Sep 30, 2020
2 parents 59bd2ce + 5bba4d8 commit 38d9e63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
18 changes: 11 additions & 7 deletions poetry/core/packages/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,8 @@ def __init__(
features=extras,
)

try:
if not isinstance(constraint, VersionConstraint):
self._constraint = parse_constraint(constraint)
else:
self._constraint = constraint
except ValueError:
self._constraint = parse_constraint("*")
self._constraint = None
self.set_constraint(constraint=constraint)

self._pretty_constraint = str(constraint)
self._optional = optional
Expand Down Expand Up @@ -86,6 +81,15 @@ def name(self):
def constraint(self):
return self._constraint

def set_constraint(self, constraint):
try:
if not isinstance(constraint, VersionConstraint):
self._constraint = parse_constraint(constraint)
else:
self._constraint = constraint
except ValueError:
self._constraint = parse_constraint("*")

@property
def pretty_constraint(self):
return self._pretty_constraint
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ vendoring = {version = "^0.3", python = "~3.8"}
pep517 = "^0.8.2"
"backports.tempfile" = {version = "^1.0", python = "~2.7"}

[tool.intreehooks]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 88
include = '\.pyi?$'
Expand Down Expand Up @@ -119,5 +116,6 @@ appdirs = []
pyrsistent = "https://raw.githubusercontent.com/tobgu/pyrsistent/master/LICENCE.mit"

[build-system]
requires = ["intreehooks"]
build-backend = "intreehooks:loader"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
backend-path = ["."]

0 comments on commit 38d9e63

Please sign in to comment.