Skip to content

Commit

Permalink
Bump semver for py3.10 and fix DeprecationWarning: Function semver.ma…
Browse files Browse the repository at this point in the history
…tch is deprecated and other semver warnings
  • Loading branch information
nzlosh committed Mar 19, 2024
1 parent 999aa4f commit bcc74d8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion fixed-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ redis==4.1.4
requests[security]==2.25.1
retrying==1.3.3
routes==2.4.1
semver==2.13.0
semver==3.0.2
six==1.13.0
argparse==1.12.2
# 202403: Bumped to latest for py3.10 support
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ rednose
requests[security]==2.25.1
retrying==1.3.3
routes==2.4.1
semver==2.13.0
semver==3.0.2
simplejson
six==1.13.0
sseclient-py==1.7
Expand Down
2 changes: 1 addition & 1 deletion st2common/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ redis==4.1.4
requests[security]==2.25.1
retrying==1.3.3
routes==2.4.1
semver==2.13.0
semver==3.0.2
six==1.13.0
st2-rbac-backend@ git+https://github.com/StackStorm/st2-rbac-backend.git@master
tenacity>=3.2.1,<7.0.0
Expand Down
18 changes: 9 additions & 9 deletions st2common/st2common/expressions/functions/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@


def version_compare(value, pattern):
return semver.compare(value, pattern)
return semver.Version.parse(value).compare(pattern)


def version_more_than(value, pattern):
return semver.compare(value, pattern) == 1
return version_compare(value, pattern) == 1


def version_less_than(value, pattern):
return semver.compare(value, pattern) == -1
return version_compare(value, pattern) == -1


def version_equal(value, pattern):
return semver.compare(value, pattern) == 0
return version_compare(value, pattern) == 0


def version_match(value, pattern):
return semver.match(value, pattern)
return semver.Version.parse(value).match(pattern)


def version_bump_major(value):
return semver.bump_major(value)
return str(semver.Version.parse(value).bump_major())


def version_bump_minor(value):
return semver.bump_minor(value)
return str(semver.Version.parse(value).bump_minor())


def version_bump_patch(value):
return semver.bump_patch(value)
return str(semver.Version.parse(value).bump_patch())


def version_strip_patch(value):
return "{major}.{minor}".format(**semver.parse(value))
return "{major}.{minor}".format(**semver.Version.parse(value))
4 changes: 2 additions & 2 deletions st2common/st2common/util/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def complex_semver_match(version, version_specifier):

if len(split_version_specifier) == 1:
# No comma, we can do a simple comparision
return semver.match(version, version_specifier)
return semver.Version.parse(version).match(version_specifier)
else:
# Compare part by part
for version_specifier_part in split_version_specifier:
Expand All @@ -74,7 +74,7 @@ def complex_semver_match(version, version_specifier):
if not version_specifier_part:
continue

if not semver.match(version, version_specifier_part):
if not semver.Version.parse(version).match(version_specifier_part):
return False

return True
Empty file.

0 comments on commit bcc74d8

Please sign in to comment.