Skip to content

Commit e2e75c0

Browse files
Make formatted_text.split_lines accept an iterable (type annotation only).
1 parent 55cde3e commit e2e75c0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/prompt_toolkit/formatted_text/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .base import (
1717
AnyFormattedText,
1818
FormattedText,
19+
OneStyleAndTextTuple,
1920
StyleAndTextTuples,
2021
Template,
2122
is_formatted_text,
@@ -35,6 +36,7 @@
3536
__all__ = [
3637
# Base.
3738
"AnyFormattedText",
39+
"OneStyleAndTextTuple",
3840
"to_formatted_text",
3941
"is_formatted_text",
4042
"Template",

src/prompt_toolkit/formatted_text/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ def fragment_list_to_text(fragments: StyleAndTextTuples) -> str:
7272
return "".join(item[1] for item in fragments if ZeroWidthEscape not in item[0])
7373

7474

75-
def split_lines(fragments: StyleAndTextTuples) -> Iterable[StyleAndTextTuples]:
75+
def split_lines(
76+
fragments: Iterable[OneStyleAndTextTuple],
77+
) -> Iterable[StyleAndTextTuples]:
7678
"""
7779
Take a single list of (style_str, text) tuples and yield one such list for each
7880
line. Just like str.split, this will yield at least one item.
7981
80-
:param fragments: List of (style_str, text) or (style_str, text, mouse_handler)
81-
tuples.
82+
:param fragments: Iterable of ``(style_str, text)`` or
83+
``(style_str, text, mouse_handler)`` tuples.
8284
"""
8385
line: StyleAndTextTuples = []
8486

0 commit comments

Comments
 (0)