You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
erroneous complaint that overloaded function implementation does not accept all possible arguments of signature #18596
$ mypy typing_bug.py
typing_bug.py:16: error: Overloaded functionimplementation 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.
fromtypingimportoverload@overloaddefset(year: int) ->None:
...
@overloaddefset() ->None:
...
defset(*args: object|int, **kw: int) ->None: # E: Overloaded function implementation does not accept all possible arguments of signature 1pass
If you remove the object | then it passes type checking.
The very wish-washy answer is that it's because "is this implementation alright" uses a generalized subtype check, so there's not the available information. I think mypy could definitely provide more provenance information though.
Activity
cjw296 commentedon Feb 4, 2025
If I change the implemention to this, mypy is happy:
But that's not correct: it's never valid to pass a datetime as a keyword parameter, note the "positional argument only" marker in signature 2.
The following also make mypy happy, but doesn't match the behaviour I need:
A5rocks commentedon Feb 4, 2025
Smaller reproducer:
If you remove the
object |then it passes type checking.cjw296 commentedon Feb 4, 2025
The error message is also frustratingly poor: why not specify which types are missing from the implementation? :-/
A5rocks commentedon Feb 7, 2025
The very wish-washy answer is that it's because "is this implementation alright" uses a generalized subtype check, so there's not the available information. I think mypy could definitely provide more provenance information though.
cjw296 commentedon Jul 8, 2025
Summary question (and hopefully eventually a thread!) on related problems:
python/typing#2040