Skip to content

Commit 2f7899b

Browse files
committed
Use more f-strings
1 parent 535d4e9 commit 2f7899b

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

bpython/curtsiesfrontend/interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def format(self, tokensource, outfile):
5555
for token, text in tokensource:
5656
while token not in self.f_strings:
5757
token = token.parent
58-
o += "{}\x03{}\x04".format(self.f_strings[token], text)
58+
o += f"{self.f_strings[token]}\x03{text}\x04"
5959
outfile.write(parse(o.rstrip()))
6060

6161

bpython/curtsiesfrontend/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ def key_help_text(self):
20672067

20682068
max_func = max(len(func) for func, key in pairs)
20692069
return "\n".join(
2070-
"{} : {}".format(func.rjust(max_func), key) for func, key in pairs
2070+
f"{func.rjust(max_func)} : {key}" for func, key in pairs
20712071
)
20722072

20732073
def get_session_formatted_for_file(self) -> str:

bpython/formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class BPythonFormatter(Formatter):
9999
def __init__(self, color_scheme, **options):
100100
self.f_strings = {}
101101
for k, v in theme_map.items():
102-
self.f_strings[k] = "\x01{}".format(color_scheme[v])
102+
self.f_strings[k] = f"\x01{color_scheme[v]}"
103103
if k is Parenthesis:
104104
# FIXME: Find a way to make this the inverse of the current
105105
# background colour
@@ -114,7 +114,7 @@ def format(self, tokensource, outfile):
114114

115115
while token not in self.f_strings:
116116
token = token.parent
117-
o += "{}\x03{}\x04".format(self.f_strings[token], text)
117+
o += f"{self.f_strings[token]}\x03{text}\x04"
118118
outfile.write(o.rstrip())
119119

120120

bpython/simpleeval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def safe_getitem(obj, index):
203203
return obj[index]
204204
except (KeyError, IndexError):
205205
raise EvaluationError(f"can't lookup key {index!r} on {obj!r}")
206-
raise ValueError("unsafe to lookup on object of type {}".format(type(obj)))
206+
raise ValueError(f"unsafe to lookup on object of type {type(obj)}")
207207

208208

209209
def find_attribute_with_name(node, name):

0 commit comments

Comments
 (0)