Add type hints to core test suite functions - #1265
Merged
Merged
Conversation
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>
bact
marked this pull request as ready for review
February 3, 2026 09:40
Co-authored-by: bact <128572+bact@users.noreply.github.com>
|
Copilot
AI
changed the title
[WIP] Add type hints to submodules incrementally
Add type hints to core test suite functions
Feb 3, 2026
bact
approved these changes
Feb 3, 2026
This was referenced Feb 3, 2026
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 type hints to functions tested in the core test suite. Fixes 35+ mypy errors across 8 files while maintaining Python 3.9 compatibility.
What was wrong
Core-tested functions lacked type annotations, causing mypy validation failures:
corpus/core.py: JSON return types declared asdict[str, str]but actual structure isdict[str, Any]corpus/common.py: Missing type annotation forlist_synonym, incorrect Union type handlingtransliterate/core.py: Incorrect/unusedtype: ignorecommentstag/unigram.py:json.load()returnsAnybut functions declareddictreturn typeutil/spell_words.py: Module-level list comprehensions had no type annotationstag/named_entity.py: Outdatedtype: ignoreannotationstransliterate/lookup.py: Dictionary access returningUnion[str, bool, None]incompatible with function return typesHow this fixes it
Type system fixes:
dict[str, Any]for nested JSON structurestype: ignore[no-any-return]for external library returnsisinstancechecks instead of assertions for runtime type guardstemp→temp_partsfor list type)Guidelines applied:
list,tuple) nottyping.List,typing.TupleUnion[]syntax instead of|for Python 3.9 compatibilityTYPE_CHECKINGimports to avoid circular dependenciestype: ignorecommentsModified files:
corpus/core.py- 10 errors fixedcorpus/common.py- 3 errors fixedtransliterate/core.py- 8 errors fixedtag/unigram.py- 5 errors fixedutil/spell_words.py- 3 errors fixedtag/named_entity.py- 4 errors fixedtransliterate/lookup.py- 2 errors fixedYour checklist for this pull request
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.