Skip to content

Overlapping unions creates issues with inference #7579

Description

@yilinwei
  • version: 7.3.0

When creating a union which has overlapping types, the inference fails. Either this should throw an error, or it should be inferred correctly.

from typing import TypeVar, Union, Iterable, List

T = TypeVar("T")

def foo(test: Union[T, List[T]]):
    pass

foo([1]) # Fails with incompatible type List[<nothing>]
  • Example of misuse here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions