Skip to content

Add type hints, docstrings, and improve code quality#6

Merged
wannaphong merged 2 commits intomainfrom
copilot/improve-python-code
Feb 5, 2026
Merged

Add type hints, docstrings, and improve code quality#6
wannaphong merged 2 commits intomainfrom
copilot/improve-python-code

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Modernize codebase with type annotations and documentation to improve maintainability and IDE support.

Changes

  • Type hints: Added comprehensive annotations to all methods (typing.Optional, typing.List, return types)
  • Docstrings: Added Google-style docstrings with Args/Returns/Raises sections to all public methods
  • Constants: Extracted magic strings to named constants (SENTENCE_SPLIT_MARKER, NER_TAG_BEGIN, NER_TAG_OUTSIDE)
  • Variable naming: Replaced underscore-prefixed names with descriptive identifiers (_pos_tagpos_tags, _new_cutnew_tokens, _ner_ner_tags)
  • PEP 8: Fixed spacing around type hints, operators, and list comprehensions
  • Package structure: Created proper __init__.py with module docstring and exports

Example

Before:

def _pos(self, doc:Doc):
    _pos_tag = []
    for i,_ in enumerate(_pos_tag):
        doc[i].pos_ = _pos_tag[i]

After:

def _pos(self, doc: Doc) -> Doc:
    """Add part-of-speech tags to tokens."""
    pos_tags = []
    for i in range(len(pos_tags)):
        doc[i].pos_ = pos_tags[i]

No functional changes - maintains 100% backward compatibility.

Original prompt

Improve python code


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve Python code for better readability Add type hints, docstrings, and improve code quality Feb 5, 2026
Copilot AI requested a review from wannaphong February 5, 2026 08:43
@wannaphong wannaphong marked this pull request as ready for review February 5, 2026 08:43
@wannaphong wannaphong merged commit da571f6 into main Feb 5, 2026
7 checks passed
@wannaphong wannaphong deleted the copilot/improve-python-code branch February 5, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants