diff --git a/src/toon_format/constants.py b/src/toon_format/constants.py index be061be..49ceb79 100644 --- a/src/toon_format/constants.py +++ b/src/toon_format/constants.py @@ -6,7 +6,7 @@ the TOON implementation. Centralizes magic values for maintainability. """ -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Dict if TYPE_CHECKING: from .types import Delimiter @@ -45,7 +45,7 @@ # endregion # region Delimiters -DELIMITERS: dict[str, "Delimiter"] = { +DELIMITERS: Dict[str, "Delimiter"] = { "comma": COMMA, "tab": TAB, "pipe": PIPE, diff --git a/src/toon_format/utils.py b/src/toon_format/utils.py index 002f3d2..935a074 100644 --- a/src/toon_format/utils.py +++ b/src/toon_format/utils.py @@ -25,7 +25,7 @@ import functools import json -from typing import Any +from typing import Any, Dict # Import encode from parent package (defined in __init__.py before this module is imported) # __init__.py defines encode() before importing utils, so this is safe @@ -91,7 +91,7 @@ def count_tokens(text: str, encoding: str = "o200k_base") -> int: return len(enc.encode(text)) -def estimate_savings(data: Any, encoding: str = "o200k_base") -> dict[str, Any]: +def estimate_savings(data: Any, encoding: str = "o200k_base") -> Dict[str, Any]: """Compare token counts between JSON and TOON formats. Args: diff --git a/src/toon_format/writer.py b/src/toon_format/writer.py index 6a89e00..57c5aaf 100644 --- a/src/toon_format/writer.py +++ b/src/toon_format/writer.py @@ -6,7 +6,7 @@ indent string caching for performance. """ -from typing import List +from typing import Dict, List from .types import Depth @@ -24,7 +24,7 @@ def __init__(self, indent_size: int) -> None: # Ensure nested structures remain distinguishable even for indent=0 normalized_indent = indent_size if indent_size > 0 else 1 self._indentation_string = " " * normalized_indent - self._indent_cache: dict[int, str] = {0: ""} + self._indent_cache: Dict[int, str] = {0: ""} self._indent_size = indent_size def push(self, depth: Depth, content: str) -> None: