[all-commits] [llvm/llvm-project] c78312: [lldb][Python] Enable type annotations for most ty...

Nerixyz via All-commits all-commits at lists.llvm.org
Fri Aug 7 03:18:24 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c783125adce180e3eed4732118b216c66b5f0093
      https://github.com/llvm/llvm-project/commit/c783125adce180e3eed4732118b216c66b5f0093
  Author: Nerixyz <nerixdev at outlook.de>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    M lldb/bindings/python/python-typemaps.swig
    M lldb/bindings/python/python.swig

  Log Message:
  -----------
  [lldb][Python] Enable type annotations for most types (#213463)

Swig 4.5.0 released today and adds support for customizable automatic
type annotations.

We have to configure the `pytyping` typemap for all cases where we
change the default Swig behavior (i.e. for all `in`/`out`/`argout`
typemaps). This is what I did in this PR. In two cases, we can't
properly annotate:

- For all `argout` typemaps, Swig includes the return type of the
function. So if we'd return a `typing.List[int]`, Swig assumes we're
using `Swig_AppendOutput`, so it annotates the return type with
`typing.List[typing.Union[ReturnType, typing.List[int]]]`.
- Related to that, the annotations for `INPUT`/`OUTPUT`/`INOUT` are
wrong, because the `pytyping` typemap doesn't know about them.

There, I disabled the annotations. Furthermore, overloads are not shown.
The issues are known, and I have fixes for them, but they will only land
in Swig 4.6.

It's a bit unfortunate that this happens after 23.x, but better late
than never.

In the future, we could use
https://github.com/tox-dev/sphinx-autodoc-typehints to show the type
hints in the documentation. One downside is that without support for
overloads, some methods only show `*args`.

You can see the current `__init__.py` in
https://gist.github.com/Nerixyz/2bf230147f933e3943a87457bf036bb0.

Towards #79043.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list