refactor(pyright): one more step towards fully strict mode#86
Conversation
Signed-off-by: Richard Chien <stdrc@outlook.com>
There was a problem hiding this comment.
Pull Request Overview
This PR advances the codebase towards full strict type checking by enabling Pyright's strict mode for additional modules (prompts, ui/print, wire, and root *.py files). The changes include type-safety improvements and a refactoring of yolo mode handling in print UI.
Key Changes:
- Added type-safe implementations to satisfy strict mode requirements (proper type annotations, non-blocking queue access)
- Refactored
yolomode logic to be set earlier in initialization rather than after UI creation - Updated Pyright version requirement and expanded strict mode coverage in pyrightconfig.json
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/kimi_cli/wire/init.py | Added receive_nowait() method for non-blocking message retrieval |
| src/kimi_cli/ui/print/init.py | Refactored to use new receive_nowait() method and added file existence check |
| src/kimi_cli/metadata.py | Fixed type annotation for default_factory to satisfy strict type checking |
| src/kimi_cli/cli.py | Added proper type annotations for echo function and updated help text |
| src/kimi_cli/init.py | Moved yolo mode logic earlier to avoid redundant setting after UI creation |
| pyrightconfig.json | Expanded strict mode coverage to include additional modules |
| pyproject.toml | Updated Pyright version from 1.1.406 to 1.1.407 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| work_dirs: list[WorkDirMeta] = Field(default_factory=list, description="Work directory list") | ||
| work_dirs: list[WorkDirMeta] = Field( | ||
| default_factory=list[WorkDirMeta], description="Work directory list" |
There was a problem hiding this comment.
The default_factory should be a callable that returns a list, not a parameterized list type. Change list[WorkDirMeta] to list since the factory needs to be callable.
| default_factory=list[WorkDirMeta], description="Work directory list" | |
| default_factory=list, description="Work directory list" |
| echo = click.echo if verbose else lambda *args, **kwargs: None | ||
|
|
||
| def _noop_echo(*args: Any, **kwargs: Any) -> None: | ||
| return None |
There was a problem hiding this comment.
[nitpick] The explicit return None is unnecessary in a function with -> None type hint. Remove the return statement or use pass instead.
| return None | |
| pass |
Now only the tools, acp, shell parts are not strict.