Typing: DataclassProtocol.__dataclass_fields__ should be ClassVar
Closed this issue · 1 comments
peterschutt commented
Defined here:
# Remember all of the fields on our class (including bases). This
# also marks this class as being a dataclass.
setattr(cls, _FIELDS, fields)
Where _FIELDS
is:
# The name of an attribute on the class where we store the Field
# objects. Also used to check if a class is a Data Class.
_FIELDS = '__dataclass_fields__'
I ran into this when trying to use the types in Starlite:
/home/peter/PycharmProjects/starlite/starlite/types/partial.py
/home/peter/PycharmProjects/starlite/starlite/types/partial.py:137:49 - error: Protocol class "DataclassProtocol" does not define "__dataclass_fields__" as a ClassVar (reportGeneralTypeIssues)
peterschutt commented
Turns out this isn't as clear cut as it seems: python/typing#1056 (reply in thread)
Prob just better to side with mypy and leave as is.