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

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Thu May 1 04:08:25 PDT 2025


================
@@ -1821,45 +1824,45 @@ def mangled_name(self):
         return self._mangled_name
 
     @property
-    def location(self):
+    def location(self) -> SourceLocation:
         """
         Return the source location (the starting character) of the entity
         pointed at by the cursor.
         """
         if not hasattr(self, "_loc"):
-            self._loc = conf.lib.clang_getCursorLocation(self)
+            self._loc: SourceLocation = conf.lib.clang_getCursorLocation(self)
 
         return self._loc
 
     @property
-    def linkage(self):
+    def linkage(self) -> LinkageKind:
         """Return the linkage of this cursor."""
         if not hasattr(self, "_linkage"):
             self._linkage = conf.lib.clang_getCursorLinkage(self)
----------------
DeinAlptraum wrote:

Not directly related to this PR, but it seems that `clang_getCursorLinkage`, as well as `clang_getCursorTLSKind` and `clang_Cursor_getStorageClass` are missing from the `FUNCTION_LIST` and thus never registered to the `conf.lib` object. From what I've tested they still seem to work just fine, we also have working tests for these... 

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


More information about the cfe-commits mailing list