Skip to content

BUG: construct_type() raises IndexError when called with bare unparameterized list #1626

@devteamaegis

Description

@devteamaegis

Calling `construct_type(value=[...], type_=list)` raises `IndexError: tuple index out of range`.

The `origin == list` branch in `src/anthropic/_models.py` (line 671) unconditionally executes `inner_type = args[0]`, but `get_args(list)` returns an empty tuple when no type parameter is present, so the index access fails.

Minimal repro:

```python
from anthropic.models import construct_type
construct_type(value=["a", "b", "c"], type
=list)
```

Full traceback:

```
File ".../src/anthropic/_models.py", line 671, in construct_type
inner_type = args[0] # List[inner_type]
~~~~^^^
IndexError: tuple index out of range
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions