Issue 178165
Summary [lldb] [feat] [python api] Add type annotations to the LLDB python API
Labels new issue
Assignees
Reporter k4lizen
    LLDB currently does not provide type annotations for the LLDB python API which makes it annoying to work with, as editors cannot provide autocompletion or statically check the existence of member functions. 

[pwndbg](https://github.com/pwndbg/pwndbg) makes extensive use of the LLDB python API and it would majorly help us if we had type annotations. For one we use mypy in the CI and this would enable mypy properly check the typing, but also having the help of the IDE/editor eases the burden for newer contributors who haven't used the LLDB python API before.

GDB does have type annotations in its python API, as provided by the [typeshed](https://github.com/python/typeshed) [types-gdb](https://pypi.org/project/types-gdb/) package. While the LLDB python API is much more comprehensive, there already are types in the function's docstrings:

<img width="717" height="335" alt="Image" src="" />

So it might be feasible to generate the python type annotations from these. There are some functions which return a different type depending on the input arguments (corresponding to function overloads in C), these could be annotated with `type1 | type2`. It is likely that there are some "tricky" cases to this, but even having like 80% of the API be typed would be a major improvement, we don't need to go from 0% to 100% imo.

There was some prior work on this: [lldb-typeinfo](https://github.com/soda92/lldb-typeinfo) but it is bundled as a seperate python package which is not viable, and also in WIP / unfinished and not official.


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to