-
Notifications
You must be signed in to change notification settings - Fork 55
fix: References to upstream click causing further side effects (#1754)
#1755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,11 @@ | ||
| import textwrap | ||
| from importlib import metadata | ||
| from pathlib import Path | ||
| from typing import Annotated, Any | ||
|
|
||
| import click | ||
| import typer | ||
| from rich.console import Console | ||
|
|
||
| from robocop import __version__ | ||
| from robocop.config import defaults, manager, parser, schema | ||
| from robocop.formatter.runner import RobocopFormatter | ||
| from robocop.linter import rules_list | ||
|
|
@@ -20,11 +19,7 @@ | |
|
|
||
|
|
||
| class CliWithVersion(typer.core.TyperGroup): | ||
| def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
| super().__init__(*args, **kwargs) | ||
| 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 | ||
|
|
||
| """Return the list of commands in the set order.""" | ||
| commands = ["check", "check-project", "format", "list", "docs"] | ||
| for command in self.commands: | ||
|
|
@@ -45,6 +40,28 @@ def list_commands(self, ctx: click.Context) -> list[str]: # noqa: ARG002 | |
| app.add_typer(list_app, name="list") | ||
|
|
||
|
|
||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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? |
||
| raise typer.Exit | ||
|
Comment on lines
+46
to
+47
|
||
|
|
||
|
|
||
| @app.callback() | ||
| def main_callback( | ||
| version: Annotated[ | ||
| bool | None, | ||
| typer.Option( | ||
| "--version", | ||
| help="Show the version and exit.", | ||
| callback=version_callback, | ||
| is_eager=True, | ||
| ), | ||
| ] = None, | ||
| ) -> None: | ||
| """Run Robocop.""" | ||
|
|
||
|
|
||
| config_option = Annotated[ | ||
| Path | None, | ||
| typer.Option( | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.