Skip to content

Commit

Permalink
fix: add comments for has_nested_dataclass function
Browse files Browse the repository at this point in the history
Signed-off-by: mao3267 <[email protected]>
  • Loading branch information
mao3267 committed Aug 13, 2024
1 parent c285e34 commit 4d2646c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion flytekit/interaction/click_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,25 @@ def convert(
parsed_value = self._parse(value, param)

def has_nested_dataclass(t: typing.Type) -> bool:

Check warning on line 312 in flytekit/interaction/click_types.py

View check run for this annotation

Codecov / codecov/patch

flytekit/interaction/click_types.py#L312

Added line #L312 was not covered by tests
"""
Recursively checks whether the given type or its nested types contain any dataclass.
This function is typically called with a dictionary or list type and will return True if
any of the nested types within the dictionary or list is a dataclass.
Note:
- A single dataclass will return True.
- The function specifically excludes certain Flyte types like FlyteFile, FlyteDirectory,
StructuredDataset, and FlyteSchema from being considered as dataclasses. This is because
these types are handled separately by Flyte and do not need to be converted to dataclasses.
Args:
t (typing.Type): The type to check for nested dataclasses.
Returns:
bool: True if the type or its nested types contain a dataclass, False otherwise.
"""
if dataclasses.is_dataclass(t):
# After supporting dataclass with Flyte types members, we will support Flyte types here.
if t not in [FlyteFile, FlyteDirectory, StructuredDataset, FlyteSchema]:
return True

Check warning on line 333 in flytekit/interaction/click_types.py

View check run for this annotation

Codecov / codecov/patch

flytekit/interaction/click_types.py#L333

Added line #L333 was not covered by tests
if get_args(t):
Expand Down

0 comments on commit 4d2646c

Please sign in to comment.