Complete type hinting across scienceworld package; add opt-in mypy tox env - #89
Open
pangwangshu wants to merge 1 commit into
Open
Complete type hinting across scienceworld package; add opt-in mypy tox env#89pangwangshu wants to merge 1 commit into
pangwangshu wants to merge 1 commit into
Conversation
Extends the type hints already started on ScienceWorldEnv's snake_case API to the remaining untyped surface: utils.py, the deprecated camelCase wrapper methods, __del__, getObjectTree, and BufferedHistorySaver. Also fixes two bugs uncovered by mypy: getRunHistorySize() called a nonexistent get_run_historySize() method, and __init__'s taskName/ serverPath params were implicitly Optional. Per MarcCote's comment on allenai#58, adds mypy as a testenv that is not part of tox's default envlist, so it's available via `tox -e mypy` without becoming a mandatory CI check. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Open
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.
Summary
Fixes #58.
Type hinting was already partially added to
ScienceWorldEnv's snake_case API in earlier commits. This PR completes the coverage and, per MarcCote's comment on the issue, wires up an opt-in mypy check without making it mandatory.scienceworld/utils.py(infer_task,snake_case_deprecation_warning), which had none.scienceworld/scienceworld.py: the deprecated camelCase wrapper methods,__del__,getObjectTree,get_max_variations's parameter, and the wholeBufferedHistorySaverclass.getRunHistorySize()called a nonexistentget_run_historySize()method (should beget_run_history_size()) — would have raisedAttributeErrorfor any camelCase-API caller.ScienceWorldEnv.__init__'staskName/serverPathparams were implicitlyOptional[str].[testenv:mypy]section totox.ini, deliberately not part of the defaultenvlist/CI matrix, so it's runnable viatox -e mypywithout gating builds — matching the "not mandatory for now" ask in the issue thread.Test plan
mypy scienceworld— no issues foundflake8 scienceworld --max-line-length 120— cleanpy_compile)pytestsuite — not run locally (no JVM available in the sandbox this was developed in); relies on CI, which builds the Scala JAR🤖 Generated with Claude Code