Add comprehensive type hints to all Python code - #229
Merged
Conversation
- Added type hints to all 20 core modules in epitran/ package - Added type hints to all 13 script files in epitran/bin/ directory - Used proper typing imports: List, Dict, Tuple, Optional, Any, Union, DefaultDict, Callable, Iterator - Enhanced method signatures with parameter and return type annotations - Fixed complex type annotations for better readability - All modules compile successfully and functionality is preserved Co-authored-by: openhands <openhands@all-hands.dev>
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
This PR adds comprehensive type hints to all Python code in the epitran package, enhancing code readability, IDE support, and enabling static type checking.
Changes Made
Core Modules (20 files)
epitran/package:_epitran.py,simple.py,backoff.py,cedict.py,dictfirst.pydownload.py,epihan.py,flite.py,ligaturize.py,meta.pyppprocessor.py,puncnorm.py,reromanize.py,rules.py,space.pystripdiacritics.py,tir2pp.py,vector.py,xsampa.pyScript Files (13 files)
epitran/bin/directory:connl2engipaspace.py,connl2ipaspace.py,decompose.py,detectcaps.pyepitranscribe.py,isbijective.py,ltf2ipaspace.py,migraterules.pyreromanize.py,space2punc.py,testvectorgen.py,vie-tones.pyuigtransliterate.py(simple script with minimal changes needed)Type Annotations Added
Optional[T]for nullable parametersTyping Imports Used
List,Dict,Tuple,Optional,Any,UnionDefaultDict,Callable,Iterator,SetBenefits
Testing
Compatibility
This work complements the earlier Python 2 to Python 3 modernization efforts and brings the codebase up to modern Python typing standards.