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
Creating a type variable that uses another type variable in its bound type creates an error even if the bound type is not generic within the scope of the type variable.
Sidenote: Not sure if this is another bug but I have set typeCheckingMode to "off" and I am still seeing this error.
To Reproduce
from abc import ABC
from typing import Generic, TypeVar
R = TypeVar("R", bound="AbstractRepository")
class AbstractRepository(ABC):
pass
class AbstractUnitOfWork(ABC, Generic[R]):
repo: R
T = TypeVar("T", bound="AbstractUnitOfWork[R]")
def commit(self: T) -> T:
return self
I get an error saying "TypeVar bound type cannot be generic" when defining T even though AbstractUnitOfWork[R] is not a generic type in this context.
Expected behavior
No error.
VS Code extension or command-line
I am running Pyright within Neovim. The version is 1.1.248
The text was updated successfully, but these errors were encountered:
The error is correct. Bound types cannot be generic. They must be concrete. There has been talk of supporting "higher-kinded types" (HKTs) within the Python type system, which would add support for this. But so far, these discussions have not led to any proposals among the type community.
Describe the bug
Creating a type variable that uses another type variable in its bound type creates an error even if the bound type is not generic within the scope of the type variable.
Sidenote: Not sure if this is another bug but I have set
typeCheckingMode
to"off"
and I am still seeing this error.To Reproduce
I get an error saying "TypeVar bound type cannot be generic" when defining
T
even thoughAbstractUnitOfWork[R]
is not a generic type in this context.Expected behavior
No error.
VS Code extension or command-line
I am running Pyright within Neovim. The version is
1.1.248
The text was updated successfully, but these errors were encountered: