Skip to content

Commit b5ebe5d

Browse files
committed
docutils.nodes.Node.next_node can return None
See code at https://github.com/docutils/docutils/blob/6d835be25d585e1dce688ef33c3876aa34ba59f0/docutils/docutils/nodes.py#L369: ```python def next_node(self, condition: type | Callable[[Node], bool] | None = None, include_self: bool = False, descend: bool = True, siblings: bool = False, ascend: bool = False, ) -> Node | None: """ Return the first node in the iterator returned by findall(), or None if the iterable is empty. Parameter list is the same as of `findall()`. Note that `include_self` defaults to False, though. """ try: return next(self.findall(condition, include_self, descend, siblings, ascend)) except StopIteration: return None ```
1 parent 725a900 commit b5ebe5d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stubs/docutils/docutils/nodes.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Node:
8989
@overload
9090
def next_node(
9191
self, condition: type[_N], include_self: bool = False, descend: bool = True, siblings: bool = False, ascend: bool = False
92-
) -> _N: ...
92+
) -> _N | None: ...
9393
@overload
9494
def next_node(
9595
self,
@@ -98,7 +98,7 @@ class Node:
9898
descend: bool = True,
9999
siblings: bool = False,
100100
ascend: bool = False,
101-
) -> Node: ...
101+
) -> Node | None: ...
102102
def validate(self, recursive: bool = True) -> None: ...
103103
def validate_position(self) -> None: ...
104104

0 commit comments

Comments
 (0)