Skip to content

Commit 3ec97d7

Browse files
Apply latest ruff fixes.
1 parent 5fb21bd commit 3ec97d7

File tree

7 files changed

+16
-18
lines changed

7 files changed

+16
-18
lines changed

ptpython/history_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def __init__(
411411

412412
if len(history_strings) > HISTORY_COUNT:
413413
history_lines[0] = (
414-
"# *** History has been truncated to %s lines ***" % HISTORY_COUNT
414+
f"# *** History has been truncated to {HISTORY_COUNT} lines ***"
415415
)
416416

417417
self.history_lines = history_lines

ptpython/ipython.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def get_completions(
157157

158158
for m in sorted(self.magics_manager.magics["line"]):
159159
if m.startswith(text):
160-
yield Completion("%s" % m, -len(text))
160+
yield Completion(f"{m}", -len(text))
161161

162162

163163
class AliasCompleter(Completer):
@@ -173,7 +173,7 @@ def get_completions(
173173

174174
for a, cmd in sorted(aliases, key=lambda a: a[0]):
175175
if a.startswith(text):
176-
yield Completion("%s" % a, -len(text), display_meta=cmd)
176+
yield Completion(f"{a}", -len(text), display_meta=cmd)
177177

178178

179179
class IPythonInput(PythonInput):
@@ -280,9 +280,8 @@ def initialize_extensions(shell, extensions):
280280
shell.extension_manager.load_extension(ext)
281281
except:
282282
warn(
283-
"Error in loading extension: %s" % ext
284-
+ "\nCheck your config files in %s"
285-
% ipy_utils.path.get_ipython_dir()
283+
f"Error in loading extension: {ext}"
284+
+ f"\nCheck your config files in {ipy_utils.path.get_ipython_dir()}"
286285
)
287286
shell.showtraceback()
288287

ptpython/layout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def goto_next(mouse_event: MouseEvent) -> None:
132132
tokens.append(("class:sidebar" + sel, " >" if selected else " "))
133133
tokens.append(("class:sidebar.label" + sel, "%-24s" % label, select_item))
134134
tokens.append(("class:sidebar.status" + sel, " ", select_item))
135-
tokens.append(("class:sidebar.status" + sel, "%s" % status, goto_next))
135+
tokens.append(("class:sidebar.status" + sel, f"{status}", goto_next))
136136

137137
if selected:
138138
tokens.append(("[SetCursorPosition]", ""))
@@ -529,7 +529,7 @@ def create_exit_confirmation(
529529
def get_text_fragments() -> StyleAndTextTuples:
530530
# Show "Do you really want to exit?"
531531
return [
532-
(style, "\n %s ([y]/n) " % python_input.exit_message),
532+
(style, f"\n {python_input.exit_message} ([y]/n) "),
533533
("[SetCursorPosition]", ""),
534534
(style, " \n"),
535535
]

ptpython/prompt_style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, python_input: PythonInput) -> None:
4848
def in_prompt(self) -> AnyFormattedText:
4949
return [
5050
("class:in", "In ["),
51-
("class:in.number", "%s" % self.python_input.current_statement_index),
51+
("class:in.number", f"{self.python_input.current_statement_index}"),
5252
("class:in", "]: "),
5353
]
5454

@@ -58,7 +58,7 @@ def in2_prompt(self, width: int) -> AnyFormattedText:
5858
def out_prompt(self) -> AnyFormattedText:
5959
return [
6060
("class:out", "Out["),
61-
("class:out.number", "%s" % self.python_input.current_statement_index),
61+
("class:out.number", f"{self.python_input.current_statement_index}"),
6262
("class:out", "]:"),
6363
("", " "),
6464
]

ptpython/python_input.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,18 +880,18 @@ def get_values() -> dict[str, Callable[[], bool]]:
880880
Option(
881881
title="Min brightness",
882882
description="Minimum brightness for the color scheme (default=0.0).",
883-
get_current_value=lambda: "%.2f" % self.min_brightness,
883+
get_current_value=lambda: f"{self.min_brightness:.2f}",
884884
get_values=lambda: {
885-
"%.2f" % value: partial(self._set_min_brightness, value)
885+
f"{value:.2f}": partial(self._set_min_brightness, value)
886886
for value in brightness_values
887887
},
888888
),
889889
Option(
890890
title="Max brightness",
891891
description="Maximum brightness for the color scheme (default=1.0).",
892-
get_current_value=lambda: "%.2f" % self.max_brightness,
892+
get_current_value=lambda: f"{self.max_brightness:.2f}",
893893
get_values=lambda: {
894-
"%.2f" % value: partial(self._set_max_brightness, value)
894+
f"{value:.2f}": partial(self._set_max_brightness, value)
895895
for value in brightness_values
896896
},
897897
),

ptpython/validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ def validate(self, document: Document) -> None:
5959
except ValueError as e:
6060
# In Python 2, compiling "\x9" (an invalid escape sequence) raises
6161
# ValueError instead of SyntaxError.
62-
raise ValidationError(0, "Syntax Error: %s" % e)
62+
raise ValidationError(0, f"Syntax Error: {e}")

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@
4747
"console_scripts": [
4848
"ptpython = ptpython.entry_points.run_ptpython:run",
4949
"ptipython = ptpython.entry_points.run_ptipython:run",
50-
"ptpython%s = ptpython.entry_points.run_ptpython:run" % sys.version_info[0],
50+
f"ptpython{sys.version_info[0]} = ptpython.entry_points.run_ptpython:run",
5151
"ptpython{}.{} = ptpython.entry_points.run_ptpython:run".format(
5252
*sys.version_info[:2]
5353
),
54-
"ptipython%s = ptpython.entry_points.run_ptipython:run"
55-
% sys.version_info[0],
54+
f"ptipython{sys.version_info[0]} = ptpython.entry_points.run_ptipython:run",
5655
"ptipython{}.{} = ptpython.entry_points.run_ptipython:run".format(
5756
*sys.version_info[:2]
5857
),

0 commit comments

Comments
 (0)