Skip to content

Commit 60803c3

Browse files
committed
Consolidate if instance check
1 parent d8ba0c2 commit 60803c3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

htmltools/_util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ def _flatten_recurse(x: Iterable[T | None], result: list[T]) -> None:
8989
from ._core import TagList
9090

9191
for item in x:
92-
if isinstance(item, TagList):
93-
_flatten_recurse(item.data, result) # pyright: ignore[reportArgumentType]
94-
elif isinstance(item, (list, tuple)):
92+
if isinstance(item, (list, tuple, TagList)):
9593
# Don't yet know how to specify recursive generic types, so we'll tell
9694
# the type checker to ignore this line.
97-
_flatten_recurse(item, result) # pyright: ignore[reportUnknownArgumentType]
95+
_flatten_recurse(
96+
item, # pyright: ignore[reportUnknownArgumentType]
97+
result, # pyright: ignore[reportArgumentType]
98+
)
9899
elif item is not None:
99100
result.append(item)
100101

0 commit comments

Comments
 (0)