Skip to content

Commit ace24a3

Browse files
committed
Use first argument of Annotated in string representation
1 parent 7f4bc66 commit ace24a3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hamilton/htypes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def get_type_as_string(type_: Type) -> Optional[str]:
9999
:return: string representation of the type. An empty string if everything fails.
100100
"""
101101

102-
if getattr(type_, "__name__", None):
102+
if typing.get_origin(type_) is Annotated: # differs from typing_inspect.get_origin
103+
type_string = get_type_as_string(typing.get_args(type_)[0])
104+
elif getattr(type_, "__name__", None):
103105
type_string = type_.__name__
104106
elif typing_inspect.get_origin(type_):
105107
base_type = typing_inspect.get_origin(type_)

0 commit comments

Comments
 (0)