-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add python stub files #493
Conversation
Forgot to mention this resolves #212. mypy seems to be complaining about the stub files having the same names as the non-stubs; I'm unsure how to make it happy and achieve the goal we're looking for, except to exclude one or the other in a mypy config. |
I ended up forking the capnp stub generator tool and making the required alterations to get it to work. Those changes are:
I have no desire to try to upstream these changes to the original repo, especially considering that it seems dormant. I also added a Please let me know if there are any necessary further changes to get this merged-- it is very helpful to development and I'd like to see it in as soon as possible. |
Thanks for the PR! This has sat around for a while since it's a +12k diff and adds overhead to otherwise simple cereal changes. Instead of checking in the stub files, can we just generate them at compile time (plus gitignore)? |
Down to <3600, but I have an idea to remove the canpnp-stub-generator dependency in non-dev environments. That should make the diff quite minimal. |
Looks like it's just a normal Python package; can we just install it with pip? |
We can clone it from their gitlab and do a local pip install (it's not on pypi), but the issue is that there are a small number of nontrivial changes needed to either fix some bugs (their package might be targeted towards a different capnproto version?) or format the output how we would like. My idea was to clone and apply a patch before installing with pip, though I'm open to other suggestions. |
It doesn't need to be on PyPI. |
That's a good compromise, and cleaner than what I was thinking. Comment back here once you've done so and I'll be right on it. |
I forgot that the |
Should be good to go once commaai/capnp-stub-generator#1 is merged; for now the aforementioned workflow will fail. |
Why are generated files still being checked in? They should just be part of the build system. |
If they are to be built in all cases, the |
IDEs have a very hard time introspecting cereal structures, which can hinder development. I used this tool to create python stubs from the capnp files. The tool seems to be a little bit broken, and a few manual corrections were necessary, so I do not include the generator script here. Unless that tool is fixed in the future, I suggest that additional fields be added to the stub files directly, rather than being autogenerated.
806907cd33ef2647|2023-07-04--17-58-54--0
is a route of master + these changes. I noticed no odd behavior while driving the car, but have not reviewed logs to see if there was any unwanted behavior. If any overhead was added from these changes, I hope it is negligible.Note:
legacy.NavUpdate.Segment.from
is not a valid python identifier, so I commented it out from the stub file.