-
Notifications
You must be signed in to change notification settings - Fork 602
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
mavgen_python: Add python3 target with type annotations #666
Conversation
Note that the type of file should be class BinaryWriter(typing.Protocol):
def write(self, b: bytes) -> int:
... and not Any, but typing.Protocol is a python 3.8 thing and I want to support Python 3.6+ with the type annotations. |
notes from dev call:
|
Mavros doesn't use |
In this PR if you specify "Python" or nothing (the default is "Python") it will only generate the type annotations if you are running it with python >= python3.6 |
getting this with py2 build:
|
While these errors are annoying, I don't see anything short of disabling bytecode compiling for those versions that fixes these warnings. Note that like this all files that can be byte-compiled, are byte-compiled. |
I had to revert the last commit that turned off byte-compilation. It will not create an egg directory if you disable byte compilation, which is what is needed by most places. The syntax errors it shows when building the package using python2 and 3.5 are quite harmless. Also note that we build the package using 3.9, so they won't happen during the official build step. |
It seems that python3 support was only tacked on and evolved organically. This assumes python2.7 and uses consistent types for internal variables while keeping the externally facing types the same.
This makes sure that somebody using python < 3.6 will be able to use mavutil like before.
This PR is based on #664 and contains 4 commits. It adds type annotation support in way that should not break mavlink for people stuck on Python2. Everyone else should benefit from the type annotations.