Closed as not planned
Closed as not planned
Description
Bug Report
It's documented that a dataclass field can be declared as optional without Optional
or | None
by simply assigning None
as a default value.
However, mypy fails to infer this.
To Reproduce
import dataclasses as dc
@dc.dataclass
class C:
j: int = None
Expected Behavior
No errors
Actual Behavior
test.py:6: error: Incompatible types in assignment (expression has type "None", variable has type "int")
Your Environment
- Mypy version used: 0.982
- Python version used: 3.10.7