Add comprehensive type hints to all Python code #229
Merged
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.