Skip to content
Myr

param=None is the same as not passing the param

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Gianluca Gippetto · committed by David Lord · parent 166b312 · Browse files · 3 files+10 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−6 removed

  • other:+10 added−6 removed

3 files+10 added−6 removed

modified:src/click/core.py+2 added-2 removed
1817 unmodified lines
1818 Added the :attr:`command_class` attribute.1819 """1820 from .decorators import command18211822 if self.command_class is not None and "cls" not in kwargs:1822 if self.command_class and kwargs.get("cls") is None:1823 kwargs["cls"] = self.command_class18241825 func: t.Optional[t.Callable] = None1826
35 unmodified lines
1862 if args and callable(args[0]):1863 func = args[0]1864 args = args[1:]18651866 if self.group_class is not None and "cls" not in kwargs:1866 if self.group_class is not None and kwargs.get("cls") is None:1867 if self.group_class is type:1868 kwargs["cls"] = type(self)1869 else:1870 kwargs["cls"] = self.group_class
1080 unmodified lines
modified:src/click/decorators.py+5 added-4 removed
242 unmodified lines
243244 .. versionchanged:: 8.1245 This decorator can be applied without parentheses.246 """247 attrs.setdefault("cls", Group)247 if attrs.get("cls") is None:248 attrs["cls"] = Group249250 if callable(name):251 grp: t.Callable[[F], Group] = t.cast(Group, command(**attrs))252 return grp(name)
22 unmodified lines
275 :class:`Argument`.276 """277278 def decorator(f: FC) -> FC:278 ArgumentClass = attrs.pop("cls", Argument)279 ArgumentClass = attrs.pop("cls", None) or Argument280 _param_memo(f, ArgumentClass(param_decls, **attrs))281 return f282283 return decorator
13 unmodified lines
297 def decorator(f: FC) -> FC:298 # Issue 926, copy attrs, so pre-defined options can re-use the same cls=299 option_attrs = attrs.copy()300300 if "help" in option_attrs:301 if option_attrs.get("help"):302 option_attrs["help"] = inspect.cleandoc(option_attrs["help"])302 OptionClass = option_attrs.pop("cls", Option)303 OptionClass = option_attrs.pop("cls", None) or Option304 _param_memo(f, OptionClass(param_decls, **option_attrs))305 return f306307 return decorator
186 unmodified lines
modified:CHANGES.rst+3 added
22 unmodified lines
23- The ``Path`` type can check whether the target is executable.24 :issue:`1961`25- ``Command.show_default`` overrides ``Context.show_default``, instead26 of the other way around. :issue:`1963`27- Parameter decorators and ``@group`` handles ``cls=None`` the same as28 not passing ``cls``. ``@option`` handles ``help=None`` the same as29 not passing ``help``. :issue:`#1959`303132Version 8.0.433-------------
948 unmodified lines