================ @@ -1913,7 +1916,7 @@ def type(self): return self._type @property - def canonical(self): + def canonical(self) -> Cursor | None: """Return the canonical Cursor corresponding to this Cursor. ---------------- DeinAlptraum wrote:
This uses `Cursor.from_cursor_result` to create the return value. That function returns `None` if it is passed the Null-Cursor, leading to the `Cursor | None` return type. That said, the input to it is `clang_getCanonicalCursor` which does not seem to ever return the Null-Cursor, so we could theoretically constrain the return type here to just `Cursor`, by asserting `isinstance(the_return_value, Cursor)`, but this is a bit ugly... what do you think? https://github.com/llvm/llvm-project/pull/138103 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits