summaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts
diff options
context:
space:
mode:
authorarcadia-devtools <[email protected]>2022-02-12 14:35:15 +0300
committerarcadia-devtools <[email protected]>2022-02-12 14:35:15 +0300
commit46a8b83899dd321edf511c0483f9c479ce2c1bc4 (patch)
treee5debc03beecbd10e7d1bf78c889c8d54e8c4523 /contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts
parentb56bbcc9f63bf31991a8aa118555ce0c12875a74 (diff)
intermediate changes
ref:7c971b97c72bbbcbf889118d39017bd14f99365a
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py12
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py6
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py2
3 files changed, 11 insertions, 9 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py
index a91bb3142cd..9140f86ab32 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/dialogs.py
@@ -1,5 +1,5 @@
import functools
-from typing import Any, Callable, List, Optional, Tuple, TypeVar
+from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
@@ -174,7 +174,8 @@ def radiolist_dialog(
text: AnyFormattedText = "",
ok_text: str = "Ok",
cancel_text: str = "Cancel",
- values: Optional[List[Tuple[_T, AnyFormattedText]]] = None,
+ values: Optional[Sequence[Tuple[_T, AnyFormattedText]]] = None,
+ default: Optional[_T] = None,
style: Optional[BaseStyle] = None,
) -> Application[_T]:
"""
@@ -189,7 +190,7 @@ def radiolist_dialog(
def ok_handler() -> None:
get_app().exit(result=radio_list.current_value)
- radio_list = RadioList(values)
+ radio_list = RadioList(values=values, default=default)
dialog = Dialog(
title=title,
@@ -212,7 +213,8 @@ def checkboxlist_dialog(
text: AnyFormattedText = "",
ok_text: str = "Ok",
cancel_text: str = "Cancel",
- values: Optional[List[Tuple[_T, AnyFormattedText]]] = None,
+ values: Optional[Sequence[Tuple[_T, AnyFormattedText]]] = None,
+ default_values: Optional[Sequence[_T]] = None,
style: Optional[BaseStyle] = None,
) -> Application[List[_T]]:
"""
@@ -227,7 +229,7 @@ def checkboxlist_dialog(
def ok_handler() -> None:
get_app().exit(result=cb_list.current_values)
- cb_list = CheckboxList(values)
+ cb_list = CheckboxList(values=values, default_values=default_values)
dialog = Dialog(
title=title,
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py
index ad3a932d3fd..1383d7a6b5b 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py
@@ -231,7 +231,7 @@ class Progress(Formatter):
def get_width(self, progress_bar: "ProgressBar") -> AnyDimension:
all_lengths = [
- len("{0:>3}".format(c.total or "?")) for c in progress_bar.counters
+ len("{:>3}".format(c.total or "?")) for c in progress_bar.counters
]
all_lengths.append(1)
return D.exact(max(all_lengths) * 2 + 1)
@@ -241,7 +241,7 @@ def _format_timedelta(timedelta: datetime.timedelta) -> str:
"""
Return hh:mm:ss, or mm:ss if the amount of hours is zero.
"""
- result = "{0}".format(timedelta).split(".")[0]
+ result = f"{timedelta}".split(".")[0]
if result.startswith("0:"):
result = result[2:]
return result
@@ -327,7 +327,7 @@ class IterationsPerSecond(Formatter):
def get_width(self, progress_bar: "ProgressBar") -> AnyDimension:
all_values = [
- len("{0:.2f}".format(c.items_completed / c.time_elapsed.total_seconds()))
+ len(f"{c.items_completed / c.time_elapsed.total_seconds():.2f}")
for c in progress_bar.counters
]
if all_values:
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py
index 4e2a532b346..c7ce74e6271 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py
@@ -119,7 +119,7 @@ def print_formatted_text(
# Normal lists which are not instances of `FormattedText` are
# considered plain text.
if isinstance(val, list) and not isinstance(val, FormattedText):
- return to_formatted_text("{0}".format(val))
+ return to_formatted_text(f"{val}")
return to_formatted_text(val, auto_convert=True)
fragments = []