[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:21 PDT 2025
================
@@ -1552,68 +1563,83 @@ class Cursor(Structure):
_fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]
+ _tu: TranslationUnit
+
@staticmethod
- def from_location(tu, location):
+ def from_location(tu: TranslationUnit, location: SourceLocation) -> Cursor:
----------------
Endilll wrote:
`clang_getCursor` can return null cursor, so I think we want to wrap the call in `from_cursor_result`, and change the return type to `Cursor | None`.
https://github.com/llvm/llvm-project/pull/138103
More information about the cfe-commits
mailing list