anthropic-sdk-python icon indicating copy to clipboard operation
anthropic-sdk-python copied to clipboard

Fix construct_type() crash on bare list/dict types

Open PHclaw opened this issue 5 months ago • 0 comments

Summary

\construct_type()\ crashes when given bare generic types (without type parameters):

  1. bare \list\ → \IndexError\ at \rgs[0]\
  2. bare \dict\ → \ValueError\ at _, items_type = get_args(type_)\

Fix

Both branches now guard against missing type arguments and return the value unchanged.

  • \dict\ branch: guard with \if len(args_tuple) < 2: return value\
  • \list\ branch: guard with \if not args: return value\

Fixes #1626. Fixes #1619.

PHclaw avatar Jun 04 '26 07:06 PHclaw