In theory, dataclasses are dumb structs but with InitVar it is possible to process parameters before assigning to attributes or have attributes created in __post_init__.
In this library there's mostly basic coercing of a more general input type to the type in class internal storage. By itself, this could be documented at library level as a special case on the names (x_ → x) but types can still differ and that would have to be documented. Also, having a special case makes understanding complicated cases even more complicated.
For example, fields.Mesh.points is either simply converted from points_InitVar in the case of NonGridMesh or created from other input arguments in the case of GridMesh.
I'm not sure what could be a good solution, for now I'll document the attributes referring the user to the docs for __init__. I don't think an established solution exists due to dataclasses being a new thing.
In theory, dataclasses are dumb structs but with
InitVar
it is possible to process parameters before assigning to attributes or have attributes created in__post_init__
.In this library there's mostly basic coercing of a more general input type to the type in class internal storage. By itself, this could be documented at library level as a special case on the names (
x_
→x
) but types can still differ and that would have to be documented. Also, having a special case makes understanding complicated cases even more complicated.For example,
fields.Mesh.points
is either simply converted frompoints_
InitVar
in the case ofNonGridMesh
or created from other input arguments in the case ofGridMesh
.I'm not sure what could be a good solution, for now I'll document the attributes referring the user to the docs for
__init__
. I don't think an established solution exists due todataclasses
being a new thing.