From ef903326fbc19419cced1fe5c4c10fef32e23647 Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Fri, 17 Jan 2025 16:11:34 +0000 Subject: [PATCH] Fix code formatting (ruff). --- examples/dialogs/progress_dialog.py | 3 +-- examples/prompts/colored-prompt.py | 7 +------ src/prompt_toolkit/filters/base.py | 3 +-- src/prompt_toolkit/layout/processors.py | 6 +++--- tests/test_cli.py | 4 ++-- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/examples/dialogs/progress_dialog.py b/examples/dialogs/progress_dialog.py index 7a29f1bb9..3d5227bc6 100755 --- a/examples/dialogs/progress_dialog.py +++ b/examples/dialogs/progress_dialog.py @@ -38,8 +38,7 @@ def worker(set_percentage, log_text): def main(): progress_dialog( title="Progress dialog example", - text="As an examples, we walk through the filesystem and print " - "all directories", + text="As an examples, we walk through the filesystem and print all directories", run_callback=worker, ).run() diff --git a/examples/prompts/colored-prompt.py b/examples/prompts/colored-prompt.py index 428ff1dd0..883b3cf20 100755 --- a/examples/prompts/colored-prompt.py +++ b/examples/prompts/colored-prompt.py @@ -66,12 +66,7 @@ def example_3(): Using ANSI for the formatting. """ answer = prompt( - ANSI( - "\x1b[31mjohn\x1b[0m@" - "\x1b[44mlocalhost\x1b[0m:" - "\x1b[4m/user/john\x1b[0m" - "# " - ) + ANSI("\x1b[31mjohn\x1b[0m@\x1b[44mlocalhost\x1b[0m:\x1b[4m/user/john\x1b[0m# ") ) print(f"You said: {answer}") diff --git a/src/prompt_toolkit/filters/base.py b/src/prompt_toolkit/filters/base.py index 410749db4..cd95424dc 100644 --- a/src/prompt_toolkit/filters/base.py +++ b/src/prompt_toolkit/filters/base.py @@ -81,8 +81,7 @@ def __bool__(self) -> None: instead of for instance ``filter1 or Always()``. """ raise ValueError( - "The truth value of a Filter is ambiguous. " - "Instead, call it as a function." + "The truth value of a Filter is ambiguous. Instead, call it as a function." ) diff --git a/src/prompt_toolkit/layout/processors.py b/src/prompt_toolkit/layout/processors.py index 8208018d0..666e79c66 100644 --- a/src/prompt_toolkit/layout/processors.py +++ b/src/prompt_toolkit/layout/processors.py @@ -847,9 +847,9 @@ def filter_processor(item: Processor) -> Processor | None: def apply_transformation(self, ti: TransformationInput) -> Transformation: from .controls import SearchBufferControl - assert isinstance( - ti.buffer_control, SearchBufferControl - ), "`ReverseSearchProcessor` should be applied to a `SearchBufferControl` only." + assert isinstance(ti.buffer_control, SearchBufferControl), ( + "`ReverseSearchProcessor` should be applied to a `SearchBufferControl` only." + ) source_to_display: SourceToDisplay | None display_to_source: DisplayToSource | None diff --git a/tests/test_cli.py b/tests/test_cli.py index c155325f9..a876f2993 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -870,11 +870,11 @@ def test_vi_temp_navigation_mode(): """ feed = partial(_feed_cli_with_input, editing_mode=EditingMode.VI) - result, cli = feed("abcde" "\x0f" "3h" "x\r") # c-o # 3 times to the left. + result, cli = feed("abcde\x0f3hx\r") # c-o # 3 times to the left. assert result.text == "axbcde" assert result.cursor_position == 2 - result, cli = feed("abcde" "\x0f" "b" "x\r") # c-o # One word backwards. + result, cli = feed("abcde\x0fbx\r") # c-o # One word backwards. assert result.text == "xabcde" assert result.cursor_position == 1