From 7a6eca1b7ead7ee1396e85a2df019788900941a0 Mon Sep 17 00:00:00 2001 From: Robin van der Noord Date: Tue, 5 Dec 2023 12:33:34 +0100 Subject: [PATCH] fix(setup): tomlkit uses custom types which broke setup --- src/typedal/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/typedal/cli.py b/src/typedal/cli.py index d62b86b..777c606 100644 --- a/src/typedal/cli.py +++ b/src/typedal/cli.py @@ -7,6 +7,7 @@ from pathlib import Path from typing import Optional +import tomli from configuraptor import asdict from configuraptor.alias import is_alias from configuraptor.helpers import is_optional @@ -122,7 +123,6 @@ def get_question(prop: str, annotation: typing.Type[T], default: T | None) -> Op default = typing.cast(T, str(default)) response = questionary.unsafe_prompt([question], default=default)[prop] - return typing.cast(T, response) @@ -150,7 +150,8 @@ def setup( toml_path.touch() toml_contents = toml_path.read_text() - toml_obj: dict[str, typing.Any] = tomlkit.loads(toml_contents) + # tomli has native Python types, tomlkit doesn't but preserves comments + toml_obj: dict[str, typing.Any] = tomli.loads(toml_contents) if "[tool.typedal]" in toml_contents: section = toml_obj["tool"]["typedal"]