-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
When a function is overloaded, documentation comments is placed in wrong place.
For example, the C++ wrapper is below:
#include <iostream>
#include <pybind11/pybind11.h>
int add_int(int x, int y) {
return x + y;
}
double add_double(double x, double y) {
return x + y;
}
namespace py = pybind11;
PYBIND11_MODULE(python_example, m) {
m.doc() = "pybind11 example plugin";
m.def("add", &add_int, "Add x and y(int)", py::arg("x"), py::arg("y"));
m.def("add", &add_double, "Add x and y(double)", py::arg("x"), py::arg("y"));
}
then, __init__.pyi
below is generated:
"""pybind11 example plugin"""
from __future__ import annotations
import python_example
import typing
__all__ = [
"add"
]
@typing.overload
def add(x: float, y: float) -> float:
"""
Add x and y(int)
Add x and y(double)
"""
@typing.overload
def add(x: int, y: int) -> int:
pass
I expect it to be like below:
"""pybind11 example plugin"""
from __future__ import annotations
import python_example
import typing
__all__ = [
"add"
]
@typing.overload
def add(x: float, y: float) -> float:
"""
Add x and y(double)
"""
@typing.overload
def add(x: int, y: int) -> int:
"""
Add x and y(int)
"""
help(add)
prints separated documents, so I think this is pybind11-stubgen problem.
Is there a solution to fix it?
auscompgeek
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed