[clang] [clang][Python] Use fstrings instead of string concatenations (PR #173861)

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 13 13:49:05 PST 2026


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	2026-02-13 21:47:10.000000 +0000
+++ cindex.py	2026-02-13 21:48:37.111334 +0000
@@ -245,11 +245,13 @@
     def __get__(self, instance: TInstance, instance_type: Any = None) -> TResult:
         if instance is None:
             property_name = self.wrapped.__name__
             class_name = instance_type.__name__
             raise TypeError(
-                "'{}' is not a static attribute of '{}'".format(property_name, class_name)
+                "'{}' is not a static attribute of '{}'".format(
+                    property_name, class_name
+                )
             )
 
         value = self.wrapped(instance)
         setattr(instance, self.wrapped.__name__, value)
 
@@ -356,11 +358,13 @@
     def __repr__(self) -> str:
         if self.file:
             filename = self.file.name
         else:
             filename = None
-        return "<SourceLocation file {}, line {}, column {}>".format(filename, self.line, self.column)
+        return "<SourceLocation file {}, line {}, column {}>".format(
+            filename, self.line, self.column
+        )
 
 
 class SourceRange(Structure):
     """
     A SourceRange describes a range of source locations within the source
@@ -540,11 +544,13 @@
         if options & ~Diagnostic._FormatOptionsMask:
             raise ValueError("Invalid format options")
         return _CXString.from_result(conf.lib.clang_formatDiagnostic(self, options))
 
     def __repr__(self):
-        return "<Diagnostic severity {}, location {}, spelling {}>".format(self.severity, self.location, self.spelling)
+        return "<Diagnostic severity {}, location {}, spelling {}>".format(
+            self.severity, self.location, self.spelling
+        )
 
     def __str__(self):
         return self.format()
 
     def from_param(self):
@@ -2717,11 +2723,13 @@
                 if key < 0:
                     raise IndexError("Only non-negative indexes are accepted.")
 
                 if key >= len(self):
                     raise IndexError(
-                        "Index greater than container length: {} > {}".format(key, len(self))
+                        "Index greater than container length: {} > {}".format(
+                            key, len(self)
+                        )
                     )
 
                 result = Type.from_result(
                     conf.lib.clang_getArgType(self.parent, key), self.parent
                 )
@@ -3281,17 +3289,15 @@
     @property
     def briefComment(self) -> str:
         return _CXString.from_result(conf.lib.clang_getCompletionBriefComment(self.obj))
 
     def __repr__(self) -> str:
-        return (
-            "{} || Priority: {} || Availability: {} || Brief comment: {}".format(
-                " | ".join(str(a) for a in self),
-                self.priority,
-                self.availability,
-                self.briefComment
-            )
+        return "{} || Priority: {} || Availability: {} || Brief comment: {}".format(
+            " | ".join(str(a) for a in self),
+            self.priority,
+            self.availability,
+            self.briefComment,
         )
 
 
 class CodeCompletionResult(Structure):
     _fields_ = [("cursorKind", c_int), ("completionString", c_object_p)]

``````````

</details>


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


More information about the cfe-commits mailing list