From 84b1cd8e7760a9b3c984a4edfc37dc7266952266 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 31 Oct 2021 21:09:54 -0400 Subject: [PATCH] Raise a deprecation warning when an invalid version is encountered. Ref #2497. Ref #2822. --- changelog.d/2497.change.rst | 1 + pkg_resources/__init__.py | 5 +++++ pytest.ini | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 changelog.d/2497.change.rst diff --git a/changelog.d/2497.change.rst b/changelog.d/2497.change.rst new file mode 100644 index 0000000000..91d840f7a7 --- /dev/null +++ b/changelog.d/2497.change.rst @@ -0,0 +1 @@ +Officially deprecated PEP 440 non-compliant versions. diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index c84f1dd9e8..3aafe6525c 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -113,6 +113,11 @@ def parse_version(v): try: return packaging.version.Version(v) except packaging.version.InvalidVersion: + warnings.warn( + f"{v} is an invalid version and will not be supported in " + "a future release", + PkgResourcesDeprecationWarning, + ) return packaging.version.LegacyVersion(v) diff --git a/pytest.ini b/pytest.ini index bdcab1bffb..2678afd846 100644 --- a/pytest.ini +++ b/pytest.ini @@ -31,3 +31,6 @@ filterwarnings= # https://github.com/pypa/setuptools/issues/917 ignore:setup.py install is deprecated. ignore:easy_install command is deprecated. + + # https://github.com/pypa/setuptools/issues/2497 + ignore:.* is an invalid version and will not be supported::pkg_resources