diff --git a/packaging/specifiers.py b/packaging/specifiers.py index 0e218a6f..dbc364b7 100644 --- a/packaging/specifiers.py +++ b/packaging/specifiers.py @@ -298,8 +298,10 @@ def wrapped(self: "Specifier", prospective: ParsedVersion, spec: str) -> bool: class Specifier(_IndividualSpecifier): - _regex_str = r""" + _operator_regex_str = r""" (?P(~=|==|!=|<=|>=|<|>|===)) + """ + _version_regex_str = r""" (?P (?: # The identity operators allow for an escape hatch that will @@ -391,7 +393,10 @@ class Specifier(_IndividualSpecifier): ) """ - _regex = re.compile(r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE) + _regex = re.compile( + r"^\s*" + _operator_regex_str + _version_regex_str + r"\s*$", + re.VERBOSE | re.IGNORECASE, + ) _operators = { "~=": "compatible",