-
Notifications
You must be signed in to change notification settings - Fork 74
Description
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_versionversion: '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:
python-semanticversion/semantic_version/base.py
Lines 606 to 607 in 2cbbee3
| def match(spec, version): | |
| return Spec(spec).match(Version(version)) |
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.