github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r origin/main...HEAD 
clang/bindings/python/clang/cindex.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- cindex.py   2025-12-29 09:09:01.000000 +0000
+++ cindex.py   2025-12-29 09:12:15.716887 +0000
@@ -143,11 +143,13 @@
         if val is None:
             return None
         return val.decode("utf8")
 
     @classmethod
-    def from_param(cls: TType["c_interop_string"], param: str | bytes | None) 
-> c_interop_string:
+    def from_param(
+        cls: TType["c_interop_string"], param: str | bytes | None
+    ) -> c_interop_string:
         if isinstance(param, str):
             return cls(param)
         if isinstance(param, bytes):
             return cls(param)
         if param is None:
@@ -292,11 +294,13 @@
                 f = None
             self._data = (f, int(l.value), int(c.value), int(o.value))
         return self._data
 
     @staticmethod
-    def from_position(tu: TranslationUnit, file: File, line: int, column: int) 
-> SourceLocation:
+    def from_position(
+        tu: TranslationUnit, file: File, line: int, column: int
+    ) -> SourceLocation:
         """
         Retrieve the source location associated with a given file/line/column 
in
         a particular translation unit.
         """
         return conf.lib.clang_getLocation(tu, file, line, column)  # type: 
ignore [no-any-return]
@@ -603,11 +607,13 @@
         # If we get no tokens, no memory was allocated. Be sure not to return
         # anything and potentially call a destructor on nothing.
         if count < 1:
             return
 
-        tokens_array: Array[Token] = cast(tokens_memory, POINTER(Token * 
count)).contents
+        tokens_array: Array[Token] = cast(
+            tokens_memory, POINTER(Token * count)
+        ).contents
 
         token_group: TokenGroup = TokenGroup(tu, tokens_memory, tokens_count)
 
         for i in range(0, count):
             token: Token = Token()
@@ -2713,11 +2719,13 @@
 
                 if key < 0:
                     raise IndexError("Only non-negative indexes are accepted.")
 
                 if key >= len(self):
-                    raise IndexError(f"Index greater than container length: 
{key} > {len(self)}")
+                    raise IndexError(
+                        f"Index greater than container length: {key} > 
{len(self)}"
+                    )
 
                 result: Type = Type.from_result(
                     conf.lib.clang_getArgType(self.parent, key), self.parent
                 )
                 if result.kind == TypeKind.INVALID:
@@ -3080,11 +3088,13 @@
     def kind(self) -> Kind:
         return completionChunkKindMap[self.__kindNumber]
 
     @CachedProperty
     def string(self) -> CompletionString | None:
-        res: CObjP = 
conf.lib.clang_getCompletionChunkCompletionString(self.cs, self.key)
+        res: CObjP = conf.lib.clang_getCompletionChunkCompletionString(
+            self.cs, self.key
+        )
 
         if not res:
             return None
         return CompletionString(res)
 
@@ -3273,13 +3283,14 @@
         """Load a TranslationUnit from the given AST file."""
         return TranslationUnit.from_ast_file(path, self)
 
     def parse(
         self,
-        path: str, args: list[str] | None = None,
+        path: str,
+        args: list[str] | None = None,
         unsaved_files: list[tuple[str, str]] | None = None,
-        options: int = 0
+        options: int = 0,
     ) -> TranslationUnit:
         """Load the translation unit from the given source code file by running
         clang and generating the AST before loading. Additional command line
         parameters can be passed to clang via the args parameter.
 
@@ -3352,11 +3363,11 @@
         cls: type[TranslationUnit],
         filename: str | None,
         args: list[str] | None = None,
         unsaved_files: list[tuple[str, str]] | None = None,
         options: int = 0,
-        index: Index | None = None
+        index: Index | None = None,
     ) -> TranslationUnit:
         """Create a TranslationUnit by parsing source.
 
         This is capable of processing source code both from files on the
         filesystem as well as in-memory contents.
@@ -3424,11 +3435,13 @@
             raise TranslationUnitLoadError("Error parsing translation unit.")
 
         return cls(ptr, index=index)
 
     @classmethod
-    def from_ast_file(cls, filename: str | PathLike, index: Index | None = 
None) -> TranslationUnit:
+    def from_ast_file(
+        cls, filename: str | PathLike, index: Index | None = None
+    ) -> TranslationUnit:
         """Create a TranslationUnit instance from a saved AST file.
 
         A previously-saved AST file (provided with -emit-ast or
         TranslationUnit.save()) is loaded from the filename specified.
 
@@ -3479,11 +3492,13 @@
         this sequence is always the input file. Note that this method will not
         recursively iterate over header files included through precompiled
         headers.
         """
 
-        def visitor(fobj: CObjP, lptr: Any, depth: int, includes: 
list[FileInclusion]) -> None:
+        def visitor(
+            fobj: CObjP, lptr: Any, depth: int, includes: list[FileInclusion]
+        ) -> None:
             if depth > 0:
                 loc: SourceLocation = lptr.contents
                 includes.append(FileInclusion(loc.file, File(fobj), loc, 
depth))
 
         # Automatically adapt CIndex/ctype pointers to python objects
@@ -3497,11 +3512,13 @@
     def get_file(self, filename: str | PathLike) -> File:
         """Obtain a File from this translation unit."""
 
         return File.from_name(self, filename)
 
-    def get_location(self, filename: str | PathLike, position: int | 
tuple[int, int]) -> SourceLocation:
+    def get_location(
+        self, filename: str | PathLike, position: int | tuple[int, int]
+    ) -> SourceLocation:
         """Obtain a SourceLocation for a file in this translation unit.
 
         The position can be specified by passing:
 
           - Integer file offset. Initial file offset is 0.
@@ -3513,11 +3530,13 @@
         if isinstance(position, int):
             return SourceLocation.from_offset(self, f, position)
 
         return SourceLocation.from_position(self, f, position[0], position[1])
 
-    def get_extent(self, filename: str | PathLike, locations: 
Sequence[object]) -> SourceRange:
+    def get_extent(
+        self, filename: str | PathLike, locations: Sequence[object]
+    ) -> SourceRange:
         """Obtain a SourceRange from this translation unit.
 
         The bounds of the SourceRange must ultimately be defined by a start and
         end SourceLocation. For the locations argument, you can pass:
 
@@ -3577,11 +3596,13 @@
                     raise IndexError
                 return Diagnostic(diag)
 
         return DiagIterator(self)
 
-    def reparse(self, unsaved_files: list[tuple[str, str]] | None = None, 
options: int = 0) -> None:
+    def reparse(
+        self, unsaved_files: list[tuple[str, str]] | None = None, options: int 
= 0
+    ) -> None:
         """
         Reparse an already parsed translation unit.
 
         In-memory contents for files can be provided by passing a list of pairs
         as unsaved_files, the first items should be the filenames to be mapped
@@ -3674,11 +3695,11 @@
         return None
 
     def get_tokens(
         self,
         locations: tuple[SourceLocation, SourceLocation] | None = None,
-        extent: SourceRange | 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
@@ -3749,11 +3770,13 @@
     unit. This class provides information about the included file, the 
including
     file, the location of the '#include' directive and the depth of the 
included
     file in the stack. Note that the input file has depth 0.
     """
 
-    def __init__(self, src: File | None, tgt: File, loc: SourceLocation, 
depth: int) -> None:
+    def __init__(
+        self, src: File | None, tgt: File, loc: SourceLocation, depth: int
+    ) -> None:
         self.source: File | None = src
         self.include: File = tgt
         self.location: SourceLocation = loc
         self.depth: int = depth
 

``````````

</details>


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