Skip to content

Commit

Permalink
Apply latest ruff fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanslenders committed May 16, 2024
1 parent 9cb57b1 commit 7230ee0
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ptpython/history_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def __init__(

if len(history_strings) > HISTORY_COUNT:
history_lines[0] = (
"# *** History has been truncated to %s lines ***" % HISTORY_COUNT
f"# *** History has been truncated to {HISTORY_COUNT} lines ***"
)

self.history_lines = history_lines
Expand Down
9 changes: 4 additions & 5 deletions ptpython/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def get_completions(

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


class AliasCompleter(Completer):
Expand All @@ -173,7 +173,7 @@ def get_completions(

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


class IPythonInput(PythonInput):
Expand Down Expand Up @@ -280,9 +280,8 @@ def initialize_extensions(shell, extensions):
shell.extension_manager.load_extension(ext)
except:
warn(
"Error in loading extension: %s" % ext
+ "\nCheck your config files in %s"
% ipy_utils.path.get_ipython_dir()
f"Error in loading extension: {ext}"
+ f"\nCheck your config files in {ipy_utils.path.get_ipython_dir()}"
)
shell.showtraceback()

Expand Down
4 changes: 2 additions & 2 deletions ptpython/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def goto_next(mouse_event: MouseEvent) -> None:
tokens.append(("class:sidebar" + sel, " >" if selected else " "))
tokens.append(("class:sidebar.label" + sel, "%-24s" % label, select_item))
tokens.append(("class:sidebar.status" + sel, " ", select_item))
tokens.append(("class:sidebar.status" + sel, "%s" % status, goto_next))
tokens.append(("class:sidebar.status" + sel, f"{status}", goto_next))

if selected:
tokens.append(("[SetCursorPosition]", ""))
Expand Down Expand Up @@ -529,7 +529,7 @@ def create_exit_confirmation(
def get_text_fragments() -> StyleAndTextTuples:
# Show "Do you really want to exit?"
return [
(style, "\n %s ([y]/n) " % python_input.exit_message),
(style, f"\n {python_input.exit_message} ([y]/n) "),
("[SetCursorPosition]", ""),
(style, " \n"),
]
Expand Down
4 changes: 2 additions & 2 deletions ptpython/prompt_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, python_input: PythonInput) -> None:
def in_prompt(self) -> AnyFormattedText:
return [
("class:in", "In ["),
("class:in.number", "%s" % self.python_input.current_statement_index),
("class:in.number", f"{self.python_input.current_statement_index}"),
("class:in", "]: "),
]

Expand All @@ -58,7 +58,7 @@ def in2_prompt(self, width: int) -> AnyFormattedText:
def out_prompt(self) -> AnyFormattedText:
return [
("class:out", "Out["),
("class:out.number", "%s" % self.python_input.current_statement_index),
("class:out.number", f"{self.python_input.current_statement_index}"),
("class:out", "]:"),
("", " "),
]
Expand Down
8 changes: 4 additions & 4 deletions ptpython/python_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,18 +880,18 @@ def get_values() -> dict[str, Callable[[], bool]]:
Option(
title="Min brightness",
description="Minimum brightness for the color scheme (default=0.0).",
get_current_value=lambda: "%.2f" % self.min_brightness,
get_current_value=lambda: f"{self.min_brightness:.2f}",
get_values=lambda: {
"%.2f" % value: partial(self._set_min_brightness, value)
f"{value:.2f}": partial(self._set_min_brightness, value)
for value in brightness_values
},
),
Option(
title="Max brightness",
description="Maximum brightness for the color scheme (default=1.0).",
get_current_value=lambda: "%.2f" % self.max_brightness,
get_current_value=lambda: f"{self.max_brightness:.2f}",
get_values=lambda: {
"%.2f" % value: partial(self._set_max_brightness, value)
f"{value:.2f}": partial(self._set_max_brightness, value)
for value in brightness_values
},
),
Expand Down
2 changes: 1 addition & 1 deletion ptpython/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def validate(self, document: Document) -> None:
except ValueError as e:
# In Python 2, compiling "\x9" (an invalid escape sequence) raises
# ValueError instead of SyntaxError.
raise ValidationError(0, "Syntax Error: %s" % e)
raise ValidationError(0, f"Syntax Error: {e}")
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@
"console_scripts": [
"ptpython = ptpython.entry_points.run_ptpython:run",
"ptipython = ptpython.entry_points.run_ptipython:run",
"ptpython%s = ptpython.entry_points.run_ptpython:run" % sys.version_info[0],
f"ptpython{sys.version_info[0]} = ptpython.entry_points.run_ptpython:run",
"ptpython{}.{} = ptpython.entry_points.run_ptpython:run".format(
*sys.version_info[:2]
),
"ptipython%s = ptpython.entry_points.run_ptipython:run"
% sys.version_info[0],
f"ptipython{sys.version_info[0]} = ptpython.entry_points.run_ptipython:run",
"ptipython{}.{} = ptpython.entry_points.run_ptipython:run".format(
*sys.version_info[:2]
),
Expand Down

0 comments on commit 7230ee0

Please sign in to comment.