0

We have an embedded python interpreter in C++ MFC application.

The issue is when I request a help of a wrapped C++ lambda function I see ellipsis in arguments:

help(my_module.test)

prints:

test(...) method of builtins.PyCapsule instance
    some description of function

while expected something like

test(x1 : double) -> double
    some description of function

Here is a definition of this function:

PYBIND11_EMBEDDED_MODULE(my_module, m)
{
    py::options options;
    //options.disable_function_signatures(); // here is a tricky point
    m.doc() = "some test module";
    m.def("test", [](double x1) { return x1; }, "some description of function", py::arg("x1"));
}

When I uncomment options.disable_function_signatures() in the module it creates a signature additionally to the one already exist:

test(...) method of builtins.PyCapsule instance
    test(x1 : float) -> float
    some description of function

A signature created by pybind11 considers my "double" as a "float".

When I generate an html documentation using pdoc I've got:

  • test(unknown)

    test(x1 : float) -> float

    some description of function

which is not representative.

I feel that there is a pybind11 conversion issue but don't know how to fix it.. Any help is appreciated.

evguran
  • 1
  • 1
  • 1
    This is the way I look at it: Python's `float` is double precision, so it corresponds to C++'s `double`. So from Python perspective (and it is a documentation of the Python interface to your code), that function accepts `float`s. – Dan Mašek Aug 31 '23 at 17:29

0 Answers0