diff --git a/.ci/scripts/check_click_for_mypy.py b/.ci/scripts/check_click_for_mypy.py index 2941277ea..408a7c6af 100755 --- a/.ci/scripts/check_click_for_mypy.py +++ b/.ci/scripts/check_click_for_mypy.py @@ -1,12 +1,12 @@ #!/bin/env python3 -from importlib.metadata import version +from importlib import metadata -from packaging.version import parse +from packaging.version import Version -click_version = version("click") - -if parse(click_version) < parse("8.1.1") or parse(click_version) >= parse("8.2"): - print("🚧 Linting with mypy is currently only supported with click~=8.1.1. 🚧") - print("🔧 Please run `pip install click~=8.1.1` first. 🔨") - exit(1) +if __name__ == "__main__": + click_version = Version(metadata.version("click")) + if click_version < Version("8.1.1"): + print("🚧 Linting with mypy is currently only supported with click>=8.1.1. 🚧") + print("🔧 Please run `pip install click>=8.1.1` first. 🔨") + exit(1) diff --git a/CHANGES/+click_8.2.feature b/CHANGES/+click_8.2.feature new file mode 100644 index 000000000..7bf1732af --- /dev/null +++ b/CHANGES/+click_8.2.feature @@ -0,0 +1 @@ +Add support for click 8.2. diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/check_click_for_mypy.py b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/check_click_for_mypy.py index a905be7ef..408a7c6af 100755 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/check_click_for_mypy.py +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/.ci/scripts/check_click_for_mypy.py @@ -1,9 +1,12 @@ #!/bin/env python3 -import click -from packaging.version import parse +from importlib import metadata -if parse(click.__version__) < parse("8.1.1") or parse(click.__version__) >= parse("8.2"): - print("🚧 Linting with mypy is currently only supported with click~=8.1.1. 🚧") - print("🔧 Please run `pip install click~=8.1.1` first. 🔨") - exit(1) +from packaging.version import Version + +if __name__ == "__main__": + click_version = Version(metadata.version("click")) + if click_version < Version("8.1.1"): + print("🚧 Linting with mypy is currently only supported with click>=8.1.1. 🚧") + print("🔧 Please run `pip install click>=8.1.1` first. 🔨") + exit(1) diff --git a/pulpcore/cli/core/task_group.py b/pulpcore/cli/core/task_group.py index 414006a07..54a8634dd 100644 --- a/pulpcore/cli/core/task_group.py +++ b/pulpcore/cli/core/task_group.py @@ -19,7 +19,7 @@ _ = translation.gettext -@pulp_group() +@pulp_group(name="task-group") @pass_pulp_context @click.pass_context def task_group(ctx: click.Context, pulp_ctx: PulpCLIContext, /) -> None: diff --git a/pulpcore/cli/rpm/prune.py b/pulpcore/cli/rpm/prune.py index e48310fc9..e8bc77085 100644 --- a/pulpcore/cli/rpm/prune.py +++ b/pulpcore/cli/rpm/prune.py @@ -33,9 +33,7 @@ @multi_repository_option @click.option( "--all-repositories", - type=bool, is_flag=True, - show_default=True, default=False, help=_("Prune *all* repositories accessible to the invoking user."), ) @@ -47,9 +45,7 @@ ) @click.option( "--dry-run", - type=bool, is_flag=True, - show_default=True, default=False, help=_("Evaluate the prune-status of the specified repositories but DO NOT make any changes."), ) @@ -73,7 +69,6 @@ def prune_packages( You may not specify --all-repositories *and* one or more specific repositories. """ - prune_ctx = PulpRpmPruneContext(pulp_ctx) if not (all_repositories or repositories): raise PulpException( _("at least one --repository, or --all-repositories, must be specified") @@ -87,5 +82,6 @@ def prune_packages( ["*"] if all_repositories else list(repositories) ) + prune_ctx = PulpRpmPruneContext(pulp_ctx) result = prune_ctx.prune_packages(repos_list, keep_days, dry_run) pulp_ctx.output_result(result) diff --git a/pyproject.toml b/pyproject.toml index 7fe36b440..278276b67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers=[ ] dependencies = [ "pulp-glue==0.33.0.dev", - "click>=8.0.0,<8.2", # Proven to not do semver. + "click>=8.0.0,<8.3", # Proven to not do semver. "PyYAML>=5.3,<6.1", "schema>=0.7.5,<0.8", "tomli>=2.0.0,<2.1;python_version<'3.11'", diff --git a/tests/test_help_pages.py b/tests/test_help_pages.py index 3534ab4c3..5ca7a58d5 100644 --- a/tests/test_help_pages.py +++ b/tests/test_help_pages.py @@ -48,7 +48,10 @@ def test_access_help(no_api: None, subtests: SubTests) -> None: result = runner.invoke(main, args + ["--help"], catch_exceptions=False) if result.exit_code == 2: - assert "not available in this context" in result.stdout + assert ( + "not available in this context" in result.stdout + or "not available in this context" in result.stderr + ) else: assert result.exit_code == 0 assert result.stdout.startswith("Usage:") or result.stdout.startswith(