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
Python version (and distribution if applicable, e.g. Anaconda):
python.analysis.indexing: true
python.analysis.typeCheckingMode: off
Code Snippet
importtypingastfromtyping_extensionsimportParamSpec, Concatenate_OriginArgsP=ParamSpec("_OriginArgsP")
_OriginSelfT=t.TypeVar("_OriginSelfT")
_OriginReturnT=t.TypeVar("_OriginReturnT")
_TargetSelfT=t.TypeVar("_TargetSelfT")
_TargetArgsP=ParamSpec("_TargetArgsP")
_NewReturnT=t.TypeVar("_NewReturnT")
@t.overloaddefcopy_method_signature(
origin: t.Callable[Concatenate[_OriginSelfT, _OriginArgsP], _OriginReturnT], *, return_type: None=..., skip_self: t.Literal[False]=...
) ->t.Callable[[t.Callable[Concatenate[_TargetSelfT, _TargetArgsP], t.Any]], t.Callable[Concatenate[_TargetSelfT, _OriginArgsP], _OriginReturnT]]:
"""A method copies the full signature from another method"""@t.overloaddefcopy_method_signature(
origin: t.Callable[Concatenate[_OriginSelfT, _OriginArgsP], _OriginReturnT], *, return_type: type[_NewReturnT], skip_self: t.Literal[False]=...
) ->t.Callable[[t.Callable[Concatenate[_TargetSelfT, _TargetArgsP], t.Any]], t.Callable[Concatenate[_TargetSelfT, _OriginArgsP], _NewReturnT]]:
"""A method copies the parameter signature from another method but overrides the return type"""@t.overloaddefcopy_method_signature(
origin: t.Callable[Concatenate[_OriginSelfT, _OriginArgsP], _OriginReturnT], *, return_type: None=..., skip_self: t.Literal[True]
) ->t.Callable[[t.Callable[_TargetArgsP, t.Any]], t.Callable[_OriginArgsP, _OriginReturnT]]:
"""A function copies the full signature from another method"""@t.overloaddefcopy_method_signature(
origin: t.Callable[Concatenate[_OriginSelfT, _OriginArgsP], _OriginReturnT], *, return_type: type[_NewReturnT], skip_self: t.Literal[True]
) ->t.Callable[[t.Callable[_TargetArgsP, t.Any]], t.Callable[_OriginArgsP, _NewReturnT]]:
"""A function copies the paramater signature from another method but overrides the return type"""@t.no_type_checkdefcopy_method_signature(
origin, *, return_type=None, skip_self=False
):
@t.no_type_checkdefinner(target):
returntargetreturninnerclassA:
@t.overloaddefmethod(self, a: int) ->None:
...
@t.overloaddefmethod(self, a: str) ->int:
...
defmethod(self, a: t.Union[int, str]) ->t.Optional[int]:
...
@copy_method_signature(A.method, return_type=int, skip_self=True)@t.no_type_checkdefhello(*args, **kwargs):
...
reveal_type(hello)
Repro Steps
Hover over the copy_method_signature decorator
Expected behavior
No error
Actual behavior
No overloads for "copy_method_signature" match the provided argumentsPylance[reportCallIssue](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportCallIssue) method.py(31, 5): Overload 4 is the closest match
Hover over the reveal_type call
Expected behaviour
Overload[(a: int) -> int, (a: str) -> int] as pointed out by pyright in the command line: method.py:64:13 - information: Type of "hello" is "Overload[(a: int) -> int, (a: str) -> int]" 0 errors, 0 warnings, 1 information
Actual behaviour
Type of "hello" is "(...) -> None"
Logs
XXX
The text was updated successfully, but these errors were encountered:
thanks for the report. pylance didn't get update last week and I think pyright recently updated its overload logic, so I'm guessing that is the reason for the disagreement. In the mean time you can check which version of pyright pylance is using in the python language server output window.
Environment data
Code Snippet
Repro Steps
copy_method_signature
decoratorExpected behavior
No error
Actual behavior
No overloads for "copy_method_signature" match the provided argumentsPylance[reportCallIssue](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportCallIssue) method.py(31, 5): Overload 4 is the closest match
reveal_type
callExpected behaviour
Overload[(a: int) -> int, (a: str) -> int]
as pointed out by pyright in the command line:method.py:64:13 - information: Type of "hello" is "Overload[(a: int) -> int, (a: str) -> int]" 0 errors, 0 warnings, 1 information
Actual behaviour
Type of "hello" is "(...) -> None"
Logs
The text was updated successfully, but these errors were encountered: