Skip to content

Commit

Permalink
convert value to dictionary (#659)
Browse files Browse the repository at this point in the history
#649 @stan-dot 

For the environment to work, it needed to be in dictionary from so a
string to dictionary conversion is needed. This was me playing with it.

You probably already working on it, the cli_value are all none unless
you assign them so pydantic keep complaining.
  • Loading branch information
Relm-Arrowny authored and stan-dot committed Oct 16, 2024
1 parent dc74ea6 commit 4181bd8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/blueapi/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ast
import os
from collections.abc import Mapping
from enum import Enum
Expand Down Expand Up @@ -169,7 +170,7 @@ def use_values_from_env(self, prefix: str = "APP_") -> None:
if key.startswith(prefix):
# Convert key to a config path-like structure
config_key = key[len(prefix) :].lower()
env_values[config_key] = value
env_values[config_key] = ast.literal_eval(value)
self.use_values(env_values)

def use_values_from_cli(self, cli_args: Any) -> None:
Expand All @@ -189,5 +190,6 @@ def load(self) -> C:
pretty_error_messages = pretty_print_errors(exc.errors())

raise InvalidConfigError(
f"Something is wrong with the configuration file:\n{pretty_error_messages}"
"Something is wrong with the configuration file:\n"
+ f"{pretty_error_messages}"
) from exc

0 comments on commit 4181bd8

Please sign in to comment.