Skip to content

Commit

Permalink
constraints: allow whitespace padding in caret constraints (for consi…
Browse files Browse the repository at this point in the history
…stency) and consolidate `parse_constraint` tests (#606)
  • Loading branch information
radoering authored Jun 18, 2023
1 parent 2bba11c commit 0749c55
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 216 deletions.
2 changes: 1 addition & 1 deletion src/poetry/core/constraints/version/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _parse_constraint(
# standard-compliant it seems to occur in some packages)
constraints = constraints.rstrip(",").rstrip()
and_constraints = re.split(
"(?<!^)(?<![~=>< ,]) *(?<!-)[, ](?!-) *(?!,|$)", constraints
r"(?<!^)(?<![\^~=>< ,]) *(?<!-)[, ](?!-) *(?!,|$)", constraints
)
constraint_objects = []

Expand Down
2 changes: 1 addition & 1 deletion src/poetry/core/constraints/version/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
COMPLETE_VERSION = re.compile(VERSION_PATTERN, re.VERBOSE | re.IGNORECASE)

CARET_CONSTRAINT = re.compile(
rf"^\^(?P<version>{VERSION_PATTERN})$", re.VERBOSE | re.IGNORECASE
rf"^\^\s*(?P<version>{VERSION_PATTERN})$", re.VERBOSE | re.IGNORECASE
)
TILDE_CONSTRAINT = re.compile(
rf"^~(?!=)\s*(?P<version>{VERSION_PATTERN})$", re.VERBOSE | re.IGNORECASE
Expand Down
Loading

0 comments on commit 0749c55

Please sign in to comment.