Closed
Description
Connected to #1399
Seems still an issue with classmethod's overloads at least (this is from python/pylance extension):
class classmethod(Generic[_T, _P, _R_co]):
...
@overload
def __get__(self, __instance: _T, __owner: type[_T] | None = None) -> Callable[_P, _R_co]: ...
@overload
def __get__(self, __instance: None, __owner: type[_T]) -> Callable[_P, _R_co]: ...`
...
Order of overloads does not matter
If i use it:
def trace_class_method(_classmethod: classmethod[T, P, R_co]) -> classmethod[T, P, R_co]:
@wraps(_classmethod.__func__)
def wrapper(_cls: type[T], *args: P.args, **kwargs: P.kwargs) -> R_co:
method = _classmethod.__get__(None, _cls) # type: ignore[arg-type]
return _log_trace(method, *args, **kwargs)
return classmethod(wrapper) # type: ignore[arg-type]
The _classmethod.__get__
doesn't seem to use correct overload.
On top of that there is another issue with return classmethod(wrapper)
(could be connected to #3482)
- Mypy version used: 1.5.1
- Python version used: 3.10.2
- Pylance version: ms-python.vscode-pylance-2023.9.10