From 3c40227f019b3ff3de4578d38ffd82fee2d34739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 10 Jan 2026 23:23:49 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Update=20types=20for=20compatibi?= =?UTF-8?q?lity=20with=20Python=203.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/doc_parsing_utils.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/doc_parsing_utils.py b/scripts/doc_parsing_utils.py index 857d808aa..79f2e9ec0 100644 --- a/scripts/doc_parsing_utils.py +++ b/scripts/doc_parsing_utils.py @@ -1,5 +1,5 @@ import re -from typing import TypedDict +from typing import TypedDict, Union CODE_INCLUDE_RE = re.compile(r"^\{\*\s*(\S+)\s*(.*)\*\}$") CODE_INCLUDE_PLACEHOLDER = "" @@ -50,8 +50,8 @@ class MarkdownLinkInfo(TypedDict): line_no: int url: str text: str - title: str | None - attributes: str | None + title: Union[str, None] + attributes: Union[str, None] full_match: str @@ -285,7 +285,11 @@ def _add_lang_code_to_url(url: str, lang_code: str) -> str: def _construct_markdown_link( - url: str, text: str, title: str | None, attributes: str | None, lang_code: str + url: str, + text: str, + title: Union[str, None], + attributes: Union[str, None], + lang_code: str, ) -> str: """ Construct a markdown link, adjusting the URL for the given language code if needed. @@ -545,7 +549,7 @@ def extract_multiline_code_blocks(text: list[str]) -> list[MultilineCodeBlockInf return blocks -def _split_hash_comment(line: str) -> tuple[str, str | None]: +def _split_hash_comment(line: str) -> tuple[str, Union[str, None]]: match = HASH_COMMENT_RE.match(line) if match: code = match.group("code").rstrip() @@ -554,7 +558,7 @@ def _split_hash_comment(line: str) -> tuple[str, str | None]: return line.rstrip(), None -def _split_slashes_comment(line: str) -> tuple[str, str | None]: +def _split_slashes_comment(line: str) -> tuple[str, Union[str, None]]: match = SLASHES_COMMENT_RE.match(line) if match: code = match.group("code").rstrip() @@ -600,8 +604,8 @@ def replace_multiline_code_block( code_block: list[str] = [] for line_a, line_b in zip(block_a["content"], block_b["content"]): - line_a_comment: str | None = None - line_b_comment: str | None = None + line_a_comment: Union[str, None] = None + line_b_comment: Union[str, None] = None # Handle comments based on language if block_language in {