Skip to content

[lldb] Add a CI step to run a python type checker #141877

@ashgti

Description

@ashgti
Contributor

lldb has a minimum version of python 3.8 at the moment.

Since python 3.5, type annotations have been supported as part of the language and this can help us catch issues during testing and development.

At the moment, not much of lldb's test suite contains type annotations but if we wanted start adding them thought the tests it could be helpful for catching issues.

If we wanted to enable this on the CI systems we would need to figure out which type checker we'd want to use.

I think the most common python type checkers are mypy and pyright, although others exist as well.

Once we have that setup and configured we likely need to update lldb/test/requirements.txt to include the type checker and likely the type_extensions library, which is a library that back ports type helpers to older versions of python.

Activity

llvmbot

llvmbot commented on May 28, 2025

@llvmbot
Member

@llvm/issue-subscribers-lldb

Author: John Harrison (ashgti)

lldb has a minimum version of python 3.8 at the moment.

Since python 3.5, type annotations have been supported as part of the language and this can help us catch issues during testing and development.

At the moment, not much of lldb's test suite contains type annotations but if we wanted start adding them thought the tests it could be helpful for catching issues.

If we wanted to enable this on the CI systems we would need to figure out which type checker we'd want to use.

I think the most common python type checkers are mypy and pyright, although others exist as well.

Once we have that setup and configured we likely need to update lldb/test/requirements.txt to include the type checker and likely the type_extensions library, which is a library that back ports type helpers to older versions of python.

ashgti

ashgti commented on May 28, 2025

@ashgti
ContributorAuthor

For reference, I have been using:

$ mypy --python-version 3.8 \
  lldb/packages/Python/lldbsuite/**/*.py \
  lldb/test/API/tools/lldb-dap/**/*.py

To check the code I've been working on recently.

boomanaiden154

boomanaiden154 commented on May 29, 2025

@boomanaiden154
Contributor

If we're going to be doing type checking, this should probably be monorepo wide rather than specific to lldb. This would also need to through the RFC process and we would need to settle on a type checker (mypy/pytype/others) and some other policies (post commit type checking buildbot?).

Just starting with lldb to gain experience might not be the worst move though.

ashgti

ashgti commented on May 29, 2025

@ashgti
ContributorAuthor

I made a post on https://discourse.llvm.org/t/rfc-type-checking-to-python-code/86605 to discuss this for lldb. If we have some traction on that, I can see about an RFC for the whole repo.

ashgti

ashgti commented on Jun 5, 2025

@ashgti
ContributorAuthor

I made a prototype of this integration in my lldb-mypy branch:

ashgti@585ce5d

This integrates the type check into the dotest.py helper.

See https://discourse.llvm.org/t/rfc-type-checking-to-python-code/86605/7 for more details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ashgti@EugeneZelenko@boomanaiden154@llvmbot

        Issue actions

          [lldb] Add a CI step to run a python type checker · Issue #141877 · llvm/llvm-project