Skip to content

Nested empty container gets inferred to object #5045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alanhdu opened this issue May 14, 2018 · 2 comments
Closed

Nested empty container gets inferred to object #5045

alanhdu opened this issue May 14, 2018 · 2 comments
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-join-v-union Using join vs. using unions

Comments

@alanhdu
Copy link
Contributor

alanhdu commented May 14, 2018

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.

@alanhdu alanhdu changed the title Nested container gets inferred to object Nested empty container gets inferred to object May 14, 2018
@ilevkivskyi
Copy link
Member

Yes, looks like a bug in join.

@AlexWaygood
Copy link
Member

Closing as a duplicate of #2255

@JelleZijlstra JelleZijlstra added the topic-join-v-union Using join vs. using unions label Apr 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-join-v-union Using join vs. using unions
Projects
None yet
Development

No branches or pull requests

4 participants