[clang] [libclang/python] Add typing annotations for the Cursor class (PR #138103)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu May 15 09:22:20 PDT 2025


================
@@ -1763,19 +1799,22 @@ def get_usr(self):
         another translation unit."""
         return _CXString.from_result(conf.lib.clang_getCursorUSR(self))
 
-    def get_included_file(self):
+    @cursor_null_guard
+    def get_included_file(self) -> File:
         """Returns the File that is included by the current inclusion cursor."""
         assert self.kind == CursorKind.INCLUSION_DIRECTIVE
 
         return File.from_result(conf.lib.clang_getIncludedFile(self), self)
 
     @property
-    def kind(self):
+    @cursor_null_guard
----------------
Endilll wrote:

You replaced `@property` decorator with your new decorator. Isn't that an unnecessary API break? Combining decorators is perfectly fine if done in the correct order.

Can you ensure we have a test for `kind` working as a property?

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


More information about the cfe-commits mailing list