Skip to content

Error initializing Union of Lists with an empty list #2164

Closed
@elazarg

Description

@elazarg

The following test case

[case testUnionListInit]
from typing import Union, List
a = []  # type: Union[List[int], List[str]]
[builtins fixtures/list.pyi]

Results in

Expected:
Actual:
  main:2: error: Incompatible types in assignment (expression has type List[None], variable has type "Union[List[int], List[str]]") (diff)

This came up during PR #2154, but I think is an independent issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions