Skip to content

Commit 9312352

Browse files
committed
Refactor block builders to use Sequence instead of List
1 parent b96e94f commit 9312352

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

elementary/messages/block_builders.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from typing import List, Optional, Tuple, Union
2+
from typing import List, Optional, Sequence, Tuple, Union
33

44
from .blocks import (
55
CodeBlock,
@@ -16,7 +16,7 @@
1616
)
1717

1818
SimpleInlineBlock = Union[str, Icon]
19-
SimpleLineBlock = Union[str, Icon, List[SimpleInlineBlock]]
19+
SimpleLineBlock = Union[str, Icon, Sequence[SimpleInlineBlock]]
2020

2121

2222
def _build_inline_block(
@@ -28,9 +28,9 @@ def _build_inline_block(
2828
def _build_inlines(
2929
content: SimpleLineBlock, style: Optional[TextStyle] = None
3030
) -> List[InlineBlock]:
31-
if isinstance(content, list):
32-
return [_build_inline_block(line, style) for line in content]
33-
return [_build_inline_block(content)]
31+
if isinstance(content, (str, Icon)):
32+
return [_build_inline_block(content, style)]
33+
return [_build_inline_block(line, style) for line in content]
3434

3535

3636
def BulletListBlock(
@@ -73,7 +73,7 @@ def LinkLineBlock(*, text: str, url: str) -> LineBlock:
7373

7474
def SummaryLineBlock(
7575
*,
76-
summary: List[Tuple[SimpleLineBlock, SimpleLineBlock]],
76+
summary: Sequence[Tuple[SimpleLineBlock, SimpleLineBlock]],
7777
include_empty_values: bool = False,
7878
) -> LineBlock:
7979
text_blocks: List[InlineBlock] = []
@@ -89,7 +89,7 @@ def SummaryLineBlock(
8989

9090
def FactsBlock(
9191
*,
92-
facts: List[
92+
facts: Sequence[
9393
Tuple[
9494
SimpleLineBlock,
9595
SimpleLineBlock,

0 commit comments

Comments
 (0)