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
Provenance
- Commit
f85a35d- Tree
13b84b2- Author
Gianluca Gippetto <gianluca.gippetto@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
166b312
3 files changed+10 added−6 removed
modified:src/click/core.py+2 added-2 removed
1817 unmodified lines1818 Added the :attr:`command_class` attribute.1819 """1820 from .decorators import command1821 1822- 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_class1824 1825 func: t.Optional[t.Callable] = None1826 35 unmodified lines1862 if args and callable(args[0]):1863 func = args[0]1864 args = args[1:]1865 1866- 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_class1080 unmodified linesmodified:src/click/decorators.py+5 added-4 removed
242 unmodified lines243 244 .. 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"] = Group249 250 if callable(name):251 grp: t.Callable[[F], Group] = t.cast(Group, command(**attrs))252 return grp(name)22 unmodified lines275 :class:`Argument`.276 """277 278 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 f282 283 return decorator13 unmodified lines297 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()300 300- 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 f306 307 return decorator186 unmodified linesmodified:CHANGES.rst+3 added
22 unmodified lines23 - 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`30 31 32 Version 8.0.433 -------------948 unmodified lines