-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pyupgrade] Automatically rewrite format-strings to f-strings (#1905)
- Loading branch information
Showing
13 changed files
with
774 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
### | ||
# Errors | ||
### | ||
|
||
"{} {}".format(a, b) | ||
|
||
"{1} {0}".format(a, b) | ||
|
||
"{x.y}".format(x=z) | ||
|
||
"{.x} {.y}".format(a, b) | ||
|
||
"{} {}".format(a.b, c.d) | ||
|
||
"{}".format(a()) | ||
|
||
"{}".format(a.b()) | ||
|
||
"{}".format(a.b().c()) | ||
|
||
"hello {}!".format(name) | ||
|
||
"{}{b}{}".format(a, c, b=b) | ||
|
||
"{}".format(0x0) | ||
|
||
"{} {}".format(a, b) | ||
|
||
"""{} {}""".format(a, b) | ||
|
||
"foo{}".format(1) | ||
|
||
r"foo{}".format(1) | ||
|
||
x = "{a}".format(a=1) | ||
|
||
print("foo {} ".format(x)) | ||
|
||
"{a[b]}".format(a=a) | ||
|
||
"{a.a[b]}".format(a=a) | ||
|
||
"{}{{}}{}".format(escaped, y) | ||
|
||
"{}".format(a) | ||
|
||
### | ||
# Non-errors | ||
### | ||
|
||
# False-negative: RustPython doesn't parse the `\N{snowman}`. | ||
"\N{snowman} {}".format(a) | ||
|
||
"{".format(a) | ||
|
||
"}".format(a) | ||
|
||
"{} {}".format(*a) | ||
|
||
"{0} {0}".format(arg) | ||
|
||
"{x} {x}".format(arg) | ||
|
||
"{x.y} {x.z}".format(arg) | ||
|
||
b"{} {}".format(a, b) | ||
|
||
"{:{}}".format(x, y) | ||
|
||
"{}{}".format(a) | ||
|
||
"" "{}".format(a["\\"]) | ||
|
||
"{}".format(a["b"]) | ||
|
||
r'"\N{snowman} {}".format(a)' | ||
|
||
"{a}" "{b}".format(a=1, b=1) | ||
|
||
|
||
async def c(): | ||
return "{}".format(await 3) | ||
|
||
|
||
async def c(): | ||
return "{}".format(1 + await 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1687,6 +1687,7 @@ | |
"UP029", | ||
"UP03", | ||
"UP030", | ||
"UP032", | ||
"W", | ||
"W2", | ||
"W29", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.