pybind/pybind11

Unkown objects in docstring function signatures

Open

#1.585 geöffnet am 1. Nov. 2018

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (2.005 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (14.677 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5T 2h) (10 gemergte PRs in 30 T)

Beschreibung

I try to rely on mypy's stubgen (with recent improvements) to generate *.pyi files from Python classes generated by pybind11. It's almost perfect, though there are just a few things that needs a bit of polishing:

  • iterator - when creating method with .def("some_func", [](some_type const &a) {return py::make_iterator(a.cbegin<elem_type>(), a.cend<elem_type>());}; then docstring is some_func() -> iterator. Type should be either Iterator (from typing) or even better, if it would be Iterator[elem_type]
  • buffer - when binding method with signature add_buffer(py::buffer const &buf) the docstring is add_buffer(buffer: buffer). Is this buffer in Python2 and bytearray in Python3? Should stubgen alias bytearray as buffer in such cases?

Contributor Guide