Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloads with None still doesn't work for pylance core. #16136

Closed
smsteel opened this issue Sep 18, 2023 · 2 comments
Closed

Overloads with None still doesn't work for pylance core. #16136

smsteel opened this issue Sep 18, 2023 · 2 comments
Labels
bug mypy got something wrong

Comments

@smsteel
Copy link

smsteel commented Sep 18, 2023

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
@smsteel smsteel added the bug mypy got something wrong label Sep 18, 2023
@smsteel
Copy link
Author

smsteel commented Sep 22, 2023

@smsteel
Copy link
Author

smsteel commented Sep 22, 2023

Overloads do work, problem is mypy typeshed

@smsteel smsteel closed this as completed Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant