Skip to content

refactor(pyright): one more step towards fully strict mode#86

Merged
stdrc merged 2 commits intomainfrom
rc/pyright-strict/2
Oct 26, 2025
Merged

refactor(pyright): one more step towards fully strict mode#86
stdrc merged 2 commits intomainfrom
rc/pyright-strict/2

Conversation

@stdrc
Copy link
Copy Markdown
Contributor

@stdrc stdrc commented Oct 26, 2025

    "strict": [
        "src/kimi_cli/prompts",
        "src/kimi_cli/soul",
        // "src/kimi_cli/tools",
        // "src/kimi_cli/ui/acp",
        "src/kimi_cli/ui/print",
        // "src/kimi_cli/ui/shell",
        "src/kimi_cli/utils",
        "src/kimi_cli/wire",
        "src/kimi_cli/*.py",
    ]

Now only the tools, acp, shell parts are not strict.

Signed-off-by: Richard Chien <stdrc@outlook.com>
Copilot AI review requested due to automatic review settings October 26, 2025 08:32
@stdrc stdrc changed the title refactor: one more step towards fully strict mode refactor(pyright): one more step towards fully strict mode Oct 26, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 yolo mode 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.

Comment thread src/kimi_cli/metadata.py

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"
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
default_factory=list[WorkDirMeta], description="Work directory list"
default_factory=list, description="Work directory list"

Copilot uses AI. Check for mistakes.
Comment thread src/kimi_cli/cli.py Outdated
echo = click.echo if verbose else lambda *args, **kwargs: None

def _noop_echo(*args: Any, **kwargs: Any) -> None:
return None
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The explicit return None is unnecessary in a function with -> None type hint. Remove the return statement or use pass instead.

Suggested change
return None
pass

Copilot uses AI. Check for mistakes.
Signed-off-by: Richard Chien <stdrc@outlook.com>
@stdrc stdrc merged commit 78aae8e into main Oct 26, 2025
2 checks passed
@stdrc stdrc deleted the rc/pyright-strict/2 branch October 26, 2025 09:23
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.

2 participants