Skip to content

Commit

Permalink
🔧 Improved error handling when type is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Oct 8, 2023
1 parent e1b6e50 commit 3b439da
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion funcchain/utils/function_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def get_output_type() -> type:
"""
Get the output type annotation of the parent caller function.
"""
return (caller_frame := get_parent_frame()).frame.f_globals[caller_frame.function].__annotations__["return"]
try:
return (caller_frame := get_parent_frame()).frame.f_globals[caller_frame.function].__annotations__["return"]
except KeyError:
raise ValueError("The funcchain must have a return type annotation")


def parser_for(output_type: type) -> BaseOutputParser:
Expand Down

0 comments on commit 3b439da

Please sign in to comment.