Skip to content

Commit

Permalink
⚡️ Add type check for cases of list input
Browse files Browse the repository at this point in the history
  • Loading branch information
malgorzatagwinner committed Oct 16, 2024
1 parent 8d11627 commit 922b657
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/viadot/orchestration/prefect/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def _handle_data_ranges(

return dynamic_date_marker

def process_dates(self, text: str) -> list[str] | str:
def _process_string(self, text: str) -> list[str] | str:
"""Analyze and extract date ranges or singular dates from the given text
based on specific patterns or pendulum dates.
Expand Down Expand Up @@ -446,6 +446,28 @@ def process_dates(self, text: str) -> list[str] | str:

return text

def process_segment(self, processed_input: str | list[str]) -> str | list[str]:
"""Process a segment by recognizing dates within it.
If the input is a string, it applies the recognize_date() function.
If the input is a list, it recursively processes each list item.
Args:
processed_input (str or list): The segment to be processed.
Returns:
str or list:
- If processed_input is a string, returns the processed string.
- If processed_input is a list, returns a list of processed strings.
"""
if isinstance(processed_input, str):
return self._process_string(processed_input)
if isinstance(processed_input, list):
return [
self.process_segment(sub_segment) for sub_segment in processed_input
] # type: ignore
return processed_input


async def list_block_documents() -> list[Any]:
"""Retrieve list of Prefect block documents."""
Expand Down

0 comments on commit 922b657

Please sign in to comment.