Skip to content

Commit

Permalink
reworked the to_list method
Browse files Browse the repository at this point in the history
  • Loading branch information
francescomucio authored May 31, 2024
1 parent 20a4470 commit 8067399
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions sources/rest_api/config_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)
import graphlib # type: ignore[import,unused-ignore]
import string
import json

import dlt
from dlt.common import logger
Expand Down Expand Up @@ -418,19 +417,11 @@ def process_parent_data_item(
include_from_parent: List[str],
) -> Tuple[List[str], Dict[str, Any]]:


def to_list(
s: str,
) -> List[str]:
try:
# Attempt to parse the string as a Python literal
parsed = json.loads(s)
# Check if the parsed object is a list
if isinstance(parsed, list):
return parsed
except (ValueError, json.JSONDecodeError):
pass
# If parsing fails or the parsed object is not a list, return the string in a list
s: Any,
) -> List[Any]:
if isinstance(s, list):
return s
return [s]

parent_resource_name = resolved_param.resolve_config["resource"]
Expand Down

0 comments on commit 8067399

Please sign in to comment.