Repository navigation
Clean up static typing, ship py.typed, and replace typeguard with mypy - #516
Merged
Merged
Conversation
Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
Accept iterator batches, NumPy scalar observations, ndarray simplex losses, and typed balancing callbacks. Describe npoints as read-only for type checking without imposing a runtime property. Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
Assisted-by: MindRoom DevAgent:openai/gpt-6.2-sol <https://github.com/mindroom-ai/mindroom>
This was referenced Dec 6, 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.
Summary
I simplified the type annotations across
adaptive, replaced runtimetypeguardinstrumentation with a single pragmaticmypycheck in CI, and added a PEP 561adaptive/py.typedmarker so downstream users benefit from the annotations.Key changes
typeguardand addmypyin CI: removed.github/workflows/typeguard.yml,pytest_typeguardfromnoxfile.py, thetypeguardtest dependency, and theadaptive/_types.pyworkaround; added.github/workflows/typecheck.ymlrunning pinnedmypy(check_untyped_defs,warn_unused_ignores,warn_redundant_casts,no_implicit_optional) and scoped the pre-commitmypyhook toadaptive/.py.typed: addedadaptive/py.typedand configured[tool.setuptools.package-data]so built wheels include it.adaptive.types(Float,Int,Bool,Real) in favor of plain Python numeric andnumpytypes while keepingadaptive/types.pyas a backwards-compatible shim (still accessible viaimport adaptive; adaptive.types.Real, without addingtypesto__all__).XsType0/1/NandYsType0/1/Naliases fromlearner1D.py(net shorter thanmain).BaseRunner,Runner,BlockingRunner,AsyncRunner,DataSaver, andBalancingLearnergeneric (Generic[LearnerType]) sorunner.learnerand wrapped learners preserve their concrete type.LearnerNDandBaseLearnerwith zero privateProtocolclasses, no addedcast()calls, and# type: ignorecut roughly in half (78 -> 30).Learner2D.loss()to handle list-valuedloss_per_triangleresults (such astriangle_loss) viafloat(np.max(losses)).adaptive/tests/test_typing.pyand aLearner2Dlist-loss test inadaptive/tests/test_learner2d.py.Supersedes #515, #377, and #408.
Verification
ruff check .andruff format --check .passed.mypy adaptivepassed both in the CIadaptive[test]environment and viapre-commit run mypy --all-files.mypyandtychecks against a built wheel passed across all seven learners, generic wrappers, async callbacks, list/NumPy bounds, custom losses, and externalBaseLearnersubclasses.[test,other]) and Python 3.13 ([test,other,rust]), plus wheelpy.typedpackaging andget_type_hints()compatibility checks.