Skip to content

Commit 06cf9f2

Browse files
committed
marshall.cachew: better exception in case we fail to get type hints from type
1 parent bf5ced0 commit 06cf9f2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868

6969
- uses: actions/setup-python@v5
7070
with:
71-
python-version: '3.8'
71+
python-version: '3.10'
7272

7373
- uses: actions/checkout@v4
7474
with:

src/cachew/marshall/cachew.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,12 @@ def build_schema(Type) -> Schema:
331331

332332
if not (is_dataclass(Type) or is_namedtuple(Type)):
333333
raise TypeNotSupported(type_=Type)
334-
hints = get_type_hints(Type)
334+
try:
335+
hints = get_type_hints(Type)
336+
except TypeError as te:
337+
# this can happen for instance on 3.9 if pipe syntax was used for Union types
338+
# would be nice to provide a friendlier error though
339+
raise TypeNotSupported(type_=Type) from te
335340
fields = tuple((k, build_schema(t)) for k, t in hints.items())
336341
return SDataclass(
337342
type=Type,

0 commit comments

Comments
 (0)