Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace format_template() function by Binder.format_toml_template() method #23

Merged
merged 7 commits into from
Jun 29, 2023

Conversation

mthuurne
Copy link
Member

Closes #17

mthuurne added 7 commits June 27, 2023 16:21
This should enable code simplifications in the future.

For now, there is one functional change: it is no longer allowed
to pass a dataclass which contains types or constructs that are
not supported by `Binder`. I don't think this will prevent any
likely real-world workflows.
This is preparation for adding more class info.
To fetch these we need to parse the source file, so that's an amount
of work that we'd rather do just once.
The `_format_value_for_field()` function had a lot of overlap with
`_get_fields()` and re-using `field_types` for formatting not only
removes the duplicate code but also saves work.
We have `parse_toml()`, so it's consistent to also be explicit in
output methods.

And if we ever add JSON support, it's necessary to be explicit.
@mthuurne mthuurne merged commit dc26705 into main Jun 29, 2023
@mthuurne mthuurne deleted the format-template-method branch June 29, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow instantiating a Binder from a dataclass instance
1 participant