Skip to content

semantic_version.match emits a PendingDeprecationWarning #147

@OpenBagTwo

Description

@OpenBagTwo

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions