Skip to content

Nested empty container gets inferred to object #5045

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.

Activity

  1. changed the title [-]Nested container gets inferred to `object`[/-] [+]Nested empty container gets inferred to `object`[/+] on May 14, 2018
  2. ilevkivskyi commented on May 14, 2018

    @ilevkivskyi
    Member

    Yes, looks like a bug in join.

  3. AlexWaygood commented on Apr 3, 2022

    @AlexWaygood
    Member

    Closing as a duplicate of #2255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions