You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In dataclasses, attributes without a default cannot follow attributes with one unless they are keyword-only arguments. By setting the parameter kw_only=True of the dataclass decorator, all fields of the class are marked as keyword-only. By setting the parameter kw_only=True of the field function, the annotated attribute is marked as keyword-only. The problem occurs when an argument with a default is marked as keyword-only by using the field function but not the dataclass decorator, and is followed by another argument without a default. mypy reports an error, but it shouldn't.
Bug Report
In
dataclasses
, attributes without a default cannot follow attributes with one unless they are keyword-only arguments. By setting the parameterkw_only=True
of thedataclass
decorator, all fields of the class are marked as keyword-only. By setting the parameterkw_only=True
of thefield
function, the annotated attribute is marked as keyword-only. The problem occurs when an argument with a default is marked as keyword-only by using thefield
function but not thedataclass
decorator, and is followed by another argument without a default.mypy
reports an error, but it shouldn't.To Reproduce
Playground
Actual Behavior
mypy
finds the following issue:Your Environment
The text was updated successfully, but these errors were encountered: