Skip to content

Commit

Permalink
marshall.cachew: better exception in case we fail to get type hints f…
Browse files Browse the repository at this point in the history
…rom type
  • Loading branch information
karlicoss committed Oct 19, 2024
1 parent bf5ced0 commit f01317c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.10'

- uses: actions/checkout@v4
with:
Expand Down
7 changes: 6 additions & 1 deletion src/cachew/marshall/cachew.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,12 @@ def build_schema(Type) -> Schema:

if not (is_dataclass(Type) or is_namedtuple(Type)):
raise TypeNotSupported(type_=Type)
hints = get_type_hints(Type)
try:
hints = get_type_hints(Type)
except TypeError as te:
# this can happen for instance on 3.9 if pipe syntax was used for Union types
# would be nice to provide a friendlier error though
raise TypeNotSupported(type_=Type) from te
fields = tuple((k, build_schema(t)) for k, t in hints.items())
return SDataclass(
type=Type,
Expand Down

0 comments on commit f01317c

Please sign in to comment.