equinox
equinox copied to clipboard
MyPy doesn't understand Module
MyPy only looks at the first definition of Module, so it doesn't see the redefinition in TYPE_CHECKING:
import dataclasses
from typing import TYPE_CHECKING, dataclass_transform
class _ModuleMeta(type): # This needs to be in a if not TYPE_CHECKING block.
pass
if TYPE_CHECKING:
@dataclass_transform(field_specifiers=(dataclasses.field,))
class _ModuleMeta(type):
pass
class Module(metaclass=_ModuleMeta):
pass
class A(Module):
x: int
A(1) # MyPy doesn't realize that A is a dataclass
Ah -- this must be a mypy vs pyright difference.
Happy to take a PR on this :)
Fixed in #822 :)