Endilll wrote:

> I have noticed the code did use fstrings previously in a few locations, but 
> string interpolation is generally a lesser cognitive load to read than the 
> `str.format()` method which puts all the variables at the end. Personally I 
> think it's easier to read the interpolated string with arguments in place.

When I'm looking at the changes you propose:
```diff
-         return "<SourceLocation file %r, line %r, column %r>" % (
-             filename,
-             self.line,
-             self.column,
-         )
+         return f"<SourceLocation file {filename!r}, line {self.line!r}, 
column {self.column!r}>"
```
or
```diff
-        return "<Diagnostic severity %r, location %r, spelling %r>" % (
-            self.severity,
-            self.location,
-            self.spelling,
-        )
+        return f"<Diagnostic severity {self.severity!r}, location 
{self.location!r}, spelling {self.spelling!r}>"
```
I'm sorry I fail to notice the reduction in cognitive load.

CC @DeinAlptraum if you think f-strings are an improvement, that's your chance 
to convince me.

https://github.com/llvm/llvm-project/pull/173861
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to