Skip to content

Commit

Permalink
Use first argument of Annotated in string representation
Browse files Browse the repository at this point in the history
  • Loading branch information
cswartzvi committed Feb 8, 2025
1 parent 7f4bc66 commit ace24a3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hamilton/htypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def get_type_as_string(type_: Type) -> Optional[str]:
:return: string representation of the type. An empty string if everything fails.
"""

if getattr(type_, "__name__", None):
if typing.get_origin(type_) is Annotated: # differs from typing_inspect.get_origin
type_string = get_type_as_string(typing.get_args(type_)[0])
elif getattr(type_, "__name__", None):
type_string = type_.__name__
elif typing_inspect.get_origin(type_):
base_type = typing_inspect.get_origin(type_)
Expand Down

0 comments on commit ace24a3

Please # to comment.