[clang] [libclang/python] Add type annotations to the TranslationUnit class (PR #180876)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 17 07:05:07 PDT 2026


================
@@ -3703,7 +3729,9 @@ def __getitem__(self, key: int) -> Diagnostic:
 
         return DiagIterator(self)
 
-    def reparse(self, unsaved_files=None, options=0):
+    def reparse(
+        self, unsaved_files: list[InMemoryFile] | None = None, options: int = 0
----------------
Endilll wrote:

`options` turns out to be `CXReparse_Flags`, which are `int` in libclang API.
There are more cases of those enums with flags that are used in Python bindings:

- `CXDiagnosticDisplayOptions`
- `CXTranslationUnit_Flags`

and some more:
- `CXCodeComplete_Flags`
- `CXIndexOptFlags`
- `CXGlobalOptFlags`
- `CXSaveTranslationUnit_Flags`
- `CXNameRefFlags`
- `CXIdxDeclInfoFlags`

which are not used yet.

Then there is `TranslationUnit.codeComplete`, which exposed `options` of `clang_codeCompleteAt` as three booleans, even though `CXCodeComplete_Flags` has 5 flags.


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


More information about the cfe-commits mailing list