mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix: adding support for environment variables type dict (#6672)
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
parent
7860055f8c
commit
13839b4273
@ -3,6 +3,7 @@ import os
|
||||
import pathlib
|
||||
import platform
|
||||
import sys
|
||||
from ast import literal_eval
|
||||
from types import UnionType
|
||||
from typing import Any, MutableMapping, get_args, get_origin
|
||||
from uuid import uuid4
|
||||
@ -72,6 +73,9 @@ def load_from_env(cfg: AppConfig, env_or_toml_dict: dict | MutableMapping[str, s
|
||||
# Attempt to cast the env var to type hinted in the dataclass
|
||||
if field_type is bool:
|
||||
cast_value = str(value).lower() in ['true', '1']
|
||||
# parse dicts like SANDBOX_RUNTIME_STARTUP_ENV_VARS
|
||||
elif get_origin(field_type) is dict:
|
||||
cast_value = literal_eval(value)
|
||||
else:
|
||||
cast_value = field_type(value)
|
||||
setattr(sub_config, field_name, cast_value)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user