Skip to content

Commit

Permalink
fix: catch pkg error and reraise
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Jul 5, 2024
1 parent 4071a93 commit da368f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dep_logic/specifiers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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__ = [
Expand Down

0 comments on commit da368f0

Please sign in to comment.