[clang] Fix all mypy --strict errors in clang python binding (PR #101784)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 3 21:17:51 PDT 2024
TsXor wrote:
@DeinAlptraum @Endilll
I made this change mostly as a proof of concept: most type checking errors here originates from type information of C library functions invisible in type checker's eye. To really fix all type checking errors in a sane way instead of just putting a `#type: ignore` after every `conf.lib.*` calls, we must introduce `ctyped` or something alike.
This "huge" PR can be splitted to the following independent parts:
1. Introduce `ctyped` and replace `functionList` with stub class `LibclangExports`. Implementation of `Config.lib` and `Config.function_exists` need to be adjusted accordingly. I will split `LibclangImports` to a independent file so that it is more readable. That 360-line test can ensure that `ctyped` and `LibclangExports` is a drop-in and equivalent replacement of `functionList` and `register_function`.
2. Fix error handling of `TranslationUnit.reparse`.
3. Rename those `camelCase` methods and fields to `snake_case`.
4. Add type check to `__eq__` methods.
5. Add return type annotations to methods and remove previous `no-return-any` ignores. This is very easy, you just need to copy what is inferred in vscode.
6. Add type annotations to classes. Also, auto generate field metadata for annotated `Stucture`. (Annotation conversion for structures is not implemented in this PR.)
I'll later collect part 1 and submit a PR.
https://github.com/llvm/llvm-project/pull/101784
More information about the cfe-commits
mailing list