Skip to content

Commit 513b9f4

Browse files
Code formatting (latest black).
1 parent b857163 commit 513b9f4

File tree

9 files changed

+40
-41
lines changed

9 files changed

+40
-41
lines changed

ptpython/completer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def _get_item_lookup_completions(
468468
"""
469469

470470
def abbr_meta(text: str) -> str:
471-
" Abbreviate meta text, make sure it fits on one line. "
471+
"Abbreviate meta text, make sure it fits on one line."
472472
# Take first line, if multiple lines.
473473
if len(text) > 20:
474474
text = text[:20] + "..."
@@ -621,7 +621,7 @@ def is_private(completion: Completion) -> bool:
621621

622622

623623
class ReprFailedError(Exception):
624-
" Raised when the repr() call in `DictionaryCompleter` fails. "
624+
"Raised when the repr() call in `DictionaryCompleter` fails."
625625

626626

627627
try:

ptpython/entry_points/run_ptipython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def run(user_ns=None):
3131
path = a.args[0]
3232
with open(path, "rb") as f:
3333
code = compile(f.read(), path, "exec")
34-
exec(code, {'__name__': '__main__', '__file__': path})
34+
exec(code, {"__name__": "__main__", "__file__": path})
3535
else:
3636
enable_deprecation_warnings()
3737

ptpython/entry_points/run_ptpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def run() -> None:
183183
# causes imports to not be found. See issue #326.
184184
# However, an empty dict sets __name__ to 'builtins', which
185185
# breaks `if __name__ == '__main__'` checks. See issue #444.
186-
exec(code, {'__name__': '__main__', '__file__': path})
186+
exec(code, {"__name__": "__main__", "__file__": path})
187187

188188
# Run interactive shell.
189189
else:

ptpython/history_browser.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585

8686

8787
class BORDER:
88-
" Box drawing characters. "
88+
"Box drawing characters."
8989
HORIZONTAL = "\u2501"
9090
VERTICAL = "\u2503"
9191
TOP_LEFT = "\u250f"
@@ -420,7 +420,7 @@ def update_default_buffer(self):
420420

421421

422422
def _toggle_help(history):
423-
" Display/hide help. "
423+
"Display/hide help."
424424
help_buffer_control = history.history_layout.help_buffer_control
425425

426426
if history.app.layout.current_control == help_buffer_control:
@@ -430,7 +430,7 @@ def _toggle_help(history):
430430

431431

432432
def _select_other_window(history):
433-
" Toggle focus between left/right window. "
433+
"Toggle focus between left/right window."
434434
current_buffer = history.app.current_buffer
435435
layout = history.history_layout.layout
436436

@@ -513,45 +513,45 @@ def _(event):
513513
# Eager: ignore the Emacs [Ctrl-X Ctrl-X] binding.
514514
@handle("c-w", filter=main_buffer_focussed)
515515
def _(event):
516-
" Select other window. "
516+
"Select other window."
517517
_select_other_window(history)
518518

519519
@handle("f4")
520520
def _(event):
521-
" Switch between Emacs/Vi mode. "
521+
"Switch between Emacs/Vi mode."
522522
python_input.vi_mode = not python_input.vi_mode
523523

524524
@handle("f1")
525525
def _(event):
526-
" Display/hide help. "
526+
"Display/hide help."
527527
_toggle_help(history)
528528

529529
@handle("enter", filter=help_focussed)
530530
@handle("c-c", filter=help_focussed)
531531
@handle("c-g", filter=help_focussed)
532532
@handle("escape", filter=help_focussed)
533533
def _(event):
534-
" Leave help. "
534+
"Leave help."
535535
event.app.layout.focus_previous()
536536

537537
@handle("q", filter=main_buffer_focussed)
538538
@handle("f3", filter=main_buffer_focussed)
539539
@handle("c-c", filter=main_buffer_focussed)
540540
@handle("c-g", filter=main_buffer_focussed)
541541
def _(event):
542-
" Cancel and go back. "
542+
"Cancel and go back."
543543
event.app.exit(result=None)
544544

545545
@handle("enter", filter=main_buffer_focussed)
546546
def _(event):
547-
" Accept input. "
547+
"Accept input."
548548
event.app.exit(result=history.default_buffer.text)
549549

550550
enable_system_bindings = Condition(lambda: python_input.enable_system_bindings)
551551

552552
@handle("c-z", filter=enable_system_bindings)
553553
def _(event):
554-
" Suspend to background. "
554+
"Suspend to background."
555555
event.app.suspend_to_background()
556556

557557
return bindings
@@ -630,7 +630,7 @@ def _default_buffer_pos_changed(self, _):
630630
)
631631

632632
def _history_buffer_pos_changed(self, _):
633-
""" When the cursor changes in the history buffer. Synchronize. """
633+
"""When the cursor changes in the history buffer. Synchronize."""
634634
# Only when this buffer has the focus.
635635
if self.app.current_buffer == self.history_buffer:
636636
line_no = self.history_buffer.document.cursor_position_row

ptpython/key_bindings.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def _(event):
203203

204204
@handle("c-c", filter=has_focus(python_input.default_buffer))
205205
def _(event):
206-
" Abort when Control-C has been pressed. "
206+
"Abort when Control-C has been pressed."
207207
event.app.exit(exception=KeyboardInterrupt, style="class:aborting")
208208

209209
return bindings
@@ -222,7 +222,7 @@ def load_sidebar_bindings(python_input):
222222
@handle("c-p", filter=sidebar_visible)
223223
@handle("k", filter=sidebar_visible)
224224
def _(event):
225-
" Go to previous option. "
225+
"Go to previous option."
226226
python_input.selected_option_index = (
227227
python_input.selected_option_index - 1
228228
) % python_input.option_count
@@ -231,7 +231,7 @@ def _(event):
231231
@handle("c-n", filter=sidebar_visible)
232232
@handle("j", filter=sidebar_visible)
233233
def _(event):
234-
" Go to next option. "
234+
"Go to next option."
235235
python_input.selected_option_index = (
236236
python_input.selected_option_index + 1
237237
) % python_input.option_count
@@ -240,14 +240,14 @@ def _(event):
240240
@handle("l", filter=sidebar_visible)
241241
@handle(" ", filter=sidebar_visible)
242242
def _(event):
243-
" Select next value for current option. "
243+
"Select next value for current option."
244244
option = python_input.selected_option
245245
option.activate_next()
246246

247247
@handle("left", filter=sidebar_visible)
248248
@handle("h", filter=sidebar_visible)
249249
def _(event):
250-
" Select previous value for current option. "
250+
"Select previous value for current option."
251251
option = python_input.selected_option
252252
option.activate_previous()
253253

@@ -257,7 +257,7 @@ def _(event):
257257
@handle("enter", filter=sidebar_visible)
258258
@handle("escape", filter=sidebar_visible)
259259
def _(event):
260-
" Hide sidebar. "
260+
"Hide sidebar."
261261
python_input.show_sidebar = False
262262
event.app.layout.focus_last()
263263

ptpython/layout.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565

6666
class CompletionVisualisation(Enum):
67-
" Visualisation method for the completions. "
67+
"Visualisation method for the completions."
6868
NONE = "none"
6969
POP_UP = "pop-up"
7070
MULTI_COLUMN = "multi-column"
@@ -116,7 +116,7 @@ def select_item(mouse_event: MouseEvent) -> None:
116116

117117
@if_mousedown
118118
def goto_next(mouse_event: MouseEvent) -> None:
119-
" Select item and go to next value. "
119+
"Select item and go to next value."
120120
python_input.selected_option_index = index
121121
option = python_input.selected_option
122122
option.activate_next()
@@ -472,7 +472,7 @@ def show_sidebar_button_info(python_input: "PythonInput") -> Container:
472472

473473
@if_mousedown
474474
def toggle_sidebar(mouse_event: MouseEvent) -> None:
475-
" Click handler for the menu. "
475+
"Click handler for the menu."
476476
python_input.show_sidebar = not python_input.show_sidebar
477477

478478
version = sys.version_info
@@ -544,7 +544,7 @@ def get_text_fragments() -> StyleAndTextTuples:
544544

545545
@Condition
546546
def extra_condition() -> bool:
547-
" Only show when... "
547+
"Only show when..."
548548
b = python_input.default_buffer
549549

550550
return (

ptpython/prompt_style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PromptStyle(metaclass=ABCMeta):
1616

1717
@abstractmethod
1818
def in_prompt(self) -> AnyFormattedText:
19-
" Return the input tokens. "
19+
"Return the input tokens."
2020
return []
2121

2222
@abstractmethod
@@ -31,7 +31,7 @@ def in2_prompt(self, width: int) -> AnyFormattedText:
3131

3232
@abstractmethod
3333
def out_prompt(self) -> AnyFormattedText:
34-
" Return the output tokens. "
34+
"Return the output tokens."
3535
return []
3636

3737

ptpython/python_input.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def __init__(
192192
output: Optional[Output] = None,
193193
# For internal use.
194194
extra_key_bindings: Optional[KeyBindings] = None,
195-
create_app = True,
195+
create_app=True,
196196
_completer: Optional[Completer] = None,
197197
_validator: Optional[Validator] = None,
198198
_lexer: Optional[Lexer] = None,
@@ -396,7 +396,6 @@ def __init__(
396396
else:
397397
self._app = None
398398

399-
400399
def _accept_handler(self, buff: Buffer) -> bool:
401400
app = get_app()
402401
app.exit(result=buff.text)
@@ -405,12 +404,12 @@ def _accept_handler(self, buff: Buffer) -> bool:
405404

406405
@property
407406
def option_count(self) -> int:
408-
" Return the total amount of options. (In all categories together.) "
407+
"Return the total amount of options. (In all categories together.)"
409408
return sum(len(category.options) for category in self.options)
410409

411410
@property
412411
def selected_option(self) -> Option:
413-
" Return the currently selected option. "
412+
"Return the currently selected option."
414413
i = 0
415414
for category in self.options:
416415
for o in category.options:
@@ -533,7 +532,7 @@ def disable(attribute: str) -> bool:
533532
def simple_option(
534533
title: str, description: str, field_name: str, values: Optional[List] = None
535534
) -> Option:
536-
" Create Simple on/of option. "
535+
"Create Simple on/of option."
537536
values = values or ["off", "on"]
538537

539538
def get_current_value():

ptpython/repl.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(self, *a, **kw) -> None:
7979
self._load_start_paths()
8080

8181
def _load_start_paths(self) -> None:
82-
" Start the Read-Eval-Print Loop. "
82+
"Start the Read-Eval-Print Loop."
8383
if self._startup_paths:
8484
for path in self._startup_paths:
8585
if os.path.exists(path):
@@ -157,9 +157,7 @@ async def run_and_show_expression_async(self, text):
157157
else:
158158
# Print.
159159
if result is not None:
160-
await loop.run_in_executor(
161-
None, lambda: self.show_result(result)
162-
)
160+
await loop.run_in_executor(None, lambda: self.show_result(result))
163161

164162
# Loop.
165163
self.current_statement_index += 1
@@ -287,7 +285,7 @@ def get_compiler_flags(self) -> int:
287285
return super().get_compiler_flags() | PyCF_ALLOW_TOP_LEVEL_AWAIT
288286

289287
def _compile_with_flags(self, code: str, mode: str):
290-
" Compile code with the right compiler flags. "
288+
"Compile code with the right compiler flags."
291289
return compile(
292290
code,
293291
"<stdin>",
@@ -578,13 +576,13 @@ def _remove_from_namespace(self) -> None:
578576

579577

580578
def _lex_python_traceback(tb):
581-
" Return token list for traceback string. "
579+
"Return token list for traceback string."
582580
lexer = PythonTracebackLexer()
583581
return lexer.get_tokens(tb)
584582

585583

586584
def _lex_python_result(tb):
587-
" Return token list for Python string. "
585+
"Return token list for Python string."
588586
lexer = PythonLexer()
589587
# Use `get_tokens_unprocessed`, so that we get exactly the same string,
590588
# without line endings appended. `print_formatted_text` already appends a
@@ -604,7 +602,9 @@ def enable_deprecation_warnings() -> None:
604602
warnings.filterwarnings("default", category=DeprecationWarning, module="__main__")
605603

606604

607-
def run_config(repl: PythonInput, config_file: str = "~/.config/ptpython/config.py") -> None:
605+
def run_config(
606+
repl: PythonInput, config_file: str = "~/.config/ptpython/config.py"
607+
) -> None:
608608
"""
609609
Execute REPL config file.
610610
@@ -752,7 +752,7 @@ def no(event: KeyPressEvent) -> None:
752752

753753
@bindings.add("<any>")
754754
def _(event: KeyPressEvent) -> None:
755-
" Disallow inserting other text. "
755+
"Disallow inserting other text."
756756
pass
757757

758758
style

0 commit comments

Comments
 (0)