From e30933b6ac4b10c8808a2717a1e1ae52e04ff925 Mon Sep 17 00:00:00 2001 From: JiachenSmith Date: Sun, 8 Jan 2023 15:19:05 +0800 Subject: [PATCH] Fix click v7 version_option compatibility (#1410) It looks like the ternary was committed backwards in https://github.com/jazzband/pip-tools/pull/1400, since the `package_name` option was add in click 8, but is only being passed in click 7. That caused `pip-tools` to error on import when installed alongside click 7. --- piptools/scripts/compile.py | 2 +- piptools/scripts/sync.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py index 44469dd..f7a786c 100755 --- a/piptools/scripts/compile.py +++ b/piptools/scripts/compile.py @@ -34,7 +34,7 @@ METADATA_FILENAMES = frozenset({"setup.py", "setup.cfg", "pyproject.toml"}) # TODO: drop click 7 and remove this block, pass directly to version_option -version_option_kwargs = {} if IS_CLICK_VER_8_PLUS else {"package_name": "pip-tools"} +version_option_kwargs = {"package_name": "pip-tools"} if IS_CLICK_VER_8_PLUS else {} def _get_default_option(option_name: str) -> Any: diff --git a/piptools/scripts/sync.py b/piptools/scripts/sync.py index ea23454..9636cd7 100755 --- a/piptools/scripts/sync.py +++ b/piptools/scripts/sync.py @@ -20,7 +20,7 @@ DEFAULT_REQUIREMENTS_FILE = "requirements.txt" # TODO: drop click 7 and remove this block, pass directly to version_option -version_option_kwargs = {} if IS_CLICK_VER_8_PLUS else {"package_name": "pip-tools"} +version_option_kwargs = {"package_name": "pip-tools"} if IS_CLICK_VER_8_PLUS else {} @click.command(context_settings={"help_option_names": ("-h", "--help")})