fix(shared): allow list settings (#1837)
This commit is contained in:
parent
bc6b43c43c
commit
a4caf4782b
2 changed files with 30 additions and 9 deletions
|
@ -2,7 +2,7 @@ import sys
|
|||
from configparser import ConfigParser
|
||||
from os import environ
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from loguru import logger
|
||||
|
||||
|
@ -63,11 +63,18 @@ class BaseConfig(BaseModel):
|
|||
env_name = (env_prefix + field.name).upper()
|
||||
|
||||
if field.is_complex():
|
||||
children = self._get_fields_from_env(
|
||||
env_name,
|
||||
env_delimiter,
|
||||
field.type_.__fields__,
|
||||
)
|
||||
children: Union[List[Any], Dict[str, Any]] = []
|
||||
|
||||
if field.sub_fields:
|
||||
if env_name in environ:
|
||||
children = [v.strip() for v in environ[env_name].split(",")]
|
||||
|
||||
else:
|
||||
children = self._get_fields_from_env(
|
||||
env_name,
|
||||
env_delimiter,
|
||||
field.type_.__fields__,
|
||||
)
|
||||
|
||||
if len(children) != 0:
|
||||
result[field.name] = children
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue