mypy keeps saying Cannot determine type on a self-referential dataclass
Python 3.11, mypy 1.8. I have a dataclass with an optional field pointing to the same class and mypy says error: Cannot determine type of 'parent' [has-type]. I've added from __future__ import annotations like the docs say. Runtime works fine, the code does what it should. Is this a mypy bug or am I annotating it wrong? Field is parent: Optional['Node'] = None.
4 replies