Open eltoder opened 1 year ago
Also, if I change y
to use direct assignment instead of using field
, the second error disappears:
class C:
x: dict[str, int] | None = field(default_factory=dict)
y: V[int] | None = V() # no error this way
Here's a workaround that type checks without errors:
class C:
x: dict[str, int] | None = field(default_factory=dict[str, int])
y: V[int] | None = field(default=V[int]())
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=bcf4de945268517a0cd8b6b9835e852f
Expected Behavior
This should produce no errors.
Actual Behavior
If I remove
| None
, mypy works as expected. However, AFAICT, outside of dataclasses such assignments are accepted.Your Environment