Closed TheTripleV closed 9 months ago
Were you getting errors building or just type checking errors? I did not get building errors.
Building errors.
I think I do what you suggesting:
Sorry, I'll not be able to look into this until next weekend.
@TheTripleV Could you provide a reproducible example? I cannot reproduce the issue.
{
auto sm1 = m.def_submodule("a1");
auto sm2 = sm1.def_submodule("a2");
auto sm3 = sm2.def_submodule("a3");
auto sm4 = sm3.def_submodule("a4");
struct Unit {
};
py::class_<Unit>(sm4, "Unit")
.def(py::init<>());
auto b = m.def_submodule("b");
auto c = m.def_submodule("c");
auto d = m.def_submodule("d");
b.def("get_unit", [] { return Unit{}; });
c.def("set_unit", [](const Unit &u) { return 0; });
d.attr("unit") = Unit{};
}
# ==> b.pyi <==
from __future__ import annotations
import demo._bindings.issues.a1.a2.a3.a4
__all__ = ['get_unit']
def get_unit() -> demo._bindings.issues.a1.a2.a3.a4.Unit:
...
# ==> c.pyi <==
from __future__ import annotations
import demo._bindings.issues.a1.a2.a3.a4
__all__ = ['set_unit']
def set_unit(arg0: demo._bindings.issues.a1.a2.a3.a4.Unit) -> int:
...
# ==> d.pyi <==
from __future__ import annotations
import demo._bindings.issues.a1.a2.a3.a4
__all__ = ['unit']
unit: demo._bindings.issues.a1.a2.a3.a4.Unit # value = <demo._bindings.issues.a1.a2.a3.a4.Unit object>
I assume there was no error in pybind11-stubgen
. Feel free to reopen if not.
I have a type in a function
wpimath.units.radians
that needs to get resolved.wpimath.units
is a module.units
cannot be accessed fromwpimath
without importing.I think stubgen should try all combinations of imports (
wpimath
,wpimath.units
) to resolve a type.