From b043035f8941006ee7ff5efad694ba57e8ce3c3b Mon Sep 17 00:00:00 2001 From: Keshav Priyadarshi Date: Wed, 30 Aug 2023 02:28:37 +0530 Subject: [PATCH 1/2] Handle NoneType in VersionRange.from_string Signed-off-by: Keshav Priyadarshi --- src/univers/version_range.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/univers/version_range.py b/src/univers/version_range.py index 37138aae..dd1747d9 100644 --- a/src/univers/version_range.py +++ b/src/univers/version_range.py @@ -98,6 +98,9 @@ def from_string(cls, vers, simplify=False, validate=False): Return a VersionRange built from a ``vers`` version range spec string, such as "vers:npm/1.2.3,>=2.0.0" """ + if not vers or not isinstance(vers, str) or not vers.strip(): + raise ValueError("A vers string argument is required.") + # Spaces are not significant and removed in a canonical form. vers = remove_spaces(vers) From 9e1b417dc81c3211f170160b74c9bd9adb61d822 Mon Sep 17 00:00:00 2001 From: Keshav Priyadarshi Date: Wed, 30 Aug 2023 13:41:11 +0530 Subject: [PATCH 2/2] Address review comments Signed-off-by: Keshav Priyadarshi --- src/univers/version_range.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/univers/version_range.py b/src/univers/version_range.py index dd1747d9..399212ad 100644 --- a/src/univers/version_range.py +++ b/src/univers/version_range.py @@ -99,7 +99,9 @@ def from_string(cls, vers, simplify=False, validate=False): such as "vers:npm/1.2.3,>=2.0.0" """ if not vers or not isinstance(vers, str) or not vers.strip(): - raise ValueError("A vers string argument is required.") + raise ValueError( + f"{vers!r} is not a valid argument, a valid ``vers`` string argument is required." + ) # Spaces are not significant and removed in a canonical form. vers = remove_spaces(vers)