Conversation
|
👋 @vyagubov |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughUpdated CI workflows and project metadata to require Python 3.10, added poetry classifiers in pyproject.toml, and added a type-ignore pragma to the ElementaryCLI class in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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. 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 |
|
@NoyaOffer @arbiv FYI. Maybe it makes sense to merge current PR before the next release. |
|
@haritamar |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@elementary/cli/cli.py`:
- Line 39: The type-ignore comment on the ElementaryCLI class is misleading;
update it to accurately state why the ignore is used or eliminate it by aligning
method signatures: either change the comment to "# type: ignore[misc,
valid-type] # Method signatures differ from click.MultiCommand stubs" or modify
ElementaryCLI.list_commands to return a Sequence[str] (e.g., return
list(self._commands.keys())) and annotate ElementaryCLI.get_command to return
Command | None to match Click's stubs; ensure both method signatures and return
types conform to click.MultiCommand expectations so the scoped type ignore is no
longer necessary.
|
|
||
|
|
||
| class ElementaryCLI(click.MultiCommand): | ||
| class ElementaryCLI(click.MultiCommand): # type: ignore[misc, valid-type] |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
click types-click MultiCommand mypy typing issue 2025
💡 Result:
The most common cause is having types-click installed while using click>=8.0.
clickships its own type hints/stubs since v8.0, sotypes-clickis no longer needed and can conflict with Click’s bundled annotations (often showing up around classes likeclick.MultiCommand). [1]- Fix: uninstall
types-click(and then re-run mypy), keeping onlyclickinstalled. If you must usetypes-click, you generally need to pinclick<8. [1]
If the problem is an actual stub bug, the types-click stubs come from typeshed, and fixes should be filed/contributed there. [1][2]
Sources:
[1] https://pypi.org/project/types-click/
[2] https://github.com/python/typeshed
🌐 Web query:
click library Python type hints MultiCommand subclassing support
💡 Result:
Yes—Click supports subclassing click.MultiCommand (and click.Group) and it has type-hint support:
- Subclassing support: A custom multi-command is implemented by overriding
list_commands(ctx)andget_command(ctx, cmd_name). Click’s docs explicitly describe this extension point forGroup/MultiCommand. [2] - Type hints: Click ships with type annotations / stubs since Click 8.0 (so you typically don’t need
types-clickon modern Click). [1] - Typed
MultiCommandAPI: In the Click API docs,get_commandis documented as returningCommand | Noneandlist_commandsasList[str], which is what type checkers will expect your overrides to match. [3]
Sources:
[1] https://pypi.org/project/types-click/
[2] https://pocoo-click.readthedocs.io/en/latest/advanced/
[3] https://dokk.org/documentation/pallets-click/8.1.7/api/
🏁 Script executed:
# Find dependency files
fd -e "pyproject.toml" -e "setup.py" -e "requirements.txt" -e "setup.cfg" | head -20Repository: elementary-data/elementary
Length of output: 52
🏁 Script executed:
# Check for mypy configuration
fd -e "mypy.ini" -e ".mypy.ini" | head -10
cat pyproject.toml 2>/dev/null | grep -A 20 "\[tool.mypy\]" || trueRepository: elementary-data/elementary
Length of output: 52
🏁 Script executed:
# Search for click and types-click in dependencies
grep -r "types-click\|click" pyproject.toml setup.py setup.cfg requirements.txt 2>/dev/null || trueRepository: elementary-data/elementary
Length of output: 402
🏁 Script executed:
# Check full pyproject.toml for types-click and mypy config
cat pyproject.toml | head -150Repository: elementary-data/elementary
Length of output: 2653
🏁 Script executed:
# Check if types-click appears anywhere in dependencies
grep -i "types.click" pyproject.toml || echo "types-click not found in pyproject.toml"Repository: elementary-data/elementary
Length of output: 109
🏁 Script executed:
# Check if there's a lock file indicating actual versions
ls -la | grep -E "\.lock|poetry\.lock|Pipfile"Repository: elementary-data/elementary
Length of output: 52
🏁 Script executed:
# Check for mypy configuration in pyproject.toml
cat pyproject.toml | grep -A 30 "\[tool.mypy\]"Repository: elementary-data/elementary
Length of output: 52
🏁 Script executed:
# Check if there's a mypy.ini or .mypy.ini file
find . -maxdepth 2 -name "mypy.ini" -o -name ".mypy.ini" -o -name "mypy.cfg" 2>/dev/null | head -5Repository: elementary-data/elementary
Length of output: 80
🏁 Script executed:
# Verify the actual click version being used and Python version support
cat pyproject.toml | grep -E "python|click" | head -10Repository: elementary-data/elementary
Length of output: 366
🏁 Script executed:
# Check mypy.ini configuration
cat ./mypy.iniRepository: elementary-data/elementary
Length of output: 358
🏁 Script executed:
# Check the actual ElementaryCLI class to understand context
cat -n elementary/cli/cli.py | head -60Repository: elementary-data/elementary
Length of output: 2271
Scoped type ignore is good practice, but reconsider the explanatory comment.
Using specific error codes (misc, valid-type) rather than a blanket ignore is correct. However, the suggested comment is inaccurate—Click 8.0+ has full type stub support for MultiCommand subclassing. The actual issue is likely method return type mismatches: list_commands() returns dict_keys but the type stub expects Sequence[str], and get_command() may have signature mismatches.
If the type ignore is still necessary, a more accurate comment would be: # type: ignore[misc, valid-type] # Method signatures differ from click.MultiCommand stubs. Alternatively, consider adjusting method signatures to match Click's type expectations (return list() from list_commands(), explicitly type get_command() return as Command | None).
🤖 Prompt for AI Agents
In `@elementary/cli/cli.py` at line 39, The type-ignore comment on the
ElementaryCLI class is misleading; update it to accurately state why the ignore
is used or eliminate it by aligning method signatures: either change the comment
to "# type: ignore[misc, valid-type] # Method signatures differ from
click.MultiCommand stubs" or modify ElementaryCLI.list_commands to return a
Sequence[str] (e.g., return list(self._commands.keys())) and annotate
ElementaryCLI.get_command to return Command | None to match Click's stubs;
ensure both method signatures and return types conform to click.MultiCommand
expectations so the scoped type ignore is no longer necessary.
Python 3.9 reached end-of-life in October 2025, so I decided to remove it.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.