Skip to content

Commit

Permalink
Fix: is_iterable_str now has an argument accept_str that must be spec…
Browse files Browse the repository at this point in the history
…ified.
  • Loading branch information
Labbeti committed Apr 18, 2024
1 parent 9b728c9 commit a3c32ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/aac_datasets/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _is_index(index: Any) -> TypeGuard[IndexType]:


def _is_column(column: Any) -> TypeGuard[ColumnType]:
return isinstance(column, str) or is_iterable_str(column) or column is None
return is_iterable_str(column, accept_str=True) or column is None


class AACDataset(Generic[ItemType], Dataset[ItemType]):
Expand Down
8 changes: 5 additions & 3 deletions src/aac_datasets/utils/type_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ def is_iterable_int(x: Any) -> TypeGuard[Iterable[int]]:
return isinstance(x, Iterable) and all(isinstance(xi, int) for xi in x)


def is_iterable_str(x: Any, accept_str: bool = False) -> TypeGuard[Iterable[str]]:
return (accept_str or not isinstance(x, str)) and (
isinstance(x, Iterable) and all(isinstance(xi, str) for xi in x)
def is_iterable_str(x: Any, *, accept_str: bool) -> TypeGuard[Iterable[str]]:
return (accept_str and isinstance(x, str)) or (
not isinstance(x, str)
and isinstance(x, Iterable)
and all(isinstance(xi, str) for xi in x)
)


Expand Down

0 comments on commit a3c32ef

Please sign in to comment.