pybind11-stubgen
pybind11-stubgen copied to clipboard
Alias stub generation
Hi,
I came across an issue with alias'. This snippet
#include <pybind11/pybind11.h>
PYBIND11_MODULE(foo, m)
{
struct Color
{
int value;
};
pybind11::class_<Color>(m, "Color")
.def_readwrite("value", &Color::value);
m.attr("Colour") = m.attr("Color");
}
produces
import foo
import typing
__all__ = [
"Colour"
"Color"
]
class Color():
def value(self) -> int:
"""
:type: int
"""
pass
class Color():
pass
when it should be
import foo
import typing
__all__ = [
"Colour"
"Color"
]
class Color():
def value(self) -> int:
"""
:type: int
"""
pass
Colour = foo.Color
The pull request should fix this as well as module, function and class member alias'.
Hi, thanks for contribution! Patch looks good to me. I'll add a couple of tests to cover this PR and merge it shortly.
Sorry for taking it that long.
Merged as 9c71cde2cd0ae8781d44902a24f2b4e85d97c9ce