Skip to content
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

Pass package_name explicitly in click.version_option decorators for compatibility with click>=8.0 #1400

Merged
merged 10 commits into from
Jun 4, 2021
9 changes: 8 additions & 1 deletion piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
DEFAULT_REQUIREMENTS_OUTPUT_FILE = "requirements.txt"
METADATA_FILENAMES = frozenset({"setup.py", "setup.cfg", "pyproject.toml"})

# TODO: drop click 7 and remove this block, pass directly to version_option
if click.__version__[0] == "7":
nicoa marked this conversation as resolved.
Show resolved Hide resolved
ver_kwargs = {}
else:
# this was introduced in click8 and if not passed would break this package
ver_kwargs = {"package_name": "pip-tools"}


def _get_default_option(option_name: str) -> Any:
"""
Expand All @@ -45,7 +52,7 @@ def _get_default_option(option_name: str) -> Any:


@click.command(context_settings={"help_option_names": ("-h", "--help")})
@click.version_option()
@click.version_option(**ver_kwargs)
@click.pass_context
@click.option("-v", "--verbose", count=True, help="Show more output")
@click.option("-q", "--quiet", count=True, help="Give less output")
Expand Down
10 changes: 9 additions & 1 deletion piptools/scripts/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
DEFAULT_REQUIREMENTS_FILE = "requirements.txt"


# TODO: drop click 7 and remove this block, pass directly to version_option
if click.__version__[0] == "7":
ver_kwargs = {}
else:
# this was introduced in click8 and if not passed would break this package
ver_kwargs = {"package_name": "pip-tools"}


@click.command(context_settings={"help_option_names": ("-h", "--help")})
@click.version_option()
@click.version_option(**ver_kwargs)
@click.option(
"-a",
"--ask",
Expand Down