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

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 05:54:22 PST 2026


================
@@ -103,9 +103,14 @@
 
 if TYPE_CHECKING:
     from ctypes import _Pointer
+    from io import TextIOWrapper
     from typing_extensions import Protocol, TypeAlias
 
     StrPath: TypeAlias = TUnion[str, os.PathLike[str]]
+    # The type that is compatible with os.fspath:
+    # str, bytes, or os.PathLikes that return either of these two
+    StrBytesPath: TypeAlias = TUnion[str, bytes, os.PathLike[str], os.PathLike[bytes]]
----------------
DeinAlptraum wrote:

The `os` moduke like many (all?) other Python standard library modules comes with type stubs that are defined separately in the typeshed project. `PathLike
For `PathLike`, see here: https://github.com/python/typeshed/blob/637ece0f0d69e4df5744ada66c4aa35cf20d8a13/stdlib/os/__init__.pyi#L881

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


More information about the cfe-commits mailing list