Conversation
Fix pyright strict-mode type errors in 30 files under tests/test_observable/,
continuing the incremental cleanup of the pyright exclusion list.
Error patterns fixed:
- _raise("string") → _raise(Exception("string"))
- def action(): → def action(_): for on_next callbacks (OnNext[T] requires a param)
- Notification union-attr access annotated with # type: ignore[union-attr]
- subscribe(scheduler="not_set") → subscribe(scheduler=None) for proper typing
- mapper/generate iterate lambdas annotated with # type: ignore[arg-type]
- do_action callback removing spurious return value
- factory(ex: Exception) → factory(ex: Exception | None) for on_error_resume_next
- return lambda: None → return None in subscribe functions
- Hoisted variables to avoid unbound-var errors inside assertRaises blocks
- Various other minor fixes (arg-type, call-arg, misc type: ignore)
260 tests pass. Part of ongoing effort to clean up pyright exclusions.
Co-authored-by: Copilot <[email protected]>
…tions Builds on PR #782 to replace the `# type: ignore` suppressions with real type annotations and structural fixes: - Use `isinstance(value, OnError|OnNext)` to narrow `Recorded.value` instead of `# type: ignore[union-attr]` (test_average, test_elementat, test_reduce, test_toiterable). - Properly annotate test-local `subscribe` functions with `ObserverBase[T] / SchedulerBase | None / DisposableBase` and return `Disposable()` so `reactivex.create(...)` accepts them without `# type: ignore[misc]/[arg-type]` (test_concat, test_observeon, test_map, test_skipuntil, test_while_do). - Type `xs` as `list[ColdObservable[int] | None]` in test_defer instead of bare `[None]`, and add `assert xs[0] is not None` narrowing. - Annotate `_raise` as `NoReturn` in test_map, test_retry, test_generate so the surrounding code type-checks without trailing dummy returns. - Use a typed module-level seed in test_generate to widen `Literal[0]` to `int` so `lambda x: x + 1` matches `Mapper[int, int]`. - `cast(Observable[int], s)` in test_tofuture instead of `# type: ignore`. Also widens two clearly-incorrect public type signatures (the implementation already supports the wider input): - `delay()` and `delay_()` now accept `AbsoluteOrRelativeTime` instead of only `RelativeTime`. The implementation already branches on `isinstance(duetime, datetime)`, so this just makes the signature match reality and removes 5 `# type: ignore[arg-type]` in test_delay. - `from_callback()` now returns `Callable[..., Observable[Any]]` instead of `Callable[[], Observable[Any]]`. The inner `function(*args)` already accepts arbitrary args, so this matches reality and removes 2 `# type: ignore[call-arg]` in test_fromcallback. Only `test_of.py:51` keeps a `# type: ignore[call-arg]` — it's in a test that never runs (typo `teest_` in the name) and intentionally calls `reactivex.of()` with a kwarg that doesn't exist; fixing it is out of scope. Pyright strict: 0 errors. All 1494 tests pass.
dbrattli
approved these changes
Apr 26, 2026
This was referenced May 1, 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.
🤖 This is an automated PR from Repo Assist.
Continuing the incremental pyright strict-mode cleanup of
tests/test_observable/. This is batch 2, following #778 (ruff cleanup) and #780 (pyright batch 1).What changed
Fixed pyright strict-mode type errors in 30 files under
tests/test_observable/(targeting files with 1–7 errors each). All 260 tests across these files still pass.Error patterns addressed
_raise("string")_raise(Exception("string"))—_raiseis typed(Exception) -> Nonedef action():ason_nextcallbackdef action(_):—OnNext[T]requires one parameterNotificationunion-attr access (.kind,.value,.exception)# type: ignore[union-attr]— correct at runtime, not statically narrowablesubscribe(scheduler="not_set")subscribe(scheduler=None)—Subscription[T]requires `SchedulerBaselambda x: xason_nextlambda x: None—OnNext[T]must returnNonegenerate(0, ..., lambda x: x+1)# type: ignore[arg-type]on iterate — Literal[0] inference mismatchdo_actioncallback returningintreturnstatementfactory(ex: Exception)inon_error_resume_nextreturn lambda: Nonein subscribereturn NoneassertRaisesFiles changed
test_amb,test_average,test_combinelatest,test_concat,test_debounce,test_defer,test_delay,test_doaction,test_elementat,test_empty,test_expand,test_filter,test_fromcallback,test_generate,test_interval,test_map,test_observeon,test_of,test_onerrorresumenext,test_reduce,test_repeat,test_retry,test_returnvalue,test_skipuntil,test_takeuntil,test_throw,test_timer,test_tofuture,test_toiterable,test_while_doNext steps
There are ~940 more pyright errors remaining in
tests/test_observable/(in files with higher error counts). Future batches will continue working through them until the directory can be removed from the pyrightexcludelist inpyproject.toml.Warning
The following domain was blocked by the firewall during workflow execution:
astral.shTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Note
🔒 Integrity filter blocked 8 items
The following items were blocked because they don't meet the GitHub integrity level.
list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: