feat(python): add full type annotations support with default enabled #319
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.
This commit implements comprehensive Python type annotation support for the Kaitai Struct compiler, making it the default behavior for modern Python development while maintaining backward compatibility.
Type Annotations by Default: Python code now generates with full type annotations enabled by default
Comprehensive Coverage: Type annotations for constructors, methods, properties, and all data types
Modern Python Support: Imports typing module and uses modern annotation syntax
Backward Compatibility: New --no-python-type-annotations flag to disable when needed
Added pythonTypeAnnotations: Boolean = true to RuntimeConfig (default: true)
Created comprehensive kaitaiTypeToPythonType() mapping function
Enhanced constructor with full parameter and instance variable annotations
Added return type annotations for all methods (_read, properties, repr)
Conditional typing imports only when annotations enabled
Removed "# type: ignore" comment when annotations are present
With type annotations (default):
Without annotations (--no-python-type-annotations):
--python-type-annotations
: Explicitly enable (now redundant but supported)--no-python-type-annotations
: Disable type annotations