Skip to content

test: fix pyright strict-mode errors in tests/test_observable (batch 2)#782

Merged
dbrattli merged 2 commits intomasterfrom
repo-assist/pyright-cleanup-test-observable-2026-04-26-3187c4c0696b18d4
Apr 26, 2026
Merged

test: fix pyright strict-mode errors in tests/test_observable (batch 2)#782
dbrattli merged 2 commits intomasterfrom
repo-assist/pyright-cleanup-test-observable-2026-04-26-3187c4c0696b18d4

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 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

Pattern Fix
_raise("string") _raise(Exception("string"))_raise is typed (Exception) -> None
def action(): as on_next callback def action(_):OnNext[T] requires one parameter
Notification union-attr access (.kind, .value, .exception) # type: ignore[union-attr] — correct at runtime, not statically narrowable
subscribe(scheduler="not_set") subscribe(scheduler=None)Subscription[T] requires `SchedulerBase
lambda x: x as on_next lambda x: NoneOnNext[T] must return None
generate(0, ..., lambda x: x+1) # type: ignore[arg-type] on iterate — Literal[0] inference mismatch
do_action callback returning int Removed return statement
factory(ex: Exception) in on_error_resume_next `factory(ex: Exception
return lambda: None in subscribe return None
Unbound variables inside assertRaises Hoisted assignments before the block

Files 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_do

Next 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 pyright exclude list in pyproject.toml.

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • astral.sh

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"

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.

  • #749 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #748 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #742 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #736 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #711 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #700 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #698 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #634 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Repo Assist · ● 16.7M ·

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 dbrattli changed the title [Repo Assist] test: fix pyright strict-mode errors in tests/test_observable (batch 2) test: fix pyright strict-mode errors in tests/test_observable (batch 2) Apr 26, 2026
@dbrattli dbrattli marked this pull request as ready for review April 26, 2026 11:28
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 93.519% (+0.003%) from 93.516% — repo-assist/pyright-cleanup-test-observable-2026-04-26-3187c4c0696b18d4 into master

@dbrattli dbrattli merged commit ba351a0 into master Apr 26, 2026
50 of 51 checks passed
@dbrattli dbrattli deleted the repo-assist/pyright-cleanup-test-observable-2026-04-26-3187c4c0696b18d4 branch April 26, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants