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
fromtyping_extensionsimportProtocolclassFunc(Protocol):
def__call__(self, __a: int, **kwargs: str) ->None:
# ^^^ positional-only arg
...
# Same error when using PEP 570 positional-only syntax:# def __call__(self, a: int, /, **kwargs: str) -> None:defmyfunc(a: int, **kwargs: str) ->None:
passf: Func=myfunc
Expected Behavior
In my view this should be allowed. Anyone calling f() promises to pass the 1st argument as positional. And myfunc accepts the 1st argument as positional or kwarg, so it should be considered compatible.
Actual Behavior
Mypy output:
positional_only.py:12: error: Incompatible types in assignment (expression has type "Callable[[int, KwArg(str)], Any]", variable has type "Func")
positional_only.py:12: note: "Func.__call__" has type "Callable[[int, KwArg(str)], Any]"
Your Environment
Mypy version used: 0.942
Mypy command-line flags: (none)
Mypy configuration options from mypy.ini (and other config files): (none)
Python version used: 3.10.2
Operating system and version: macOS
The text was updated successfully, but these errors were encountered:
Bug Report
Expected Behavior
In my view this should be allowed. Anyone calling
f()
promises to pass the 1st argument as positional. And myfunc accepts the 1st argument as positional or kwarg, so it should be considered compatible.Actual Behavior
Mypy output:
Your Environment
mypy.ini
(and other config files): (none)The text was updated successfully, but these errors were encountered: