fix: References to upstream click causing further side effects (#1754)#1755
Open
Meizzajanor wants to merge 2 commits into
Open
fix: References to upstream click causing further side effects (#1754)#1755Meizzajanor wants to merge 2 commits into
click causing further side effects (#1754)#1755Meizzajanor wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Replaces direct click dependency usage with typer equivalents throughout the codebase, and switches __version__ import to importlib.metadata.
Changes:
- Remove
clickfrom dependencies and replaceclick.echo,click.BadParameter,click.exceptions.Exit,click.FileErrorwithtyperequivalents. - Replace
click.version_optionwith an explicit Typer--versioncallback. - Use
importlib.metadata.version("robotframework-robocop")instead ofrobocop.__version__.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Drops click dependency. |
| src/robocop/run.py | Replaces click version_option with Typer callback; uses importlib.metadata. |
| src/robocop/runtime/resolver.py | Switches click.echo to typer.echo. |
| src/robocop/formatter/runner.py | Updates a comment from click to typer. |
| src/robocop/formatter/utils/misc.py | Uses typer.BadParameter instead of click. |
| src/robocop/config/parser.py | Imports FileError from typer._click.exceptions. |
| tests/config/test_extend_config.py | Updates exception class to typer's FileError. |
| tests/formatter/init.py | Replaces click.exceptions.Exit with typer.Exit. |
| tests/linter/utils/init.py | Replaces click.exceptions.Exit with typer.Exit. |
| tests/test_cli.py | Uses importlib.metadata.version for version assertion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| click.version_option(version=__version__)(self) | ||
|
|
||
| def list_commands(self, ctx: click.Context) -> list[str]: # noqa: ARG002 | ||
| def list_commands(self, ctx: Any) -> list[str]: # noqa: ARG002 |
Comment on lines
+46
to
+47
| typer.echo(f"robocop, version {metadata.version('robotframework-robocop')}") | ||
| raise typer.Exit |
bhirsz
reviewed
May 27, 2026
| def version_callback(value: bool | None) -> None: | ||
| if not value: | ||
| return | ||
| typer.echo(f"robocop, version {metadata.version('robotframework-robocop')}") |
Member
There was a problem hiding this comment.
Since we already store the version under from robocop import version, why not use it? Is there any reason for chosing metadata.version over the version from the package directly?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request removes the dependency on
clickand fully migrates the CLI and related error handling to usetyperand its APIs. It updates imports, exception handling, and test code accordingly. Additionally, it refactors the version display logic to useimportlib.metadatafor version retrieval.Key changes include:
Dependency and Import Cleanup:
clickfrom the dependencies inpyproject.tomland all code imports, replacing them withtyperortyper._click.exceptionswhere necessary. [1] [2] [3] [4] [5] [6] [7]Error and Exception Handling:
click.FileErrorandclick.BadParameterwithtyperequivalents throughout the codebase and tests, ensuring consistent error handling. [1] [2] [3] [4]CLI Output and Echo:
click.echocalls totyper.echofor output and error messages. [1] [2] [3]CLI Version Handling:
--versionoption handled via atypercallback, retrieving the version withimportlib.metadatainstead of importing from the package. [1] [2] [3] [4] [5]Test Suite Updates:
typer.Exitand related exceptions instead ofclickexceptions, ensuring tests remain valid after the migration. [1] [2] [3]These changes collectively modernize the CLI implementation, streamline dependencies, and improve maintainability by unifying on the
typerlibrary.Issues:
Closes #1754 .