================
@@ -311,36 +320,36 @@ def from_offset(tu, file, offset):
         return conf.lib.clang_getLocationForOffset(tu, file, offset)  # type: 
ignore [no-any-return]
 
     @property
-    def file(self):
+    def file(self) -> File | None:
         """Get the file represented by this source location."""
         return self._get_instantiation()[0]
 
     @property
-    def line(self):
+    def line(self) -> int:
         """Get the line represented by this source location."""
         return self._get_instantiation()[1]
 
     @property
-    def column(self):
+    def column(self) -> int:
         """Get the column represented by this source location."""
         return self._get_instantiation()[2]
 
     @property
-    def offset(self):
+    def offset(self) -> int:
         """Get the file offset represented by this source location."""
         return self._get_instantiation()[3]
 
     @property
-    def is_in_system_header(self):
+    def is_in_system_header(self) -> bool:
         """Returns true if the given source location is in a system header."""
         return bool(conf.lib.clang_Location_isInSystemHeader(self))
 
-    def __eq__(self, other):
+    def __eq__(self, other: object) -> bool:
----------------
DeinAlptraum wrote:

As I also actually just learned the other day, the suggested behavior here is 
to throw `NotImplemented`, see here: 
https://docs.python.org/3/library/constants.html#NotImplemented

If you do `operator(a, b)` when `type(a) != type(b)`, then if `a` returns 
`NotImplemented`, it is then attempted to call the `__eq__` implementation of 
whatever type `b` is of, and when that does not allow comparison (also 
returning `NotImplemented`) an exception is raised

https://github.com/llvm/llvm-project/pull/173845
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to