Skip to content

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

Merged
dbrattli merged 3 commits intomasterfrom
repo-assist/pyright-cleanup-test-observable-2026-05-01-7222f55d1674f33a
May 1, 2026
Merged

test: fix pyright strict-mode errors in tests/test_observable/ (batch 3)#785
dbrattli merged 3 commits intomasterfrom
repo-assist/pyright-cleanup-test-observable-2026-05-01-7222f55d1674f33a

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 1, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Fixes pyright strict-mode type errors in 25 test files in tests/test_observable/, continuing the cleanup started in batches 1 (#780) and 2 (#782).

Changes

25 files modified across these error patterns:

  1. _raise annotation — Added from typing import NoReturn and annotated def _raise(ex: Exception) -> NoReturn: (or ex: str where the function wraps strings in RxException). Using NoReturn is required because _raise is used in lambda contexts where the lambda's return type matters (e.g. key selectors, comparers).

  2. Callsite string-to-Exception wrapping — Changed _raise(ex) / _raise("ex") to _raise(Exception(ex)) / _raise(Exception("ex")) in files where ex is a plain string. Assertions remain correct because Notification.__eq__ uses string comparison (str(Exception("ex")) == "ex").

  3. Subscribe return type — Changed return lambda: None to return Disposable() in subscribe functions passed to reactivex.create(). The Subscription[T] type requires DisposableBase, not Callable[[], None]. Added from reactivex.disposable import Disposable where needed.

  4. Dispose wrapper — Changed return dispose to return Disposable(dispose) in test_create.py where dispose is a Callable[[], None].

  5. on_error string args — Changed o.on_error("ex") etc. to o.on_error(Exception("ex")) since Observer.on_error expects Exception.

  6. finally_action callback — Removed return statements from action() functions in test_finally.py. Action = Callable[[], None] must return None.

  7. do_action(on_next=...) parameter — Changed def action(): to def action(_: object) -> None: in test_merge.py since OnNext[T] = Callable[[T], None] requires one parameter.

Files changed

test_bufferwithcount, test_create, test_debounce, test_defer, test_delay, test_delaywithmapper, test_distinct, test_distinctuntilchanged, test_expand, test_finally, test_firstordefault, test_fromcallback, test_fromiterable, test_generatewithrelativetime, test_last, test_merge, test_minby, test_publish, test_returnvalue, test_single, test_singleordefault, test_takeuntilwithtime, test_timeout, test_timeoutwithmapper, test_using

Next step

After all files in tests/test_observable/ pass pyright checks, a maintainer can remove tests/test_observable from the [tool.pyright] exclude list in pyproject.toml (protected file — requires manual edit).

CI will validate via uv run pytest and uv run pyright.

Generated by Repo Assist

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 72 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".
  • using timeout with GroupedObservable leads to an index shift #225 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • Sort hot observable between (slow) scan executions #237 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • Observable interval appears to leak #259 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • Example noteboks are out of date #265 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • Proposal for a subscribe scheduler #309 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • Convert async iterator to Obervable #422 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • Weird interaction between group_by and to_iterable? #467 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • Q: how to use scheduler with subject for concurrency? #528 list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • ... and 56 more items

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

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

Generated by Repo Assist · ● 14.1M ·

Fix pyright errors in 25 test files in tests/test_observable/:
- Add 'from typing import NoReturn' import
- Annotate '_raise' functions with 'ex: Exception -> NoReturn' signature
- Fix callsites passing str to '_raise()' to wrap in Exception()
- Fix subscribe functions returning 'lambda: None' to return Disposable()
- Fix 'return dispose' to 'return Disposable(dispose)'
- Fix 'o.on_error(str)' calls to wrap strings in Exception()
- Fix 'do_action(on_next=action)' with zero-param action to accept one param
- Remove non-None return values from 'finally_action' callbacks

These changes allow tests/test_observable/ to eventually be removed
from the pyright exclude list in pyproject.toml.

Co-authored-by: Copilot <[email protected]>
@dbrattli dbrattli changed the title [Repo Assist] test: fix pyright strict-mode errors in tests/test_observable/ (batch 3) test: fix pyright strict-mode errors in tests/test_observable/ (batch 3) May 1, 2026
@dbrattli dbrattli marked this pull request as ready for review May 1, 2026 10:48
@coveralls
Copy link
Copy Markdown

coveralls commented May 1, 2026

Coverage Status

coverage: 93.524% (+0.005%) from 93.519% — repo-assist/pyright-cleanup-test-observable-2026-05-01-7222f55d1674f33a into master

Pre-commit hook failures from PR #785:
- Reorder `from typing import NoReturn` after `from datetime` in 3 files
- Wrap two long lines exceeding 88 chars in test_fromiterable.py and
  test_minby.py

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@dbrattli dbrattli merged commit 8413154 into master May 1, 2026
64 of 83 checks passed
@dbrattli dbrattli deleted the repo-assist/pyright-cleanup-test-observable-2026-05-01-7222f55d1674f33a branch May 1, 2026 13:26
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