ProtixIT / dataclass-binder

Python library to bind TOML data to dataclasses in a type-safe way
MIT License
13 stars 2 forks source link

Add support for `InitVar` #9

Open mthuurne opened 1 year ago

mthuurne commented 1 year ago

The InitVar annotation defines a value that is passed as an argument to __init__() and then to __post_init__() but does not exist as a field on the dataclass instance. This is roughly the opposite of init=False, where the field does exist but there is no matching argument of __init__().

As there is an __init__() argument, we could actually bind values to it. But the Binder specialization needs to be extended to support it.

mthuurne commented 1 year ago

The template formatting would also need to include InitVar arguments in its output.