[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 08:44:33 PDT 2024


Endilll wrote:

Conceptually, `ClangLib` works for strict type checking, because implementations are opaque, so the checker has to simply believe the annotations. What I want is to push this opaqueness boundary closer to the user-facing API, and get rid of the large body of code that is here just to satisfy strict checker without providing much value.

> Alternatively, we could type: ignore all calls to ClangLib attributes. That would require about 180 such annotations I believe.

This sounds fine to me. Even though I don't care too much about strict type checkers, ubiquitous `// type: ignore` on calls to `clang_`-prefixed functions should be rather easy to pick up by both authors and reviewers of future PRs.

---------

> Should I close this PR for now and split this into multiple PRs for the bugfixes and then several smaller, grouped changes?

I didn't intend you to close this PR in any case. My thinking was that you submit some of the changes from this PR and another PR, it gets merged into `main`, then you merge `main` back into this PR, eliminating changes from here.

That said, what you said about enums sounds convincing. I still would like bugs to be fixed separately (hopefully with tests). The fact that they get in the way of this PR is good enough to show that they are actually bugs to be fixed.

https://github.com/llvm/llvm-project/pull/78114


More information about the cfe-commits mailing list