diff options
author | Gianluca Gippetto <gianluca.gippetto@gmail.com> | 2021-06-18 15:43:37 +0200 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2022-02-20 08:57:45 -0800 |
commit | f85a35daa401b1aa2e9303e092890884fd11a890 (patch) | |
tree | 13b84b2c729bdce5877a84fb131c70332332523b /src | |
parent | 166b31261f55ba3126456bbc2ff9e16142115e56 (diff) | |
download | click-f85a35daa401b1aa2e9303e092890884fd11a890.tar.gz |
param=None is the same as not passing the param
Diffstat (limited to 'src')
-rw-r--r-- | src/click/core.py | 4 | ||||
-rw-r--r-- | src/click/decorators.py | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/click/core.py b/src/click/core.py index 4b96767..604d8ba 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -1819,7 +1819,7 @@ class Group(MultiCommand): """ from .decorators import command - if self.command_class is not None and "cls" not in kwargs: + if self.command_class and kwargs.get("cls") is None: kwargs["cls"] = self.command_class func: t.Optional[t.Callable] = None @@ -1863,7 +1863,7 @@ class Group(MultiCommand): func = args[0] args = args[1:] - if self.group_class is not None and "cls" not in kwargs: + if self.group_class is not None and kwargs.get("cls") is None: if self.group_class is type: kwargs["cls"] = type(self) else: diff --git a/src/click/decorators.py b/src/click/decorators.py index a8c6d2d..a2fbadd 100644 --- a/src/click/decorators.py +++ b/src/click/decorators.py @@ -244,7 +244,8 @@ def group( .. versionchanged:: 8.1 This decorator can be applied without parentheses. """ - attrs.setdefault("cls", Group) + if attrs.get("cls") is None: + attrs["cls"] = Group if callable(name): grp: t.Callable[[F], Group] = t.cast(Group, command(**attrs)) @@ -275,7 +276,7 @@ def argument(*param_decls: str, **attrs: t.Any) -> t.Callable[[FC], FC]: """ def decorator(f: FC) -> FC: - ArgumentClass = attrs.pop("cls", Argument) + ArgumentClass = attrs.pop("cls", None) or Argument _param_memo(f, ArgumentClass(param_decls, **attrs)) return f @@ -297,9 +298,9 @@ def option(*param_decls: str, **attrs: t.Any) -> t.Callable[[FC], FC]: # Issue 926, copy attrs, so pre-defined options can re-use the same cls= option_attrs = attrs.copy() - if "help" in option_attrs: + if option_attrs.get("help"): option_attrs["help"] = inspect.cleandoc(option_attrs["help"]) - OptionClass = option_attrs.pop("cls", Option) + OptionClass = option_attrs.pop("cls", None) or Option _param_memo(f, OptionClass(param_decls, **option_attrs)) return f |