diff --git a/pulp_cli/generic.py b/pulp_cli/generic.py index 26089d8b..174ab432 100644 --- a/pulp_cli/generic.py +++ b/pulp_cli/generic.py @@ -49,6 +49,20 @@ else: SECRET_STORAGE = True +try: + # Sentinel is introduced in click 8.3. + # We need to use it to identify unset values. + _UNSET = click._utils.Sentinel.UNSET # type: ignore[attr-defined] + + def _unset(value: t.Any) -> bool: + return value is _UNSET or value is None or value == () or value == [] + +except AttributeError: + + def _unset(value: t.Any) -> bool: + return value is None or value == () or value == [] + + translation = get_translation(__package__) _ = translation.gettext @@ -474,7 +488,7 @@ def __init__( super().__init__(*args, **kwargs) def process_value(self, ctx: click.Context, value: t.Any) -> t.Any: - if self.needs_plugins and value is not None and value != (): + if self.needs_plugins and not _unset(value): pulp_ctx = ctx.find_object(PulpCLIContext) assert pulp_ctx is not None for plugin_requirement in self.needs_plugins: diff --git a/pyproject.toml b/pyproject.toml index 933e97e6..88d5d0eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers=[ ] dependencies = [ "pulp-glue==0.37.0.dev", - "click>=8.0.0,<8.3", # Proven to not do semver. + "click>=8.0.0,<8.4", # 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'",