Pkg: fix parsing versions (#15401)

* testing
* fix regex
This commit is contained in:
Jirka Borovec 2022-11-01 23:43:22 +01:00 committed by GitHub
parent 1b56daf4f7
commit c0149d86df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -54,11 +54,11 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
Returns:
adjusted requirement
>>> _augment_requirement("arrow>=1.2.0, <=1.2.2 # anything", unfreeze="")
'arrow>=1.2.0, <=1.2.2'
>>> _augment_requirement("arrow>=1.2.0, <=1.2.2 # strict", unfreeze="")
'arrow>=1.2.0, <=1.2.2 # strict'
>>> _augment_requirement("arrow>=1.2.0, <=1.2.2 # my name", unfreeze="all")
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # anything", unfreeze="")
'arrow<=1.2.2,>=1.2.0'
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # strict", unfreeze="")
'arrow<=1.2.2,>=1.2.0 # strict'
>>> _augment_requirement("arrow<=1.2.2,>=1.2.0 # my name", unfreeze="all")
'arrow>=1.2.0'
>>> _augment_requirement("arrow>=1.2.0, <=1.2.2 # strict", unfreeze="all")
'arrow>=1.2.0, <=1.2.2 # strict'
@ -94,7 +94,7 @@ def _augment_requirement(ln: str, comment_char: str = "#", unfreeze: str = "all"
# remove version restrictions unless they are strict
if unfreeze and "<" in req and not is_strict:
req = re.sub(r",? *<=? *[\d\.\*]+", "", req).strip()
req = re.sub(r",? *<=? *[\d\.\*]+,? *", "", req).strip()
if ver_major is not None and not is_strict:
# add , only if there are already some versions
req += f"{',' if any(c in req for c in '<=>') else ''} <{int(ver_major) + 1}.0"