Skip to content

No error for overlapping overloads that vary in parameters with default values #19803

@brianschubert

Description

@brianschubert

Bug Report

Mypy doesn't complain that the following overloads overlap with incompatible return types, but probably should:

from typing import  overload

@overload
def foo(*, a: str = ...) -> str: ...
@overload
def foo(*, a: int | str = ...) -> int: ...

For comparison, pyright emits a diagnostic here (playground). Mypy does emit an error if a default value for a is omitted in either overload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions