-
Notifications
You must be signed in to change notification settings - Fork 253
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
Type stubs for rosbag2_py #1459
Comments
@emersonknapp Do you have thoughts about this proposal? |
Currently, the type annotations for methods are generic. Eg. pybind11::tuple read_next() Ideally, it would have the return type pybind's test_python_types.cpp has examples showing how to specify these more specific types. /* pybind automatically translates between C++11 and Python tuples */
std::tuple<int, std::string, bool> tuple_passthrough(std::tuple<bool, std::string, int> input) {
return std::make_tuple(std::get<2>(input), std::get<1>(input), std::get<0>(input));
} |
Signed-off-by: Roman Sokolkov <[email protected]>
Signed-off-by: Roman Sokolkov <[email protected]>
* Add Python stubs for rosbag2_py Signed-off-by: Roman Sokolkov <[email protected]> * Add note to DEVELOPING.md Signed-off-by: Roman Sokolkov <[email protected]> * Add note to py.typed Signed-off-by: Roman Sokolkov <[email protected]> --------- Signed-off-by: Roman Sokolkov <[email protected]>
@MichaelOrlov should we reopen this issue or create a new one for addressing issues that pybind11-stubgen found?
|
@r7vme Hold on. But how the pybind11-stubgen found these issues if we didn't change those files from the last run? Certainly need to open a new issue or PR. |
@MichaelOrlov I just copy pasted output from the above. We did not break anyting yet :) In any case, I think we can try to address those issues. |
Can we reopen this issue? |
Ok. I reopen this issue. |
Yeah, let's close this issue, major issue is fixed. |
Description
I'd like type stubs for
rosbag2_py
, so that I can get autocomplete/static analysis.Completion Criteria
** What needs to be true before we can call this "Done"? Bullet lists are appropriate. **
rosbag2_py
have full type annotations. A static analysis tool like mypy/pylance can tell parse these type annotations.Implementation Notes / Suggestions
Stubs can be generated with
pybind11-stubgen
:After doing this, making a
setup.py
, and installing the newly createdrosbag2_py-stubs
library, we get some type information, though the function argument and return types are incomplete:The output from the
pybind11-stubgen
command isI expect that addressing the issues in this output would get us the missing type information.
Testing Notes / Suggestions
** All features in this project need tests. Please give some input on cases that will need to be tested - and how the testing might be implemented. **
A test could run
mypy
on an example python script usingrosbag2_py
. I'm not sure whatmypy
options would need to be set to verify that all therosbag2_py
objects are properly typed.The text was updated successfully, but these errors were encountered: