Skip to content

Commit 5260e4c

Browse files
committed
combine isinstance tests
1 parent a36d1c0 commit 5260e4c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pandas/_libs/lib.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,13 +1098,12 @@ cdef inline bint c_is_list_like(object obj, bint allow_sets) except -1:
10981098
# equiv: `isinstance(obj, abc.Iterable)`
10991099
getattr(obj, "__iter__", None) is not None and not isinstance(obj, type)
11001100
# we do not count strings/unicode/bytes as list-like
1101-
and not isinstance(obj, (str, bytes))
1101+
# exclude Generic types that have __iter__
1102+
and not isinstance(obj, (str, bytes, _GenericAlias))
11021103
# exclude zero-dimensional duck-arrays, effectively scalars
11031104
and not (hasattr(obj, "ndim") and obj.ndim == 0)
11041105
# exclude sets if allow_sets is False
11051106
and not (allow_sets is False and isinstance(obj, abc.Set))
1106-
# exclude Generic types that have __iter__
1107-
and not isinstance(obj, _GenericAlias)
11081107
)
11091108

11101109

0 commit comments

Comments
 (0)