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
{{ message }}
Repository navigation
False positive: comparison-overlap with dataclasses.Field.default_factory and dataclasses.MISSING #12124
In code which is checking if a field has a default, a check to see if Field.default_factory is MISSING will be misreported as a comparison-overlap error if mypy --strict is used.
This looks like a bug in the typeshed stub dataclasses.pyi. The type annotations for Field.default and Field.default_factory should probably be unions that include the type _MISSING_TYPE.
Good point! I didn't think to look at typeshed -- I thought mypy was doing something weird.
I'll put in a PR to update it. Assuming that's right and my patch is accepted, I'll close this when that's merged.
Activity
erictraut commentedon Feb 4, 2022
This looks like a bug in the typeshed stub
dataclasses.pyi. The type annotations forField.defaultandField.default_factoryshould probably be unions that include the type_MISSING_TYPE.sirosen commentedon Feb 4, 2022
Good point! I didn't think to look at typeshed -- I thought
mypywas doing something weird.I'll put in a PR to update it. Assuming that's right and my patch is accepted, I'll close this when that's merged.
hauntsaninja commentedon Feb 4, 2022
There isn't any action for mypy, so closing. Current plan is to use the literal trick in typeshed: python/typeshed#7127