Closed PeterJCLaw closed 1 year ago
Yes, that is a good idea. However, since the Python API depends on the shared library binaries of the libController, it might be tricky to set it up properly on PyPI and support all architectures (Windows, Linux and macOS). But if you are willing to try this out, feel free to explore it and let us know your findings. Eventually, we would be happy to review your PR introducing such a contribution.
Have done some experimenting; the results are in https://github.com/cyberbotics/webots/pull/5472 though mostly as a PR seemed a useful way to share the results.
I'm not sure how the Python API is built, however I was wondering whether it would be possible to create type annotations for it. This would help document the APIs as well as allow users to check that their code is using the API correctly (just as, for example, the Java compiler is able to do for users of the Java API).
At the moment I've got a set of local stubs in my project which I've manually created based on the documented API, with the types captured from a mixture of observed data types and the docs for other languages (mostly Java).
It feels like type annotations could usefully be added to the signature snippets in the docs as well as potentially being published as a stubs package on PyPI for use in type checking and as editor completions.
I'm definitely hoping that the signatures would be generated from the true source, however I'd be happy to contribute the stubs I've created as a starting point if they need to be manually defined.