Subclassing from pandera.api.dataframe.model.DataFrameModel
errors on annotated but not initialized fields starting with an underscore
#1765
Labels
bug
Something isn't working
Describe the bug
If I create a generic subclass of
pandera.api.dataframe.model.DataFrameModel
that has an uninitialized, annotated field starting with an underscore, and try to instantiate it with concrete type parameters,DataFrameModel.__class_getitem__
throws an error when it tries to collect the fields here.Code Sample, a copy-pastable example
The last line raises the following error:
Expected behavior
The field shouldn't be collected since it starts with an underscore.
Desktop (please complete the following information):
Additional context
It seems like
_foo
is never in the dictattrs = cls._get_model_attrs()
, since that checks through the__dict__
s of the superclasses, but_foo
isn't initialized, so it's not there.Maybe we should filter out non-fields from the
annotations
dict as well.The text was updated successfully, but these errors were encountered: