From 6c084a6b7d304d3fd4953c292119c92f257f4744 Mon Sep 17 00:00:00 2001 From: Konstantin Fickel Date: Sun, 18 Jan 2026 18:18:39 +0100 Subject: [PATCH] fix: update imports --- src/streamer/parse/parse.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/streamer/parse/parse.py b/src/streamer/parse/parse.py index 08dbb26..a4c8421 100644 --- a/src/streamer/parse/parse.py +++ b/src/streamer/parse/parse.py @@ -1,12 +1,18 @@ -from typing import Optional -from mistletoe import Document -from mistletoe.block_token import Paragraph, BlockToken, Heading, List, ListItem from collections import Counter -from .markdown_tag import TagMarkdownRenderer +from mistletoe.block_token import ( + BlockToken, + Document, + Heading, + List, + ListItem, + Paragraph, +) + from .extract_tag import extract_markers_and_tags, has_markers -from .shard import Shard, StreamFile from .list import split_at +from .markdown_tag import TagMarkdownRenderer +from .shard import Shard, StreamFile def get_line_number(block_token: BlockToken) -> int: @@ -71,7 +77,7 @@ def find_headings_by_level( def calculate_heading_level_for_next_split( block_tokens: list[BlockToken], -) -> Optional[int]: +) -> int | None: """ If there is no marker in any heading, then return None. If only the first token is a heading with a marker, then return None. @@ -98,7 +104,7 @@ def calculate_heading_level_for_next_split( def parse_single_block_shards( block_token: BlockToken, start_line: int, end_line: int -) -> tuple[Optional[Shard], list[str]]: +) -> tuple[Shard | None, list[str]]: markers, tags, children = [], [], [] if isinstance(block_token, List): @@ -137,7 +143,7 @@ def parse_multiple_block_shards( start_line: int, end_line: int, enforce_shard: bool = False, -) -> tuple[Optional[Shard], list[str]]: +) -> tuple[Shard | None, list[str]]: is_first_block_heading = isinstance(block_tokens[0], Heading) and has_markers( block_tokens[0] ) @@ -180,7 +186,7 @@ def parse_header_shards( start_line: int, end_line: int, use_first_child_as_header: bool = False, -) -> Optional[Shard]: +) -> Shard | None: if len(block_tokens) == 0: return build_shard(start_line, end_line)