Closed
Description
This is probably more of a question and I don't know where else to ask it right now.
Is it possible to type the iterator?
I don't know if pybind11 doesn't currently offer that in general, if it's because of my possibly specific implementation or if this package just hasn't implemented that so far?
class Value
{
public:
virtual ~Value() = default;
};
class Array : public Value, public std::vector<Value*>
{
public:
using std::vector<Value*>::vector;
....
};
....
py::class_<Array, Value>(m, "Array", "")
....
.def("__iter__", [](Array& array) {
return py::make_iterator(array.begin(), array.end());
}, py::keep_alive<0, 1>()); /* Keep vector alive while iterator is used */
Generates:
class Array(Value):
def __iter__(self) -> typing.Iterator: ...
Is it possible to generate somethin like the following?
class Array(Value):
def __iter__(self) -> typing.Iterator[Value]: ...
Metadata
Metadata
Assignees
Labels
No labels