[clang] [libclang/python] Add type annotations to the TranslationUnit class (PR #180876)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 15 08:40:37 PST 2026
================
@@ -3797,18 +3825,22 @@ def codeComplete(
return CodeCompletionResults(ptr)
return None
- def get_tokens(self, locations=None, extent=None):
+ def get_tokens(
+ self,
+ locations: tuple[SourceLocation, SourceLocation] | None = None,
+ extent: SourceRange | None = None,
+ ) -> Iterator[Token]:
"""Obtain tokens in this translation unit.
This is a generator for Token instances. The caller specifies a range
of source code to obtain tokens for. The range can be specified as a
2-tuple of SourceLocation or as a SourceRange. If both are defined,
behavior is undefined.
----------------
Endilll wrote:
I'm not happy how we silently ignore `extent` when `locations` is specified. Can we add a check to throw an appropriate exception when both are passed?
https://github.com/llvm/llvm-project/pull/180876
More information about the cfe-commits
mailing list