Skip to content

Literals overlap when defaults given #6580

Closed
@llchan

Description

@llchan

It appears that Literals with default values lead to overlapping signatures. In the following example, the defaults are necessary since this argument follows another defaulted argument.

  • Are you reporting a bug, or opening a feature request? bug
  • Please insert below the code you are checking with mypy.
    @overload
    def foo(x: int = 0, y: Literal[False] = False) -> int: ...
    @overload
    def foo(x: int = 0, y: Literal[True] = True) -> str: ...
    @overload
    def foo(x: int = 0, y: bool = False) -> Union[int, str]: ...
  • What is the actual behavior/output?
    Overloaded function signatures 1 and 2 overlap with incompatible return types
    
  • What is the behavior/output you expect?
    No error
  • What are the versions of mypy and Python you are using?
    mypy 0.680+dev.4e0a1583aeb00b248e187054980771f1897a1d31 (current master)
    CPython 3.7.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions