Skip to content

Nested empty container gets inferred to object #5045

Closed
@alanhdu

Description

@alanhdu

Using mypy 0.600, running mypy on

x = [[], [1, 2], [3, 4]]
reveal_type(x)

shows

test.py:2: error: Revealed type is 'builtins.list[builtins.object*]'

If this doesn't have the empty list, then mypy infers 'builtins.list[builtins.list*[builtins.int]]' for

x = [[1, 2], [3, 4]]
reveal_type(x)

Ideally, mypy would be able to infer List[List[int]] even when there's an empty list.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions