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
@classmethod complaining about the first cls
non-optional argument
#7662
Comments
Definitions of class classmethod(Generic[_T, _P, _R_co]):
@property
def __func__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ...
@property
def __isabstractmethod__(self) -> bool: ...
def __init__(self, f: Callable[Concatenate[type[_T], _P], _R_co], /) -> None: ...
@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]: ...
if sys.version_info >= (3, 10):
__name__: str
__qualname__: str
@property
def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... |
I'm not able to repro this issue. My best guess is that you have a really old, stale version of I'm pretty confident this isn't a bug in pyright, so I'm going to close the issue. |
My typing_extensions is latest:
|
There is something wrong with the If i monkey patch the Replace this: def __init__(self, f: Callable[Concatenate[type[_T], _P], _R_co], /) -> None: ... With: def __init__(self, f: Callable[..., _R_co], /) -> None: ... Then the error goes away. It looks like Concatenate is always resolving to My typesheds in VS Code come from:
But the same errors also happen in CLI which is installed by
|
|
Another monkey patch that makes the error go away is to import Got the idea from: python/typing_extensions#48 |
It sounds like something in your current environment is corrupt. Have you tried creating a clean virtual environment as I suggested above? Do you have a typing-extensions stub library installed? Those would override the stubs that ship with pyright or pylance. |
Perhaps I misunderstood what you meant by clean environment. I cleaned it but re-produced it from my See here: If I dial this back to just |
Tracked it down to |
Describe the bug
I can't seem to define a class method that accepts the
cls
parameter. PyRight flags it as a type error.Code or Screenshots
If possible, provide a minimal, self-contained code sample (surrounded by triple back ticks) to demonstrate the issue. The code should define or import all referenced symbols.
I get this error:
VS Code extension or command-line
Both CLI and VS Code have the same problem.
The text was updated successfully, but these errors were encountered: