From e54a16325f9a9cc28ad1998209fd31e12623ff8d Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Sun, 1 Jun 2025 20:24:10 +0100 Subject: [PATCH] Ensure that Iterator includes the type yielded --- src/bipart.cpp | 9 ++++----- src/libsemigroups_pybind11/froidure_pin.py | 4 ++-- src/libsemigroups_pybind11/konieczny.py | 4 ++-- src/word-graph.cpp | 10 +++++----- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/bipart.cpp b/src/bipart.cpp index 4b63a32cf..9c7d8563d 100644 --- a/src/bipart.cpp +++ b/src/bipart.cpp @@ -105,10 +105,9 @@ Return a const iterator yielding the indices of the blocks. Constant. :returns: - A value of type :any:`Iterator`. - + An iterator yielding the indices of blocks. :rtype: - iterator + Iterator[int] )pbdoc"); thing.def("degree", &Blocks::degree, @@ -318,9 +317,9 @@ Return an iterator yielding the indices of the blocks. Constant. :returns: - A value of type :any:`Iterator`. + An iterator yielding the indices of the blocks. :rtype: - Iterator + Iterator[int] )pbdoc"); thing.def("degree", &Bipartition::degree, diff --git a/src/libsemigroups_pybind11/froidure_pin.py b/src/libsemigroups_pybind11/froidure_pin.py index c32e7cbc1..69f401f37 100644 --- a/src/libsemigroups_pybind11/froidure_pin.py +++ b/src/libsemigroups_pybind11/froidure_pin.py @@ -176,7 +176,7 @@ def __getitem__(self: _Self, i: int) -> Element: self._raise_if_element_not_implemented() return _to_py(_to_cxx(self)[i]) - def __iter__(self: _Self) -> Iterator: + def __iter__(self: _Self) -> Iterator[Element]: self._raise_if_element_not_implemented() return map(_to_py, iter(_to_cxx(self))) @@ -209,7 +209,7 @@ def idempotents( # pylint: disable=missing-function-docstring @_copydoc(_FroidurePinPBR.sorted_elements) def sorted_elements( # pylint: disable=missing-function-docstring self: _Self, - ) -> Iterator: + ) -> Iterator[Element]: self._raise_if_element_not_implemented() return map( _to_py, diff --git a/src/libsemigroups_pybind11/konieczny.py b/src/libsemigroups_pybind11/konieczny.py index 8dd8d594d..c7baf3502 100644 --- a/src/libsemigroups_pybind11/konieczny.py +++ b/src/libsemigroups_pybind11/konieczny.py @@ -156,7 +156,7 @@ def generators(self: Self) -> Iterator[Element]: ) @_copydoc(_KoniecznyBMat.current_D_classes) - def current_D_classes(self: Self) -> Iterator: + def current_D_classes(self: Self) -> Iterator[DClass]: # pylint: disable=missing-function-docstring,invalid-name return map( _to_py, @@ -164,7 +164,7 @@ def current_D_classes(self: Self) -> Iterator: ) @_copydoc(_KoniecznyBMat.D_classes) - def D_classes(self: Self) -> Iterator: + def D_classes(self: Self) -> Iterator[DClass]: # pylint: disable=missing-function-docstring,invalid-name return map( _to_py, diff --git a/src/word-graph.cpp b/src/word-graph.cpp index bf9802115..927db2d27 100644 --- a/src/word-graph.cpp +++ b/src/word-graph.cpp @@ -189,10 +189,10 @@ This function returns an iterator yielding the nodes of the word graph. :returns: - An :any:`Iterator`. + An iterator yielding the nodes. :rtype: - Iterator + Iterator[int] :complexity: Constant.)pbdoc"); @@ -221,8 +221,8 @@ to the source node *source*. This target might equal :any:`UNDEFINED`. :param source: the source node in the word graph. :type source: int -:returns: An :any:`Iterator`. -:rtype: Iterator +:returns: An iterator yielding the targets. +:rtype: Iterator[int | Undefined] :raises LibsemigroupsError: if *source* is out of range (i.e. greater than or equal to @@ -331,7 +331,7 @@ targets of edges with source *source*. :type source: int :returns: An iterator. -:rtype: Iterator +:rtype: Iterator[tuple[int, int | Undefined]] :raises LibsemigroupsError: if *source* is out of bounds.)pbdoc"); thing.def(