From cf087d2ee20727dbbe561c8c0f90aa85ef0a5d4b Mon Sep 17 00:00:00 2001 From: Jouramie Date: Wed, 6 Mar 2024 08:55:01 -0500 Subject: [PATCH] also exclude bytes in is_iterable_but_str --- Utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utils.py b/Utils.py index 0a294e7c7a..d81a743321 100644 --- a/Utils.py +++ b/Utils.py @@ -970,7 +970,7 @@ class RepeatableChain: 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)