Skip to content

templates: use Python type names in generated docstring - #845

Merged
julianoes merged 3 commits into
mavlink:mainfrom
vishwagw:docs-python-types-in-docstrings
Dec 3, 2026
Merged

julianoes merged 3 commits into
mavlink:mainfrom
vishwagw:docs-python-types-in-docstrings

Conversation

@vishwagw

@vishwagw vishwagw commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Problem

The generated plugin docstrings, and the API reference built from them, show C++ type names:

latitude_deg : double
timestamp_us : uint64_t
text : std::string

other/templates/py/type_conversions only maps the repeated prefix and suffix. So
protoc-gen-mavsdk falls back to its built-in C++ defaults (TypeInfo._default_types) for
every primitive.

Change

Map the protobuf primitives to Python types in other/templates/py/type_conversions
(double/float → float, (u)int32_t/(u)int64_t → int, std::string → str,
std::byte → bytes). The bindings were then regenerated with other/tools/run_protoc.sh
(pinned grpcio-tools==1.75.0 from requirements-dev.txt, Python 3.13).

  • 40 generated modules changed, and every changed line is a docstring name : type line
    (230× int, 141× str, 75× float). No code changes.
  • Regenerating on main with the old mapping reproduces main exactly, so this diff is only
    the mapping change.
  • The mavsdk-update workflow regenerates from these templates, so future releases keep the
    Python names.
  • All modules still import.

Note: tracking_server is stale

tracking_server.py keeps two C++ type names because it isn't regenerated any more: its
proto is no longer in proto/protos, and the plugin is gone from MAVSDK's cpp/src/mavsdk/plugins
at v4.3.0. The generated files were last touched at v2.12.10, but System still imports and
wires it. I left it out of this PR and can send a separate one to remove it, if you'd like.

@julianoes julianoes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@julianoes
julianoes merged commit fe286da into mavlink:main Dec 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants