-
Notifications
You must be signed in to change notification settings - Fork 2.2k
docstring type hint incorrect for argument depending on class declaration order #2263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't think this is possible to resolve. While in the |
That's too bad. I was hoping for some sort of second pass to be able to solve it. |
You could structure your bindings in two passes, though, if you know you potentially have issues like this:
Some internal second-pass might be technically possible, but would probably cause a lot of rewriting and maybe an extra cost, and so is probably not worth it. I do have some ugly system for automatically doing the two-pass bindings in my project, if you're interested: https://github.com/YannickJadoul/Parselmouth/blob/f899207fb60dbcfea6acd3d87d62d3be8ad62c1c/src/Bindings.h |
Thanks for the tip @YannickJadoul ! |
Issue description
The generated type-hint for the argument in the initialiser of class B (see below) is invalid and shows the internal namespace instead of the module. Output of
main.py
(again see below)Note that the code is functional (although useless). To get the correct type hints we have to define
py::class_<A>(m, "A")
beforepy::class_<B>(m, "B")
expected behaviour
I'd expected to see type hints resolved correctly, regardless of class declaration order.
Reproducible example code
cmakelists.txt
main.cpp
main.py
The text was updated successfully, but these errors were encountered: