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

Make configuration more reliable with stronger typing #35

Open
riley-harper opened this issue Aug 2, 2022 · 1 comment
Open

Make configuration more reliable with stronger typing #35

riley-harper opened this issue Aug 2, 2022 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@riley-harper
Copy link
Contributor

We've thought about making use of Rust for this, because the way it handles this stuff is abserdely cool. The more free parsing of Python may make this change hard to do in a completely backwards-compatible manner. Some TOML formatting issues that the Python parser handles might cause errors when parsed with Rust.

The general idea is to use maturin to build the Rust crate as a Python module, then call that module from existing Python to parse the hlink config file. We could use the Rust toml crate, which has support for defining the configuration as a Rust struct with derive macros. With some magic from the Rust serde crate, we can parse an enumeration like comparison types without any changes to the current configuration format.

@riley-harper riley-harper added the enhancement New feature or request label Aug 2, 2022
@riley-harper riley-harper changed the title Make configuration safer with stronger typing Make configuration more reliable with stronger typing Aug 3, 2022
@riley-harper
Copy link
Contributor Author

I recently discovered the dacite Python package, which seems like just the tool to be able to do this parsing and validation in Python without needing to add in a Rust component. The typing isn't as strict as Rust, but we get to keep everything in Python. I think that dacite is a better choice than serde + Rust at the moment.

This issue is tied to the fact that we're using an old, out-of-date TOML parser, but it can be worked on separately. This layer goes from a dictionary to an internal representation of a configuration. The TOML parser goes from a file to a dictionary.

@riley-harper riley-harper modified the milestone: v4.0.0 Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant