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
using a decorator on an overloaded function where the decorator uses Concatenate causes false positive "Overloaded function implementation does not accept all possible arguments" error #17459
fromtypingimportCallable, Concatenate, TypeVar, overload, ParamSpecT=TypeVar("T")
P=ParamSpec("P")
R=TypeVar("R")
deffoo(fn: Callable[Concatenate[T, P], R]) ->Callable[Concatenate[T, P], R]:
returnfnclassFoo:
@overloaddefbar(self, a: str) ->str: ...
@overloaddefbar(self, a: int) ->int: ...
# error: Overloaded function implementation does not accept all possible arguments of signature 1# error: Overloaded function implementation does not accept all possible arguments of signature 2@foodefbar(self, a: object) ->object: ...
There was a discussion about this in the typing forum. The general consensus was aligned with this viewpoint, and this is what I've implemented in pyright, but this hasn't yet been formally incorporated into the typing spec. You're welcome to add your input to the discussion thread.
Activity
ilevkivskyi commentedon Jul 1, 2024
This is because
foo()destroys the argument name for the first argument. Internally, I see the inferred type for implementation isso it cannot accept call like
Foo.bar(self=Foo(), a=1). This seems way too pedantic however.DetachHead commentedon Jul 12, 2024
imo
selfshould be implicitly positional only. i can't think of a case where you'd want to specify it as a keyword argumenterictraut commentedon Jul 12, 2024
There was a discussion about this in the typing forum. The general consensus was aligned with this viewpoint, and this is what I've implemented in pyright, but this hasn't yet been formally incorporated into the typing spec. You're welcome to add your input to the discussion thread.