Closed Coelhomatias closed 4 months ago
This is most likely due to your IDE or plug-in not relying on or parsing the help output. Maybe it's expecting the function to have a docstring in a given format? We could try to add one as described here and see if this solves your issue. I don't have time for this at the moment, but feel free to give it a try and contribute it back with a PR if it works.
I'm sorry I don't have much knowledge in this subject. I use VSCode with Pylance. From my understanding and what I read online. For Pylance to understand the types of the module it is necessary a stub file. This stubfile can be generated with pybind11-stubgen or with mypy's stubgen. Both of them give me errors when trying to generate the stubs because some missing imports. Despite this, a stub file is indeed generated but I can't get Pylance to know about this. I am not a C/C++ developer and I don't know how to modify make files, however, I think this can be added to the build process. I will be working extensively with colmap and pycolmap for the remainder of the year and would be happy to (eventually) contribute, however, I too don't have enough time to learn the necessary skills for now. Maybe in the future I'll submit a PR regarding this issue.
Hi @Coelhomatias, I just tried generating stubfiles with pybind11-stubgen pycolmap
. It will create a file stubs/pycolmap.pyi
. You need to move it into the same folder as the pycolmap.cpython*.so
file (with a source install you can just put it into the pycolmap folder). Then VSCode gives correct types (where available, arguments with type py::object
will show ...
) and auto-complete also works.
@Phil26AT Thank you very much, you just saved me a lot of time and effort!
I see a lot of type definitions in the code but for some reason type hints in python only show the Unknown type in the tooltip. If I print
type(...)
it works and gives me the correct type. Would love some code completion instead of always runninghelp(...)