Skip to content

fix(runtime): satisfy ty in runtime tests#529

Open
Subhajitdas99 wants to merge 1 commit into
GetBindu:mainfrom
Subhajitdas99:fix/runtime-tests-ty-cleanup
Open

fix(runtime): satisfy ty in runtime tests#529
Subhajitdas99 wants to merge 1 commit into
GetBindu:mainfrom
Subhajitdas99:fix/runtime-tests-ty-cleanup

Conversation

@Subhajitdas99
Copy link
Copy Markdown
Contributor

@Subhajitdas99 Subhajitdas99 commented May 9, 2026

Summary

  • Problem: Updated runtime tests fail ty due to stale type: ignore comments and nullable await_args access in mocked async calls. The runtime provider code also imports the optional boxd dependency, which ty could not resolve in the default test environment.
  • Why it matters: These typing issues block unrelated PRs in CI even when their own changes are clean.
  • What changed: Removed unused type: ignore directives, added explicit non-None assertions before accessing await_args.args / await_args.kwargs, and added minimal local boxd stub files so ty can resolve the optional runtime dependency during static analysis.
  • What did NOT change: No production runtime behavior changes, no CLI behavior changes, and no test logic changes beyond type-safety guards and type-checking stubs.

Change Type (select all that apply)

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Security hardening
  • Tests
  • Chore/infra

Scope (select all touched areas)

  • Server / API endpoints
  • Extensions (DID, x402, etc.)
  • Storage backends
  • Scheduler backends
  • Observability / monitoring
  • Authentication / authorization
  • CLI / utilities
  • Tests
  • Documentation
  • CI/CD / infra

Linked Issue/PR

User-Visible / Behavior Changes

None.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/credentials handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Database schema/migration changes? (Yes/No) No
  • Authentication/authorization changes? (Yes/No) No
  • If any Yes, explain risk + mitigation: None

Verification

Environment

  • OS: Windows 11
  • Python version: 3.12.9
  • Storage backend: Not applicable
  • Scheduler backend: Not applicable

Steps to Test

  1. Run uv run pre-commit run --all-files
  2. Confirm ty no longer reports unused type: ignore comments in the runtime test base file
  3. Confirm ty no longer reports nullable await_args access or unresolved boxd imports in the runtime provider/test paths

Expected Behavior

  • Pre-commit no longer fails on these runtime typing issues.
  • Test behavior remains unchanged.

Actual Behavior

  • Removed the stale suppressions, added explicit non-None guards, and provided minimal local boxd stubs for static analysis.
  • Pre-commit passed locally on commit.

Evidence (attach at least one)

  • Failing test before + passing after
  • Test output / logs
  • Screenshot / recording
  • Performance metrics (if relevant)

Human Verification (required)

  • Verified scenarios: Verified the affected runtime tests now guard nullable await_args access and no longer rely on unused type: ignore comments. Verified ty can resolve the optional boxd import path via local stubs.
  • Edge cases checked: Checked both log-streaming assertions and shell exec assertions where mocked await_args is read. Checked that the minimal stub surface covers the imported runtime symbols used by static analysis.
  • What you did NOT verify: Did not change or re-verify production runtime behavior against a live boxd installation, since this PR is focused on static-analysis/test-path cleanup.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Database migration needed? (Yes/No) No
  • If yes, exact upgrade steps: None

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert this PR.
  • Files/config to restore:
    • tests/unit/runtime/test_base.py
    • tests/unit/runtime/test_boxd_provider.py
    • tests/unit/runtime/test_cli_shell_logs.py
    • boxd/__init__.pyi
    • boxd/aio.pyi
    • boxd/errors.pyi
  • Known bad symptoms reviewers should watch for: Unexpected test assertion failures if a mocked async call stops being awaited, or future boxd imports require additional stubbed symbols for static analysis.

Risks and Mitigations

  • Risk: The local boxd stubs may need expansion if additional optional SDK symbols are imported later.
    • Mitigation: Kept the stubs intentionally minimal and limited to the symbols currently referenced by ty in the runtime provider/tests.

Checklist

  • Tests pass (uv run pytest)
  • Pre-commit hooks pass (uv run pre-commit run --all-files)
  • Documentation updated (if needed)
  • Security impact assessed
  • Human verification completed
  • Backward compatibility considered

Summary by CodeRabbit

Release Notes

  • New Features

    • Added configuration structures for container resource management (CPU, memory, disk)
    • Added network proxy configuration support
    • Added lifecycle auto-suspend configuration
    • Added async compute context manager for container operations
    • Added NotFoundError exception for enhanced error handling
  • Tests

    • Enhanced validation assertions in command execution tests

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06e8484b-bc40-478e-8116-68e85e81a4d6

📥 Commits

Reviewing files that changed from the base of the PR and between 9d1d192 and cdfe26f.

📒 Files selected for processing (3)
  • boxd/__init__.pyi
  • boxd/aio.pyi
  • boxd/errors.pyi
✅ Files skipped from review due to trivial changes (1)
  • boxd/errors.pyi
🚧 Files skipped from review as they are similar to previous changes (2)
  • boxd/aio.pyi
  • boxd/init.pyi

📝 Walkthrough

Walkthrough

This PR introduces three new type stub files (boxd/__init__.pyi, boxd/aio.pyi, boxd/errors.pyi) defining configuration classes, an async context manager, and a custom exception. It also adds null-safety assertions to four existing test methods before accessing mock call arguments.

Changes

Box Configuration and Async Compute APIs

Layer / File(s) Summary
Configuration Data Contracts
boxd/__init__.pyi
Four configuration data classes form a composition hierarchy: ProxyEntry (name and port pair), NetworkConfig (optional proxy list), LifecycleConfig (optional auto-suspend timeout), and BoxConfig (resource fields and nested configs with keyword-only initialization).
Async Context Manager Interface
boxd/aio.pyi
Compute class provides async context-manager protocol with __aenter__ and __aexit__ method signatures, accepting flexible initialization via **kwargs.
Exception Definitions
boxd/errors.pyi
NotFoundError exception type declared as subclass of Exception.
Test Assertion Safeguards
tests/unit/runtime/test_boxd_provider.py, tests/unit/runtime/test_cli_shell_logs.py
Four test methods add null checks (fake_box.exec.await_args is not None) before inspecting mock command arguments in log-streaming and shell tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 New stubs for boxes and async dreams,
Configuration flows in type-safe streams,
Null checks guard the test assertions tight,
A rabbit hops through types—all working right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly refers to satisfying type-checking requirements in runtime tests, which is the primary focus of the changeset.
Description check ✅ Passed The description follows the template structure, provides detailed problem/solution/verification, and clearly documents the typing fixes and stub additions made.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Subhajitdas99 Subhajitdas99 force-pushed the fix/runtime-tests-ty-cleanup branch from 9d1d192 to cdfe26f Compare June 2, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant