Fix mypy 2.3.0 type errors in the test suite#274
Open
ben-xo wants to merge 1 commit into
Open
Conversation
mypy 2.3.0 (released 2026-07-13) is stricter and surfaces 7 errors in the test suite on unmodified main (CI's `mypy<3,>=2.1` floats to it), failing the Lint job on every open PR. All test-only, no behavioural change. - tests/utils/assert_equal_awaitables_or_values.py: the awaitable branch returns a coroutine where the declared TypeVar `T` is expected; cast it (the function returns an awaitable iff its inputs are awaitables). - tests/execution/test_abstract.py: the conditionally-defined `is_type_of` and `type_error` (sync vs async variants) now must have identical signatures; pre-declare each with an explicit `Callable[..., Any]`. - tests/execution/test_stream.py: `name` is assigned either a coroutine (`throw()`) or a `str`; annotate it `Any`. - tests/execution/test_middleware.py: the awaited `subscribe(...)` item is inferred as `object`; cast it to `ExecutionResult` before reading `.data`. mypy src tests, ruff check src tests and ruff format --check src tests are all clean under the pinned tool versions (mypy 2.3.0, ruff 0.15.21).
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.
mypy 2.3.0 (released 2026-07-13) is stricter and produces 7 errors on unmodified
main— CI'smypy<3,>=2.1floats to it, so the Lint job now fails on every open PR. This fixes them. All changes are test-only with no behavioural change.Errors fixed
tests/utils/assert_equal_awaitables_or_values.pyCoroutinevs declared TypeVarTcast("T", …)— the helper returns an awaitable iff its inputs are awaitablestests/execution/test_abstract.py(×2)is_type_of/type_errorsync-vs-async variants must have identical signaturesCallable[..., Any]tests/execution/test_stream.py(×2)nameassigned either a coroutine (throw()) or astrname: Anytests/execution/test_middleware.py(×2)subscribe(...)item inferred asobject, so.datais rejectedcast("ExecutionResult", …)Verification (pinned tool versions)
python -m mypy src tests— Success, no issues (mypy 2.3.0)python -m ruff check src tests/ruff format --check src tests— clean (ruff 0.15.21)test_abstract,test_stream,test_middleware) pass unchanged.