diff options
Diffstat (limited to 'src/prompt_toolkit/formatted_text')
-rw-r--r-- | src/prompt_toolkit/formatted_text/__init__.py | 1 | ||||
-rw-r--r-- | src/prompt_toolkit/formatted_text/ansi.py | 6 | ||||
-rw-r--r-- | src/prompt_toolkit/formatted_text/base.py | 5 | ||||
-rw-r--r-- | src/prompt_toolkit/formatted_text/utils.py | 1 |
4 files changed, 6 insertions, 7 deletions
diff --git a/src/prompt_toolkit/formatted_text/__init__.py b/src/prompt_toolkit/formatted_text/__init__.py index db44ab9..0590c81 100644 --- a/src/prompt_toolkit/formatted_text/__init__.py +++ b/src/prompt_toolkit/formatted_text/__init__.py @@ -10,6 +10,7 @@ an :class:`.HTML` object, an :class:`.ANSI` object or a sequence of `(style_string, text)` tuples. The :func:`.to_formatted_text` conversion function takes any of these and turns all of them into such a tuple sequence. """ + from __future__ import annotations from .ansi import ANSI diff --git a/src/prompt_toolkit/formatted_text/ansi.py b/src/prompt_toolkit/formatted_text/ansi.py index 08ec0b3..4761982 100644 --- a/src/prompt_toolkit/formatted_text/ansi.py +++ b/src/prompt_toolkit/formatted_text/ansi.py @@ -210,10 +210,8 @@ class ANSI: # True colors. if n == 2 and len(attrs) >= 3: try: - color_str = "#{:02x}{:02x}{:02x}".format( - attrs.pop(), - attrs.pop(), - attrs.pop(), + color_str = ( + f"#{attrs.pop():02x}{attrs.pop():02x}{attrs.pop():02x}" ) except IndexError: pass diff --git a/src/prompt_toolkit/formatted_text/base.py b/src/prompt_toolkit/formatted_text/base.py index 92de353..5fee1f8 100644 --- a/src/prompt_toolkit/formatted_text/base.py +++ b/src/prompt_toolkit/formatted_text/base.py @@ -38,8 +38,7 @@ if TYPE_CHECKING: text. """ - def __pt_formatted_text__(self) -> StyleAndTextTuples: - ... + def __pt_formatted_text__(self) -> StyleAndTextTuples: ... AnyFormattedText = Union[ @@ -132,7 +131,7 @@ class FormattedText(StyleAndTextTuples): return self def __repr__(self) -> str: - return "FormattedText(%s)" % super().__repr__() + return f"FormattedText({super().__repr__()})" class Template: diff --git a/src/prompt_toolkit/formatted_text/utils.py b/src/prompt_toolkit/formatted_text/utils.py index c8c37e0..43228c3 100644 --- a/src/prompt_toolkit/formatted_text/utils.py +++ b/src/prompt_toolkit/formatted_text/utils.py @@ -4,6 +4,7 @@ Utilities for manipulating formatted text. When ``to_formatted_text`` has been called, we get a list of ``(style, text)`` tuples. This file contains functions for manipulating such a list. """ + from __future__ import annotations from typing import Iterable, cast |