fix(ble_log): use typing.Optional/List for Python 3.9 compatibility

This commit is contained in:
luoxu
2026-05-07 13:36:29 +08:00
committed by Luo Xu
parent b57260f260
commit 55a58720d9
2 changed files with 6 additions and 2 deletions

View File

@@ -10,13 +10,15 @@ import re
import shutil
import tempfile
import unittest
from typing import List
from typing import Optional
import test_utils # noqa: F401 — must be first to set up sys.path
from ble_log_compress import ARG_SIZE_TYPE
from test_utils import PipelineContext
def _extract_size_types_from_macro(macro_str: str) -> list[int] | None:
def _extract_size_types_from_macro(macro_str: str) -> Optional[List[int]]:
"""Extract size type values from a generated macro string."""
m = re.search(r'ble_log_compressed_hex_print\(\d+,\d+, (\d+)(?:, (.+?))?(?:,\s*[a-zA-Z_])', macro_str)
if not m:

View File

@@ -16,6 +16,8 @@ import shutil
import sys
import tempfile
from pathlib import Path
from typing import List
from typing import Optional
TESTS_DIR = Path(__file__).resolve().parent
SCRIPTS_DIR = TESTS_DIR.parent / 'scripts'
@@ -39,7 +41,7 @@ BLUEDROID_TAGS = [
]
def run_pipeline(fixture_files: list[str], output_name: str, tags_with_preserve: list[str] | None = None) -> None:
def run_pipeline(fixture_files: List[str], output_name: str, tags_with_preserve: Optional[List[str]] = None) -> None:
"""Run compression on fixture files and save the generated header as a golden file."""
tags_with_preserve = tags_with_preserve or ['APPL_TRACE_ERROR', 'APPL_TRACE_WARNING']