From da368f0960ef896a05146b068b1c4de2138bd23d Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Fri, 5 Jul 2024 11:04:01 +0800 Subject: [PATCH] fix: catch pkg error and reraise Signed-off-by: Frost Ming --- src/dep_logic/specifiers/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dep_logic/specifiers/__init__.py b/src/dep_logic/specifiers/__init__.py index 0a2ec69..8cd9441 100644 --- a/src/dep_logic/specifiers/__init__.py +++ b/src/dep_logic/specifiers/__init__.py @@ -4,6 +4,7 @@ import itertools import operator +from packaging.specifiers import InvalidSpecifier as PkgInvalidSpecifier from packaging.specifiers import Specifier, SpecifierSet from packaging.version import Version @@ -109,7 +110,12 @@ def parse_version_specifier(spec: str) -> BaseSpecifier: return functools.reduce( operator.or_, map(parse_version_specifier, spec.split("||")) ) - return from_specifierset(SpecifierSet(spec)) + try: + pkg_spec = SpecifierSet(spec) + except PkgInvalidSpecifier as e: + raise InvalidSpecifier(str(e)) from e + else: + return from_specifierset(pkg_spec) __all__ = [