Add Python 3.11+ type hints to core modules#51
Merged
Conversation
- Add type annotations to dumptool.py, jsontool.py, main.py, and utils.py - Use modern Python 3.11+ syntax (e.g., set[str] instead of Set[str]) - Add io and typing imports for proper type hints - Import JsonType from utils for consistent JSON type annotations - Add return type annotations to all functions
- CI workflow: Remove Python 3.8/3.9/3.10, keep 3.11/3.12/3.13/3.14 - pyproject.toml: Add Python 3.14 classifier, update ruff target-version to py311, mypy to 3.11 - Add pytest-cov to dependency-groups for test coverage - Modernize all type hints to Python 3.11+ syntax: - Union[X, Y] → X | Y - Optional[X] → X | None - List[X] → list[X] - Dict[X, Y] → dict[X, Y] - Tuple[X, Y] → tuple[X, Y] - Import from collections.abc instead of typing for Callable, Iterable, Iterator - Add strict=True to zip() call - Use ternary operator for fout assignment in main.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dumptool.py,jsontool.py,main.py, andutils.pyset[str]instead ofSet[str])ioandtypingimports for proper type hintsJsonTypefrom utils for consistent JSON type annotationsChanges
This PR enhances type safety by adding comprehensive type hints across the core modules using Python 3.11+ syntax.
Test plan