Skip to content

Error initializing Union of Lists with an empty list #2164

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.

Activity

  1. changed the title [-]Error [/-] [+]Error initializing Union of Lists with an empty list[/+] on Sep 21, 2016
  2. elazarg commented on Sep 21, 2016

    @elazarg
    ContributorAuthor

    Perhaps related to binder.py#L189?

  3. gvanrossum commented on Sep 21, 2016

    @gvanrossum
    Member

    Doesn't sound like a very important issue, the example has questionable value. (I'm not saying it's not a bug -- just that I don't think it's urgent to fix it.)

  4. added this to the milestone on Sep 21, 2016
  5. removed this from the milestone on Mar 29, 2017
  6. JukkaL commented on Mar 29, 2019

    @JukkaL
    Collaborator

    Closing in favor of duplicate #6463 (the latter issue has a slight more interesting example).

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