Skip to content

Convert templates to python functions, TorEnviron to dataclass, and reorg data

Jim Newsome requested to merge jnewsome/chutney:un-template2 into main

At a high level this refactoring is meant to take advantage of relatively recent Python features like type annotations and checking and f-strings formatting.

Moving from the dict-like Environments to putting everything in fields lets us get more mileage out of type annotations and checking, and drops some implementation complexity in Environments.

Converting the torrc templates into executable Python code (leveraging f-strings) likewise lets us drop our bespoke formatting code, and gives us more flexibility in the "templates" to have a little bit of logic and type conversions.

Moving fields out of NodeConfig (previously TorEnviron) that aren't meant to be set by the user/network-script makes it a bit clearer which fields are meant to be configured and which are generated and when. This does introduce a little bit of overhead when writing code of sometimes having to look for where a particular piece of data is, but mypy statically catches most potential mistakes.

Edited by Jim Newsome

Merge request reports

Loading