Skip to content

Commit

Permalink
Code style fixes for compatibility with latest Ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanslenders committed May 15, 2024
1 parent 85079ad commit 3c0290d
Show file tree
Hide file tree
Showing 206 changed files with 346 additions and 250 deletions.
1 change: 1 addition & 0 deletions examples/dialogs/button_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of button dialog window.
"""

from prompt_toolkit.shortcuts import button_dialog


Expand Down
3 changes: 2 additions & 1 deletion examples/dialogs/checkbox_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of a checkbox-list-based dialog.
"""

from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import checkboxlist_dialog, message_dialog
from prompt_toolkit.styles import Style
Expand Down Expand Up @@ -30,7 +31,7 @@
if results:
message_dialog(
title="Room service",
text="You selected: %s\nGreat choice sir !" % ",".join(results),
text="You selected: {}\nGreat choice sir !".format(",".join(results)),
).run()
else:
message_dialog("*starves*").run()
1 change: 1 addition & 0 deletions examples/dialogs/input_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of an input box dialog.
"""

from prompt_toolkit.shortcuts import input_dialog


Expand Down
1 change: 1 addition & 0 deletions examples/dialogs/messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of a message box window.
"""

from prompt_toolkit.shortcuts import message_dialog


Expand Down
1 change: 1 addition & 0 deletions examples/dialogs/password_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of an password input dialog.
"""

from prompt_toolkit.shortcuts import input_dialog


Expand Down
1 change: 1 addition & 0 deletions examples/dialogs/progress_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of a progress bar dialog.
"""

import os
import time

Expand Down
1 change: 1 addition & 0 deletions examples/dialogs/radio_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of a radio list box dialog.
"""

from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import radiolist_dialog

Expand Down
1 change: 1 addition & 0 deletions examples/dialogs/styled_messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
This also demonstrates that the `title` argument can be any kind of formatted
text.
"""

from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import message_dialog
from prompt_toolkit.styles import Style
Expand Down
1 change: 1 addition & 0 deletions examples/dialogs/yes_no_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of confirmation (yes/no) dialog window.
"""

from prompt_toolkit.shortcuts import yes_no_dialog


Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
A simple example of a few buttons and click handlers.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.key_binding import KeyBindings
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A simple example of a calculator program.
This could be used as inspiration for a REPL.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.document import Document
from prompt_toolkit.key_binding import KeyBindings
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/dummy-app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
This is the most simple example possible.
"""

from prompt_toolkit import Application

app = Application(full_screen=False)
Expand Down
6 changes: 3 additions & 3 deletions examples/full-screen/full-screen-demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
"""
""" """

from pygments.lexers.html import HtmlLexer

from prompt_toolkit.application import Application
Expand Down Expand Up @@ -218,7 +218,7 @@ def do_exit():

def run():
result = application.run()
print("You said: %r" % result)
print(f"You said: {result!r}")


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/hello-world.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
A simple example of a a text area displaying "Hello World!".
"""

from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout import Layout
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/no-layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
An empty full screen application without layout.
"""

from prompt_toolkit import Application

Application(full_screen=True).run()
6 changes: 2 additions & 4 deletions examples/full-screen/pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
A simple application that shows a Pager application.
"""

from pygments.lexers.python import PythonLexer

from prompt_toolkit.application import Application
Expand All @@ -28,10 +29,7 @@ def get_statusbar_text():
("class:status", _pager_py_path + " - "),
(
"class:status.position",
"{}:{}".format(
text_area.document.cursor_position_row + 1,
text_area.document.cursor_position_col + 1,
),
f"{text_area.document.cursor_position_row + 1}:{text_area.document.cursor_position_col + 1}",
),
("class:status", " - Press "),
("class:status.key", "Ctrl-C"),
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/scrollable-panes/simple-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
A simple example of a scrollable pane.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.key_binding import KeyBindings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
A simple example of a scrollable pane.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.completion import WordCompleter
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Demo of the different Window alignment options.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import HSplit, Window, WindowAlign
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/autocompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Important is to make sure that there is a `CompletionsMenu` in the layout,
otherwise the completions won't be visible.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.completion import WordCompleter
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/colorcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Colorcolumn example.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.key_binding import KeyBindings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Cursorcolumn / cursorline example.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.key_binding import KeyBindings
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/float-transparency.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of the 'transparency' attribute of `Window' when used in a Float.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.key_binding import KeyBindings
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/floats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Horizontal split example.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import Float, FloatContainer, Window
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/focus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Demonstration of how to programmatically focus a certain widget.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.document import Document
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/horizontal-align.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Horizontal align demo with HSplit.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.key_binding import KeyBindings
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/horizontal-split.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Horizontal split example.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import HSplit, Window
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/line-prefixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Important is to make sure that there is a `CompletionsMenu` in the layout,
otherwise the completions won't be visible.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.filters import Condition
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/margins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
This is mainly used for displaying line numbers and scroll bars, but it could
be used to display any other kind of information as well.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.key_binding import KeyBindings
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/vertical-align.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Vertical align demo with VSplit.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.key_binding import KeyBindings
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/simple-demos/vertical-split.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Vertical split example.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import VSplit, Window
Expand Down
1 change: 1 addition & 0 deletions examples/full-screen/split-screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
This will show a window on the left for user input. When the user types, the
reversed input is shown on the right. Pressing Ctrl-Q will quit the application.
"""

from prompt_toolkit.application import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.key_binding import KeyBindings
Expand Down
6 changes: 2 additions & 4 deletions examples/full-screen/text-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
A simple example of a Notepad-like text editor.
"""

import datetime
from asyncio import Future, ensure_future

Expand Down Expand Up @@ -53,10 +54,7 @@ def get_statusbar_text():


def get_statusbar_right_text():
return " {}:{} ".format(
text_field.document.cursor_position_row + 1,
text_field.document.cursor_position_col + 1,
)
return f" {text_field.document.cursor_position_row + 1}:{text_field.document.cursor_position_col + 1} "


search_toolbar = SearchToolbar()
Expand Down
3 changes: 2 additions & 1 deletion examples/gevent-get-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
For testing: test to make sure that everything still works when gevent monkey
patches are applied.
"""

from gevent.monkey import patch_all

from prompt_toolkit.eventloop.defaults import create_event_loop
Expand All @@ -21,4 +22,4 @@ def dummy_inputhook(*a):
# Ask for input.
session = PromptSession("Give me some input: ", loop=eventloop)
answer = session.prompt()
print("You said: %s" % answer)
print(f"You said: {answer}")
1 change: 1 addition & 0 deletions examples/print-text/ansi-colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Demonstration of all the ANSI colors.
"""

from prompt_toolkit import print_formatted_text
from prompt_toolkit.formatted_text import HTML, FormattedText

Expand Down
1 change: 1 addition & 0 deletions examples/print-text/ansi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
The advantage here is that this is cross platform. The escape sequences will be
parsed and turned into appropriate Win32 API calls on Windows.
"""

from prompt_toolkit import print_formatted_text
from prompt_toolkit.formatted_text import ANSI, HTML

Expand Down
1 change: 1 addition & 0 deletions examples/print-text/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Demonstration of how to print using the HTML class.
"""

from prompt_toolkit import HTML, print_formatted_text

print = print_formatted_text
Expand Down
1 change: 1 addition & 0 deletions examples/print-text/named-colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Demonstration of all the ANSI colors.
"""

from prompt_toolkit import HTML, print_formatted_text
from prompt_toolkit.formatted_text import FormattedText
from prompt_toolkit.output import ColorDepth
Expand Down
1 change: 1 addition & 0 deletions examples/print-text/print-formatted-text.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Example of printing colored text to the output.
"""

from prompt_toolkit import print_formatted_text
from prompt_toolkit.formatted_text import ANSI, HTML, FormattedText
from prompt_toolkit.styles import Style
Expand Down
1 change: 1 addition & 0 deletions examples/print-text/print-frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Example usage of 'print_container', a tool to print
any layout in a non-interactive way.
"""

from prompt_toolkit.shortcuts import print_container
from prompt_toolkit.widgets import Frame, TextArea

Expand Down
1 change: 1 addition & 0 deletions examples/print-text/prompt-toolkit-logo-ansi-art.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
The ANSI output was generated using "pngtoansi": https://github.com/crgimenes/pngtoansi
(ESC still had to be replaced with \x1b
"""

from prompt_toolkit import print_formatted_text
from prompt_toolkit.formatted_text import ANSI

Expand Down
1 change: 1 addition & 0 deletions examples/print-text/pygments-tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Printing a list of Pygments (Token, text) tuples,
or an output of a Pygments lexer.
"""

import pygments
from pygments.lexers.python import PythonLexer
from pygments.token import Token
Expand Down
1 change: 1 addition & 0 deletions examples/print-text/true-color-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Demonstration of all the ANSI colors.
"""

from prompt_toolkit import print_formatted_text
from prompt_toolkit.formatted_text import HTML, FormattedText
from prompt_toolkit.output import ColorDepth
Expand Down
Loading

0 comments on commit 3c0290d

Please sign in to comment.