Add None validation for corpus paths to prevent confusing runtime errors#1234
Merged
Add None validation for corpus paths to prevent confusing runtime errors#1234
Conversation
Co-authored-by: bact <128572+bact@users.noreply.github.com>
…tion years Co-authored-by: bact <128572+bact@users.noreply.github.com>
…ibility Co-authored-by: bact <128572+bact@users.noreply.github.com>
Co-authored-by: bact <128572+bact@users.noreply.github.com>
|
bact
approved these changes
Jan 30, 2026
Copilot
AI
changed the title
[WIP] Review changes made in multiple pull requests
Add None validation for corpus paths to prevent confusing runtime errors
Jan 30, 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 does this changes
Adds defensive validation for corpus file paths that can be None when files aren't downloaded, preventing confusing TypeError and AttributeError at runtime. Adds
get_thwiki_lstm()helper for validated access. Fixes resource leak in test.What was wrong
get_corpus_path()returnsNonewhen corpus files aren't downloaded, but code assumed non-None:How this fixes it
Validation with clear errors:
ulmfit/core.py: Addedget_thwiki_lstm()that validates paths and raises RuntimeError with download instructions. THWIKI_LSTM dict preserved for backward compatibility.generate/thai2fit.py: Validates paths at module load before file operationstag/thainer.py: Validates model paths before passing to pycrfsuite with version-specific instructionsResource safety:
tests/extra/testx_ulmfit.py: Replacedpickle.load(open(...))with proper context managerAll changes maintain backward compatibility. Error messages use multiline format with actionable instructions:
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.