[clang] [libclang/python] Add type annotations to the TranslationUnit class (PR #180876)

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 10 19:17:19 PST 2026


================
@@ -3809,6 +3843,8 @@ def get_tokens(self, locations=None, extent=None):
             raise TypeError("get_tokens() requires at least one argument")
         if locations is not None:
             extent = SourceRange(start=locations[0], end=locations[1])
+        if extent is None:
+            raise TypeError("get_tokens() requires at least one argument")
----------------
DeinAlptraum wrote:

The previoius check ensured that either `locations` or `extent` is set, but in a way that the type checker doesn't understand. I changed this to ensure the type checker gets that the `extent` passed to `TokenGroup.get_tokens` in the end is not `None`.

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


More information about the cfe-commits mailing list