Skip to content

erroneous complaint that overloaded function implementation does not accept all possible arguments of signature #18596

Open
@cjw296

Description

@cjw296

Bug Report

Erroneous complaint that overloaded function implementation does not accept all possible arguments of signature.

To Reproduce

from datetime import datetime
from typing import overload

class Sample:

    @overload
    @classmethod
    def set(cls, year: int) -> None:
        ...

    @overload
    @classmethod
    def set(cls, instance: datetime, / ) -> None:
        ...

    @classmethod
    def set(cls, *args: datetime | int, **kw: int) -> None:
        pass

Expected Behavior

The above should pass type checking.

Pyright's happy enough:

$ pyright typing_bug.py 
0 errors, 0 warnings, 0 informations 

Actual Behavior

$ mypy typing_bug.py 
typing_bug.py:16: error: Overloaded function implementation does not accept all possible arguments of signature 1  [misc]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.14.1 (compiled: yes)
  • Mypy command-line flags: None, see above
  • Mypy configuration options from mypy.ini (and other config files): None.
  • Python version used: Python 3.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions