Skip to content

Wrong "Overloaded function implementation does not accept all possible arguments" #11004

Closed as not planned
@dvarrazzo

Description

@dvarrazzo

Bug Report

The following example (reduced from psycopg 3) seems to be a false positive:

To Reproduce

from typing import Any, Callable, Generic, overload, Optional, TypeVar, Tuple, Union

Row = TypeVar("Row")

class Connection(Generic[Row]):
    @overload
    def connect(
        self, *, row_factory: Callable[[], Row], **kwargs: Union[None, int, str]
    ) -> "Connection[Row]":
        ...

    @overload
    def connect(
        self, **kwargs: Union[None, int, str],
    ) -> "Connection[Tuple[Any, ...]]":
        ...

    def connect(
        self, *, row_factory: Optional[Callable[[], Row]] = None, **kwargs: Any,
    ) -> "Connection[Any]":
        raise NotImplementedError

The file is flagged with the error:

bug_mypy.py:18: error: Overloaded function implementation does not accept all possible arguments of signature 2  [misc]

Your Environment

  • Mypy version used: 0.910
  • Python version used: 3.8
  • Operating system and version: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions