mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-02 07:23:25 +00:00
[BugFix] Fix the multiple items check (#6294)
* check for multiple items when no info * check for , and ; only if it's a str --------- Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
This commit is contained in:
@@ -42,5 +42,16 @@ def filter_inputs(
|
||||
|
||||
kwargs[p][field] = new
|
||||
break
|
||||
else:
|
||||
provider = kwargs.get("provider_choices", {}).get("provider")
|
||||
for param_category in ("standard_params", "extra_params"):
|
||||
if param_category in kwargs:
|
||||
for field, value in kwargs[param_category].items():
|
||||
if isinstance(value, list):
|
||||
kwargs[param_category][field] = ",".join(map(str, value))
|
||||
check_single_item(
|
||||
kwargs[param_category][field],
|
||||
f"{field} -> multiple items not allowed for '{provider}'",
|
||||
)
|
||||
|
||||
return kwargs
|
||||
|
||||
@@ -166,6 +166,6 @@ def check_single_item(
|
||||
value: Optional[str], message: Optional[str] = None
|
||||
) -> Optional[str]:
|
||||
"""Check that string contains a single item."""
|
||||
if value and ("," in value or ";" in value):
|
||||
if value and isinstance(value, str) and ("," in value or ";" in value):
|
||||
raise OpenBBError(message if message else "multiple items not allowed")
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user