[REFACTOR] do not throw an exception in list_parse_fallback (#1891)

This commit is contained in:
dni ⚡
2023-08-24 12:50:38 +02:00
committed by GitHub
parent c54f48ee73
commit 1efec9bb80

View File

@@ -12,15 +12,15 @@ from loguru import logger
from pydantic import BaseSettings, Extra, Field, validator
def list_parse_fallback(v):
try:
return json.loads(v)
except Exception:
replaced = v.replace(" ", "")
if replaced:
return replaced.split(",")
def list_parse_fallback(v: str):
v = v.replace(" ", "")
if len(v) > 0:
if v.startswith("[") or v.startswith("{"):
return json.loads(v)
else:
return []
return v.split(",")
else:
return []
class LNbitsSettings(BaseSettings):