mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Modify DOMNode.walk_children to return a list
Originally it returned an iterable, building that up from a list anyway. In local discussion it's been decided that it makes more sense to simply return the list. There's no obvious advantage to doing it a different way.
This commit is contained in:
@@ -634,7 +634,7 @@ class DOMNode(MessagePump):
|
|||||||
with_self: bool = True,
|
with_self: bool = True,
|
||||||
method: WalkMethod = "depth",
|
method: WalkMethod = "depth",
|
||||||
reverse: bool = False,
|
reverse: bool = False,
|
||||||
) -> Iterable[WalkType]:
|
) -> list[WalkType]:
|
||||||
...
|
...
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
@@ -644,7 +644,7 @@ class DOMNode(MessagePump):
|
|||||||
with_self: bool = True,
|
with_self: bool = True,
|
||||||
method: WalkMethod = "depth",
|
method: WalkMethod = "depth",
|
||||||
reverse: bool = False,
|
reverse: bool = False,
|
||||||
) -> Iterable[DOMNode]:
|
) -> list[DOMNode]:
|
||||||
...
|
...
|
||||||
|
|
||||||
def walk_children(
|
def walk_children(
|
||||||
@@ -654,7 +654,7 @@ class DOMNode(MessagePump):
|
|||||||
with_self: bool = True,
|
with_self: bool = True,
|
||||||
method: WalkMethod = "depth",
|
method: WalkMethod = "depth",
|
||||||
reverse: bool = False,
|
reverse: bool = False,
|
||||||
) -> Iterable[DOMNode | WalkType]:
|
) -> list[DOMNode] | list[WalkType]:
|
||||||
"""Generate descendant nodes.
|
"""Generate descendant nodes.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -665,7 +665,7 @@ class DOMNode(MessagePump):
|
|||||||
reverse (bool, optional): Reverse the order (bottom up). Defaults to False.
|
reverse (bool, optional): Reverse the order (bottom up). Defaults to False.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Iterable[DOMNode | WalkType]: An iterable of nodes.
|
list[DOMNode] | list[WalkType]: A list of nodes.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -712,9 +712,8 @@ class DOMNode(MessagePump):
|
|||||||
# change mid-walk
|
# change mid-walk
|
||||||
nodes = list(node_generator)
|
nodes = list(node_generator)
|
||||||
if reverse:
|
if reverse:
|
||||||
yield from reversed(nodes)
|
nodes.reverse()
|
||||||
else:
|
return nodes
|
||||||
yield from nodes
|
|
||||||
|
|
||||||
def get_child(self, id: str) -> DOMNode:
|
def get_child(self, id: str) -> DOMNode:
|
||||||
"""Return the first child (immediate descendent) of this node with the given ID.
|
"""Return the first child (immediate descendent) of this node with the given ID.
|
||||||
|
|||||||
Reference in New Issue
Block a user