Skip to content

Commit

Permalink
also exclude bytes in is_iterable_but_str
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouramie committed Mar 6, 2024
1 parent 38f9ee5 commit cf087d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ def __len__(self):


def is_iterable_but_str(obj: object) -> TypeGuard[typing.Iterable[typing.Any]]:
""" but not a `str` (because technically, `str` is `Iterable[str]`) """
if isinstance(obj, str):
""" but not a `str` nor `bytes` (because technically, `str` and `bytes` are `Iterable[str | bytes]`) """
if isinstance(obj, (str, bytes)):
return False
return isinstance(obj, typing.Iterable)

0 comments on commit cf087d2

Please sign in to comment.