With the following function:
from typing import ClassVar
def overrode_make_stub(cls: ClassVar["Emailer"]) -> bool:
return not (getattr(cls.make_stub, "_not_overridden", False))
I’m getting this error from Pylance in Visual Studio Code:
"ClassVar" is not allowed in this context
I’m using Python3.9 and Pylance v2021.10.0.
In this example the Email class has a "make_stub" function, which has a _not_overriden attribute set to True. When I inspect a module for subclasses of that class I can use this to filter only the ones that overrode the "make_sub" function.
I can’t find any documentation on this error. Does anyone know why it’s coming up?