Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependency: allow constraint to be set #90

Merged
merged 2 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
abn marked this conversation as resolved.
Show resolved Hide resolved
build-backend = "intreehooks:loader"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
backend-path = ["."]