Commit ba351a0
test: fix pyright strict-mode errors in tests/test_observable (batch 2) (#782)
* test: fix pyright strict-mode errors in test_observable (batch 2)
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 <223556219+Copilot@users.noreply.github.com>
* refactor(tests): replace type:ignore comments with proper type annotations
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.
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Dag Brattli <dag@brattli.net>1 parent d78df7d commit ba351a0
32 files changed
Lines changed: 158 additions & 80 deletions
File tree
- reactivex
- observable
- operators
- tests/test_observable
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
710 | | - | |
| 710 | + | |
| 711 | + | |
711 | 712 | | |
712 | 713 | | |
713 | 714 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
| 475 | + | |
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
228 | | - | |
| 230 | + | |
229 | 231 | | |
230 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
231 | 236 | | |
232 | 237 | | |
| 238 | + | |
233 | 239 | | |
234 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
235 | 244 | | |
236 | 245 | | |
| 246 | + | |
237 | 247 | | |
238 | 248 | | |
239 | 249 | | |
| |||
245 | 255 | | |
246 | 256 | | |
247 | 257 | | |
248 | | - | |
| 258 | + | |
249 | 259 | | |
250 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
251 | 264 | | |
252 | 265 | | |
| 266 | + | |
253 | 267 | | |
254 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
255 | 272 | | |
256 | 273 | | |
| 274 | + | |
257 | 275 | | |
258 | 276 | | |
259 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
| 362 | + | |
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
379 | | - | |
| 379 | + | |
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | | - | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| 90 | + | |
87 | 91 | | |
88 | 92 | | |
89 | 93 | | |
| |||
0 commit comments