Commit e5026d1
chore(sdks/python): fix pyright errors from CI on 8d97a64
CI's Python SDK Quality (sandbox) job failed at the pyright step with 10
errors after I ignored that lint in earlier rounds. All on this PR's
new code; tests and ruff are unaffected.
### Three categories
**(1) ``timedelta | None`` not assignable to ``timedelta`` (4 errors)**
The auto-default change in 4e4f12c made ``PoolConfig.acquire_min_remaining_ttl``
declared as ``timedelta | None`` (``None`` means "auto-derive from idle_timeout"
at ``__post_init__``). Even though ``__post_init__`` always resolves it to a
concrete ``timedelta`` via ``object.__setattr__``, pyright can't see through
that, so passing it to the helper functions tripped.
Fix: widen the helper signatures to accept ``timedelta | None`` and treat
``None`` as zero. This matches what ``__post_init__`` would do anyway and
removes the need for ``cast`` at every call site.
**(2) ``_kill_sandbox_best_effort`` returns ``bool`` but reconciler wants
``Callable[[str], None]`` (2 errors)**
In 33ee6f3 ``_kill_sandbox_best_effort`` was changed to return ``bool`` so
``_kill_discarded_alive`` could fire the success debug log only on a confirmed
kill. But the reconciler's ``on_discard_sandbox`` parameter is typed
``Callable[[str], None]``, and ``bool`` is not a subtype of ``None``.
Fix: introduce a thin ``_discard_sandbox_callback`` adapter on both pool
facades that calls ``_kill_sandbox_best_effort`` and drops the return. The
reconciler now receives the adapter; the bool is still available to
``_kill_discarded_alive`` for the success-only log.
**(3) ``getattr(store, ...)`` returns ``object`` (4 errors)**
The Python ``hasattr``-based store-compat shim in ``pool_types.py`` uses
``getattr(store, "try_take_idle_min_ttl", None)``, which pyright types as
``object``. Calling that or awaiting it tripped four errors in the helpers.
Fix: ``cast`` each ``getattr`` result to the actual signature
(``Awaitable[TakeIdleResult]`` / ``Iterable[str] | None`` etc.). Behavior
unchanged at runtime — ``callable(method)`` still gates the call.
### Verification
- ``uv run pyright`` — 0 errors
- ``uv run ruff check`` — clean
- ``uv run pytest`` — 207 passed
- Kotlin ``:sandbox:test`` + ``:sandbox-pool-redis:test`` (real Redis 7) +
``spotlessCheck`` — all green
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 8d97a64 commit e5026d1
3 files changed
Lines changed: 40 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
487 | 494 | | |
488 | 495 | | |
489 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
358 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
359 | 360 | | |
360 | | - | |
| 361 | + | |
361 | 362 | | |
362 | 363 | | |
363 | 364 | | |
364 | | - | |
| 365 | + | |
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
368 | 369 | | |
369 | | - | |
| 370 | + | |
370 | 371 | | |
371 | 372 | | |
372 | | - | |
| 373 | + | |
373 | 374 | | |
374 | 375 | | |
375 | 376 | | |
376 | | - | |
| 377 | + | |
| 378 | + | |
377 | 379 | | |
378 | 380 | | |
379 | 381 | | |
380 | 382 | | |
381 | 383 | | |
382 | 384 | | |
383 | 385 | | |
384 | | - | |
| 386 | + | |
385 | 387 | | |
386 | 388 | | |
387 | 389 | | |
388 | 390 | | |
389 | | - | |
390 | | - | |
| 391 | + | |
| 392 | + | |
391 | 393 | | |
392 | | - | |
| 394 | + | |
393 | 395 | | |
394 | 396 | | |
395 | 397 | | |
396 | 398 | | |
397 | | - | |
| 399 | + | |
398 | 400 | | |
399 | 401 | | |
400 | 402 | | |
| |||
404 | 406 | | |
405 | 407 | | |
406 | 408 | | |
407 | | - | |
| 409 | + | |
408 | 410 | | |
409 | 411 | | |
410 | | - | |
| 412 | + | |
411 | 413 | | |
412 | 414 | | |
413 | 415 | | |
414 | 416 | | |
415 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
416 | 421 | | |
417 | 422 | | |
418 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
| 360 | + | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
470 | 478 | | |
471 | 479 | | |
472 | 480 | | |
| |||
0 commit comments