File tree Expand file tree Collapse file tree 2 files changed +9
-18
lines changed
Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,11 @@ def allows(self, other: BaseConstraint) -> bool:
7878
7979 """
8080
81- if not isinstance (other , Constraint ) or other .operator != "==" :
81+ if not isinstance (other , Constraint ) or other .operator not in {
82+ "==" ,
83+ "in" ,
84+ "not in" ,
85+ }:
8286 raise ValueError (
8387 f"Invalid argument for allows"
8488 f' ("other" must be a constraint with operator "=="): { other } '
@@ -95,18 +99,13 @@ def allows(self, other: BaseConstraint) -> bool:
9599
96100 if is_equal_op :
97101 return self ._value == other .value
98- if is_non_equal_op :
99- return self ._value != other .value
100102
101- if (
102- is_in_op
103- and is_other_in_op
104- or is_other_in_op
105- or is_in_op
106- and is_other_equal_op
107- ):
103+ if is_in_op and is_other_in_op or is_in_op and is_other_equal_op :
108104 return bool (self ._trans_op_str ["in" ](other .value , self ._value ))
109105
106+ if is_non_equal_op and not (is_other_in_op or is_other_not_in_op ):
107+ return self ._value != other .value
108+
110109 if (
111110 is_in_op
112111 and is_other_non_equal_op
Original file line number Diff line number Diff line change @@ -315,9 +315,6 @@ def __hash__(self) -> int:
315315
316316
317317class SingleMarker (SingleMarkerLike [Union [BaseConstraint , VersionConstraint ]]):
318- _CONSTRAINT_RE = re .compile (
319- r"""(?i)^((~=|!=|>=?|<=?|==?=?|not in|in)?\s*.+)|(".+"|'.+'\s*(not in|in))$"""
320- )
321318 _CONSTRAINT_RE_PATTERN_1 = re .compile (
322319 r"(?i)^(?P<op>~=|!=|>=?|<=?|==?=?|not in|in)?\s*(?P<value>.+)$"
323320 )
@@ -346,11 +343,6 @@ def __init__(
346343 original_constraint_string = constraint_string = str (constraint )
347344 self ._swapped_name_value : bool = swapped_name_value
348345
349- # Extract operator and value
350- m = self ._CONSTRAINT_RE .match (constraint_string )
351- if m is None :
352- raise InvalidMarker (f"Invalid marker for '{ name } ': { constraint_string } " )
353-
354346 if swapped_name_value :
355347 pattern = self ._CONSTRAINT_RE_PATTERN_2
356348 else :
You can’t perform that action at this time.
0 commit comments