fix: resolve ty type diagnostics and add CI quality gates#568
fix: resolve ty type diagnostics and add CI quality gates#568mangelajo merged 4 commits intojumpstarter-dev:mainfrom
Conversation
Add type annotations and narrowing to fix type-check-python CI job: - renode: suppress 24 diagnostics (invalid-assignment from children dict, unresolved-reference from nonlocal, missing-argument from **kwargs) - mitmproxy: narrow 12 union-typed config fields via isinstance assertions - gpiod: suppress 5 mock method assertion false positives Generated-By: Forge/20260416_080433_27954_5e68926b Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tation Replace lowercase `any` (builtin function) with `FrameType | None` from the types module for the signal handler's frame parameter. This fixes the actual type error instead of suppressing it with a ty-ignore comment. Generated-By: Forge/20260416_080433_27954_5e68926b
Replace `assert config.token is not None` with proper `if` checks that raise `click.ClickException`, consistent with the CLI error handling pattern. Assertions can be disabled with `python -O`, making them unsuitable for runtime validation. Generated-By: Forge/20260416_080433_27954_5e68926b
Add tests for the unsupported shell fallback in completion.py (when get_completion_class returns None) and for edge cases in DurationParamType (integer input, unsupported type). Generated-By: Forge/20260416_080433_27954_5e68926b
📝 WalkthroughWalkthroughThis PR adds test coverage for parameter parsing and error handling, improves type annotations in signal handler code, enhances mitmproxy driver tests with runtime type assertions, replaces runtime assertions with proper exception handling in the login command, and adds type-checker suppression comments across multiple test and driver files. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/nvdemux/manager.py (1)
162-177: Consider adding explicit type annotation toframeparameter.While the type checker can infer the frame type from the outer function's return type, adding an explicit annotation would improve clarity and consistency with the explicitly-typed return signature:
def handler(signum: int, frame: FrameType | None):This makes the handler signature immediately clear without needing to reference the outer function's return type.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/nvdemux/manager.py` around lines 162 - 177, The handler callback currently defines def handler(signum: int, frame): without an explicit frame type; update the signature of handler to explicitly annotate frame as FrameType | None (e.g., def handler(signum: int, frame: FrameType | None):) and ensure FrameType is imported (from types import FrameType) or use typing.Optional if needed so the annotation is recognized; keep the rest of handler logic (cleanup via cls._instance._cleanup(), restoring cls._original_sigterm_handler / cls._original_sigint_handler, and os.kill(os.getpid(), signum)) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@python/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/nvdemux/manager.py`:
- Around line 162-177: The handler callback currently defines def
handler(signum: int, frame): without an explicit frame type; update the
signature of handler to explicitly annotate frame as FrameType | None (e.g., def
handler(signum: int, frame: FrameType | None):) and ensure FrameType is imported
(from types import FrameType) or use typing.Optional if needed so the annotation
is recognized; keep the rest of handler logic (cleanup via
cls._instance._cleanup(), restoring cls._original_sigterm_handler /
cls._original_sigint_handler, and os.kill(os.getpid(), signum)) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: acda1192-c385-41f4-9336-5f1006e45b0c
📒 Files selected for processing (8)
python/packages/jumpstarter-cli/jumpstarter_cli/common_test.pypython/packages/jumpstarter-cli/jumpstarter_cli/completion_test.pypython/packages/jumpstarter-cli/jumpstarter_cli/login.pypython/packages/jumpstarter-driver-gpiod/jumpstarter_driver_gpiod/driver_test.pypython/packages/jumpstarter-driver-mitmproxy/jumpstarter_driver_mitmproxy/driver_test.pypython/packages/jumpstarter-driver-pyserial/jumpstarter_driver_pyserial/nvdemux/manager.pypython/packages/jumpstarter-driver-renode/jumpstarter_driver_renode/driver.pypython/packages/jumpstarter-driver-renode/jumpstarter_driver_renode/driver_test.py
Summary
tytype checker diagnostics across Python driver packages (power_pdu, sdwire, dutlink, and others) by correcting type annotations, replacingassertwith explicit None checks, and using proper types likeFrameTypetytype checking job in lint workflow and diff-coverage enforcement (80% threshold on changed lines) in test workflowTest plan
make typasses locally with zero diagnostics on the fixed packagesmake testpasses across all affected packagestype-check-pythonCI job runs successfully on PRs touching Python code🤖 Generated with Claude Code