Align docstrings with type hints across codebase - #1270
Merged
Conversation
Co-authored-by: bact <128572+bact@users.noreply.github.com>
…oint None check Co-authored-by: bact <128572+bact@users.noreply.github.com>
… code Co-authored-by: bact <128572+bact@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Verify precision of type hints and docstrings
Verify and improve type hints precision across codebase
Feb 3, 2026
bact
approved these changes
Feb 3, 2026
bact
marked this pull request as ready for review
February 3, 2026 13:04
Update docstrings to use native Python types (list, dict, tuple) instead of typing module style (List, Dict, Tuple) to match the type hints. This affects: - pythainlp/phayathaibert/core.py (4 fixes) - pythainlp/benchmarks/word_tokenization.py (4 fixes) - pythainlp/word_vector/core.py (2 fixes) - pythainlp/tag/named_entity.py (2 fixes) - pythainlp/spell/core.py (2 fixes) - pythainlp/tag/tltk.py (1 fix) - pythainlp/tag/thainer.py (1 fix) - pythainlp/tag/chunk.py (1 fix) - pythainlp/spell/words_spelling_correction.py (1 fix) - pythainlp/spell/pn.py (1 fix) - pythainlp/coref/core.py (1 fix) 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
Verify and improve type hints precision across codebase
Align docstrings with type hints across codebase
Feb 3, 2026
bact
reviewed
Feb 3, 2026
|
|
||
| :return: dataframe with row x col = len(samples) x len(metrics) | ||
| :rtype: pandas.DataFrame | ||
| :rtype: pd.DataFrame |
Member
There was a problem hiding this comment.
keep the fullname. "pd" is an alias used only locally.
Contributor
Author
There was a problem hiding this comment.
Fixed in c656076 - changed to pandas.DataFrame
bact
reviewed
Feb 3, 2026
|
|
||
| :return: `gensim` word2vec model | ||
| :rtype: gensim.models.keyedvectors.Word2VecKeyedVectors | ||
| :rtype: Word2VecKeyedVectors |
Contributor
Author
There was a problem hiding this comment.
Fixed in c656076 - changed to gensim.models.keyedvectors.Word2VecKeyedVectors
bact
reviewed
Feb 3, 2026
| :return: 300-dimension vector representing the given sentence | ||
| in form of :mod:`numpy` array | ||
| :rtype: :class:`numpy.ndarray((1,300))` | ||
| :rtype: ndarray |
Member
There was a problem hiding this comment.
use full qualified name "numpy.ndarray"
Contributor
Author
There was a problem hiding this comment.
Fixed in c656076 - changed to numpy.ndarray
Co-authored-by: bact <128572+bact@users.noreply.github.com>
|
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
Synchronizes docstrings with type hints, eliminating 42 mismatches where documentation used outdated
typingmodule syntax while code used Python 3.9+ native types. Additionally ensures non-standard types use fully qualified module names for clarity.What was wrong
Docstrings documented types as
List[str],Dict[...],Tuple[...](typing module style) while function signatures usedlist[str],dict[...],tuple[...](native Python 3.9+ style). Additionally, some docstrings used local import aliases (likepd.DataFrame) or unqualified type names (likeWord2VecKeyedVectors) instead of fully qualified module names, making it unclear which module provides the type.How this fixes it
Documentation updates (42 fixes across 16 files):
List→list,Dict→dict,Tuple→tuplein:rtype:annotationsUnion[List[...], ...]→Union[list[...], ...]for consistencypd.DataFrame→pandas.DataFrameWord2VecKeyedVectors→gensim.models.keyedvectors.Word2VecKeyedVectorsndarray→numpy.ndarrayType hint improvements (3 instances):
dict→dict[str, Any]inbenchmarks/word_tokenization.pyfor flattened result structureslist→list[tuple[int, int]]where docstrings specified structureHigh-impact modules:
tokenize/core.py: 8 fixes (tokenization return types)benchmarks/word_tokenization.py: 8 fixes (benchmark metrics)phayathaibert/core.py: 4 fixes (NER outputs)word_vector/core.py: 4 fixes (word vector model types)Your checklist for this pull request
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.