[clang] [clang][Python] Apply type annotations to Python (PR #173845)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 12 04:45:31 PST 2026
================
@@ -3835,23 +3863,23 @@ class CompileCommands:
that can be used for building a specific file.
"""
- def __init__(self, ccmds):
- self.ccmds = ccmds
+ def __init__(self, ccmds: CObjP) -> None:
+ self.ccmds: CObjP = ccmds
- def __del__(self):
+ def __del__(self) -> None:
conf.lib.clang_CompileCommands_dispose(self.ccmds)
- def __len__(self):
+ def __len__(self) -> int:
return int(conf.lib.clang_CompileCommands_getSize(self.ccmds))
- def __getitem__(self, i):
+ def __getitem__(self, i: int) -> CompileCommand:
cc = conf.lib.clang_CompileCommands_getCommand(self.ccmds, i)
if not cc:
raise IndexError
return CompileCommand(cc, self)
@staticmethod
- def from_result(res):
+ def from_result(res: Any) -> CompileCommands | None:
----------------
Endilll wrote:
`res` has to be convertible to `bool` and be something that `CompileCommands.__init__` can work with, which is not `Any`.
https://github.com/llvm/llvm-project/pull/173845
More information about the cfe-commits
mailing list