Skip to content

[libclang/python] Fix Type.get_offset annotation#187841

Merged
DeinAlptraum merged 1 commit intollvm:mainfrom
DeinAlptraum:bytes-annotations
Mar 21, 2026
Merged

[libclang/python] Fix Type.get_offset annotation#187841
DeinAlptraum merged 1 commit intollvm:mainfrom
DeinAlptraum:bytes-annotations

Conversation

@DeinAlptraum
Copy link
Copy Markdown
Contributor

As discussed in #180876 (comment), Type.get_offset can process bytes arguments as well. For consistency with other functions taking str arguments, its type annotation is adapted to reflect this.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:as-a-library libclang and C++ API labels Mar 21, 2026
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Mar 21, 2026

@llvm/pr-subscribers-clang

Author: Jannick Kremer (DeinAlptraum)

Changes

As discussed in #180876 (comment), Type.get_offset can process bytes arguments as well. For consistency with other functions taking str arguments, its type annotation is adapted to reflect this.


Full diff: https://github.com/llvm/llvm-project/pull/187841.diff

1 Files Affected:

  • (modified) clang/bindings/python/clang/cindex.py (+1-1)
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index c34a1c0db01e9..57e1855886b8b 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -2919,7 +2919,7 @@ def get_size(self) -> int:
         """
         return conf.lib.clang_Type_getSizeOf(self)  # type: ignore [no-any-return]
 
-    def get_offset(self, fieldname: str) -> int:
+    def get_offset(self, fieldname: TUnion[str, bytes]) -> int:
         """
         Retrieve the offset of a field in the record.
         """

@DeinAlptraum DeinAlptraum requested a review from Endilll March 21, 2026 14:31
@DeinAlptraum DeinAlptraum merged commit 82eee26 into llvm:main Mar 21, 2026
15 checks passed
ambergorzynski pushed a commit to ambergorzynski/llvm-project that referenced this pull request Mar 27, 2026
As discussed in
llvm#180876 (comment),
`Type.get_offset` can process `bytes` arguments as well. For consistency
with other functions taking `str` arguments, its type annotation is
adapted to reflect this.
Aadarsh-Keshri pushed a commit to Aadarsh-Keshri/llvm-project that referenced this pull request Mar 28, 2026
As discussed in
llvm#180876 (comment),
`Type.get_offset` can process `bytes` arguments as well. For consistency
with other functions taking `str` arguments, its type annotation is
adapted to reflect this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:as-a-library libclang and C++ API clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants