Skip to content

Fix construct_type() crash on bare list/dict types#1643

Open
PHclaw wants to merge 1 commit into
anthropics:mainfrom
PHclaw:fix/bare-list-dict-construct-type
Open

Fix construct_type() crash on bare list/dict types#1643
PHclaw wants to merge 1 commit into
anthropics:mainfrom
PHclaw:fix/bare-list-dict-construct-type

Conversation

@PHclaw

@PHclaw PHclaw commented Jun 4, 2026

Copy link
Copy Markdown

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.

Fix IndexError when origin==list with no type args (e.g. list instead
of list[T]).
Fix ValueError when origin==dict with no type args (e.g. dict instead
of dict[K, V]).

Fixes anthropics#1626 (bare list).
Fixes anthropics#1619 (bare dict).
@PHclaw PHclaw requested a review from a team as a code owner June 4, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant