================
@@ -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:

Okay, I did find a way to do this after all. I made the `Config` object keep a 
null-cursor instance on hand and use this to implement a `Cursor.is_null` 
(rather than calling `cursor_getNullCursor` every time), and added a guard that 
assert that the cursor is not null on all method and property calls.

@Endilll I don't entirely understand what you mean by 
> should drop | None part of type hint

considering
> Instead of the assert you propose, I think all Cursor methods should assert 
> that self is not a null cursor,

Unless we change the annotation of `Cursor.from_cursor_result` to return type 
`Cursor` or add an assert or similar inside the `canonical` property that the 
return is not `None`, the type checker won't except that the return type of 
`canonical` is just `Cursor`

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

Reply via email to