Skip to content

fix(cli): preserve Literal type for mode in command dispatch#49

Open
Flames4fun wants to merge 1 commit intoabduznik:masterfrom
Flames4fun:fix/mypy-cli-mode-literal
Open

fix(cli): preserve Literal type for mode in command dispatch#49
Flames4fun wants to merge 1 commit intoabduznik:masterfrom
Flames4fun:fix/mypy-cli-mode-literal

Conversation

@Flames4fun
Copy link
Copy Markdown
Contributor

Summary

This PR fixes the mypy errors reported in src/cli.py by preserving the narrow literal type used for command dispatch mode.

What changed

  • Introduced a Mode type alias as Literal["fast", "smart"]
  • Replaced the inline conditional assignment of mode with an explicit branch assignment
  • Kept the CLI command dispatch unchanged while ensuring downstream functions receive the expected literal type

Why

The previous implementation assigned mode using a conditional expression, which caused mypy to widen the inferred type more than expected in this context. Several command handlers require Literal["fast", "smart"], so the type mismatch surfaced as multiple static type errors in src/cli.py.

Using an explicit branch preserves the intended literal typing cleanly and avoids adding unnecessary casts.

Validation

mypy src/cli.py
mypy src

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