-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Would it be possible to broaden classmethod to accept ParamSpec when MyPy's support is better? #7689
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
Comments
This is on my to-do list for as soon as mypy 0.950 is released 🙂 |
Though I'm not sure how much of a difference this will make, considering how thoroughly type checkers special case classmethod (and staticmethod). |
Also, import sys
from typing import TypeVar, Callable, Generic
from typing_extensions import ParamSpec, Concatenate
_P = ParamSpec("_P")
_R_co = TypeVar("_R_co", covariant=True)
_T = TypeVar("_T")
class classmethod(Generic[_P, _R_co, _T]):
@property
def __func__(self) -> Callable[Concatenate[_T, _P], _R_co]: ...
@property
def __isabstractmethod__(self) -> bool: ...
def __init__(self: classmethod[_P, _R_co, _T], __f: Callable[Concatenate[_T, _P], _R_co]) -> None: ...
def __get__(self, __obj: _T | None, __type: type[_T] | None = ...) -> Callable[_P, _R_co]: ...
if sys.version_info >= (3, 10):
__name__: str
__qualname__: str
@property
def __wrapped__(self) -> Callable[Concatenate[_T, _P], _R_co]: ... |
@JelleZijlstra Yup, I just learned about that here. It's not too big a deal since it's very rare that you decorate class methods, but maybe after |
Mypy 0.950 is now out, but sadly we still cannot use |
It could be something like:
The text was updated successfully, but these errors were encountered: