ci: enhance type checking in workflow and improve test coverage

- Added a step to fail the CI if any '# type: ignore' comments are found in Python files.
- Refactored tests to use mocking for better isolation and reliability.
- Updated type hints and casting in several files to improve type safety.
This commit is contained in:
Alishahryar1 2026-02-14 23:01:11 -08:00
parent 97217debfa
commit 0d292cd578
6 changed files with 41 additions and 12 deletions

View file

@ -5,7 +5,7 @@ Contains token counting for API requests.
import json
import logging
from typing import Any, List, Optional, Union
from typing import Any, List, Optional, Union, cast
import tiktoken
@ -18,7 +18,7 @@ __all__ = ["get_token_count"]
def _get_block_attr(block: object, key: str, default: Any = "") -> Any:
"""Get attribute from block (object or dict)."""
if isinstance(block, dict):
return block.get(key, default) # type: ignore[no-matching-overload]
return cast(dict[str, Any], block).get(key, default)
return getattr(block, key, default)