[REFACTOR] do not throw an exception in list_parse_fallback (#1891)
This commit is contained in:
+8
-8
@@ -12,15 +12,15 @@ from loguru import logger
|
|||||||
from pydantic import BaseSettings, Extra, Field, validator
|
from pydantic import BaseSettings, Extra, Field, validator
|
||||||
|
|
||||||
|
|
||||||
def list_parse_fallback(v):
|
def list_parse_fallback(v: str):
|
||||||
try:
|
v = v.replace(" ", "")
|
||||||
return json.loads(v)
|
if len(v) > 0:
|
||||||
except Exception:
|
if v.startswith("[") or v.startswith("{"):
|
||||||
replaced = v.replace(" ", "")
|
return json.loads(v)
|
||||||
if replaced:
|
|
||||||
return replaced.split(",")
|
|
||||||
else:
|
else:
|
||||||
return []
|
return v.split(",")
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
class LNbitsSettings(BaseSettings):
|
class LNbitsSettings(BaseSettings):
|
||||||
|
|||||||
Reference in New Issue
Block a user