python-semanticversion
python-semanticversion copied to clipboard
semantic_version.match emits a PendingDeprecationWarning
Summary
Calling the top-level match
method emits a PendingDeprecationWarning
regardless of the provided inputs
Environment and Version
- Python version: 3.11.3 (conda-forge)
-
semantic_version
version: '2.10.0' - Operating system: Linux x64
Steps to Reproduce
>>> import warnings
>>> import semantic_version as semver
>>> warnings.simplefilter("always")
>>> semver.match(">1.19.2", "1.19.3")
produces:
/path/to/my/virtualenv/lib/python3.11/site-packages/semantic_version/base.py:600: PendingDeprecationWarning: The Spec() class will be removed in 3.1; use SimpleSpec() instead.
return Spec(spec).match(Version(version))
True
Workaround
Being hyper-explicit in my call:
>>> semver.SimpleSpec(">1.19.2").match(semver.Version("1.19.3"))
will produce the desired result with no warning
Severity
Annoyance. I'm using this as a dependency in a personal project, and the deprecation shows up all over my test logs. Given that the API seems to be somewhat in flux, I'd prefer to rely on the simple string-matching method, unless that too is deprecated.
Desired Outcome
Looking at the current implementation:
https://github.com/rbarrois/python-semanticversion/blob/2cbbee3154d9011cee873ae3a020cd17c669f6df/semantic_version/base.py#L606-L607
It seems like it would be a simple matter of changing:
def match(spec, version):
- return Spec(spec).match(Version(version))
+ return SimpleSpec(spec).match(Version(version))
but if the intent is to wean users off of the direct match
method, then the current behavior makes sense.
Ah. Looks like this is related to #109. Feel free to close this as a dupe (though please let me know first if the top-level match
function is going away).