Fix Context injection crash with return type annotations

Closed
SA
3mo ago
+8-0

Summary

Fixes #3298

  • typing.get_type_hints() includes a "return" key when the function has a return annotation, but inspect.signature().parameters does not — iterating over the hints dict caused a KeyError when looking up "return" in the parameter list
  • Added a check to skip keys from get_type_hints() that aren't in signature.parameters, fixing the crash without altering Context injection behavior

Test plan

  • Functions with -> ReturnType annotations no longer crash during context injection
  • Context parameters are still correctly identified and injected
  • Functions without return annotations unaffected