Repository navigation
Fix invalid type annotations (callable, np.array) in the package - #1438
Open
Michael-Duck wants to merge 1 commit into
Open
Michael-Duck wants to merge 1 commit into
Michael-Duck wants to merge 1 commit into
Conversation
Signed-off-by: Michael-Duck <michael@realms.nexus>
Michael-Duck
force-pushed
the
michael-duck/ai-759-fix-invalid-type-hints
branch
from
October 20, 2026 10:56
0a06bb8 to
058e121
Compare
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
The package used functions where a type was expected:
callableas an annotation inExtractiveness.__init__and infind_executable_batch_size,np.array(the constructor function, not the array type) as the return annotation ofDropMetrics._align_bags, and a bareAnnotatedas the type ofArg.type. Type checkers reject all of them andtyping.get_type_hints()cannot resolve them at runtime. This replaces them withtyping.Callable,numpy.ndarrayandtyping.Any, and adds a regression test that scans every module of the package for annotations that do not refer to a type.Notes
Only annotations change, runtime behaviour is unchanged. The new test is a static (ast-based) check: it needs no model, no GPU and no network access. Scope: this fixes the class of errors the issue points at - annotations that are not types - and guards against new ones; the ~1.2k remaining mypy errors reported in the issue are unrelated to it.
Tests
python3 -m pytest tests/unit/test_type_hints.py -q-> 285 passed. On the unmodified tree the same test reports 4 failed, 281 passed - one failure per file changed above:cli_args.py(bareAnnotated),metrics/harness_compatibility/drop.py(np.array),metrics/metrics_sample.py(callable),utils/parallelism.py(callable).ruff check src testsandruff format --check src tests-> clean. The whole-reporuff check .andruff format --check .(whatmake qualityruns) are clean too.python -m pytest tests/ -q --ignore=tests/slow_tests-> 953 passed, 17 failed, 5 skipped. Those 17 failures are pre-existing and unrelated to this change: the identical set fails on the unmodifiedorigin/maintree. They are 8 failures intests/unit/tasks/test_registry.py(TypeError: HfApi.list_models() got an unexpected keyword argument 'model_name', ahuggingface_hubAPI change) and 9 intests/unit/models/vllm/test_vllm_model.py+tests/unit/utils/test_caching.py(vllmis not installed in the sandbox).tests/slow_testswas not run: it downloads models and needs a GPU.Fixes #759