Complete type annotations across codebase (97% coverage) - #1277
Merged
Conversation
…ix Any import Co-authored-by: bact <128572+bact@users.noreply.github.com>
…nd Any returns Co-authored-by: bact <128572+bact@users.noreply.github.com>
… type narrowing Co-authored-by: bact <128572+bact@users.noreply.github.com>
… and process_thai Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
…twork classes Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
- Add type hints to 69 module variables across 16 files - Add type hints to 1 class variable (Node.__slots__) - Add type hints to 2 instance variables (Trie.words, Trie.root) - Ensure Python 3.9 compatibility (no X | Y syntax) - Import Pattern type for regex patterns - All changes pass ruff checks Co-authored-by: bact <128572+bact@users.noreply.github.com>
- Remove redundant declaration in syllable.py - Fix type annotation in pronounce.py using intermediate variable - Remove unnecessary loop variable annotations in spell_words.py and morse.py Co-authored-by: bact <128572+bact@users.noreply.github.com>
Use Optional[list[str]] instead of list[str] | None
…nize modules Co-authored-by: bact <128572+bact@users.noreply.github.com>
- Added type annotations to all module-level variables including loop variables in ancient/aksonhan.py, util/morse.py, util/spell_words.py, util/syllable.py, wsd/core.py - Added type annotations to ulmfit/core.py module-level rule lists - Added type annotations to cli/__init__.py, ulmfit/preprocess.py, wangchanberta/__init__.py, wangchanberta/core.py - Added type annotations to transliterate/royin.py reassignments - Added class-level type annotations to WordNetAug, ChatBotModel, Words_Spelling_Correction, WngchanBerta_ONNX, WunsenTransliterate Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
|
Copilot
AI
changed the title
[WIP] Add type annotations to achieve 100% coverage
Complete type annotations across codebase (97% coverage)
Feb 4, 2026
bact
marked this pull request as ready for review
February 4, 2026 14:36
bact
approved these changes
Feb 4, 2026
2 tasks
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.


What do these changes do
Adds comprehensive type annotations across the entire PyThaiNLP codebase, achieving 100% function coverage and 97% variable coverage.
Coverage achieved:
Key improvements:
type: ignorecommentsTYPE_CHECKINGimports to avoid circular dependenciesOptional[X],Union[X, Y]syntax)Modules annotated:
What was wrong
The codebase lacked comprehensive type annotations, limiting IDE support, static analysis capabilities, and type safety. No systematic type checking was enforced.
How this fixes it
Systematically annotated all functions, methods, and variables using:
TYPE_CHECKINGguardsAnyfor complex external library types (transformers, PyTorch) where stubs unavailableExample of improvements:
Your checklist for this pull request
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.