Skip to content
Myr

Merge branch '8.1.x'

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

authored by David Lord · committed by David Lord · parents 6bd8e56, 9c6f4c8 · Browse files · 8 files+41 added−8 removed
This commit

State

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

Diff stats

8 files+41 added−8 removed

  • tests:+18 added−0 removed
  • other:+23 added−8 removed

8 files+41 added−8 removed

modified:requirements/dev.txt+1 added-1 removed
18 unmodified lines
19filelock==3.6.020 # via21 # tox22 # virtualenv23identify==2.4.1223identify==2.5.024 # via pre-commit25nodeenv==1.6.026 # via pre-commit27pep517==0.12.0
33 unmodified lines
modified:requirements/docs.txt+1 added-1 removed
19 unmodified lines
20idna==3.321 # via requests22imagesize==1.3.023 # via sphinx24jinja2==3.1.124jinja2==3.1.225 # via sphinx26markupsafe==2.1.127 # via jinja228packaging==21.3
44 unmodified lines
modified:requirements/typing.txt+1 added-1 removed
3 unmodified lines
4# To update, run:5#6# pip-compile-multi7#8mypy==0.9428mypy==0.9509 # via -r requirements/typing.in10mypy-extensions==0.4.311 # via mypy12tomli==2.0.1
3 unmodified lines
modified:src/click/core.py+3 added
2578 unmodified lines
25792580 if self.is_flag:2581 raise TypeError("'count' is not valid with 'is_flag'.")25822583 if self.multiple and self.is_flag:2584 raise TypeError("'multiple' is not valid with 'is_flag', use 'count'.")25852586 def to_info_dict(self) -> t.Dict[str, t.Any]:2587 info_dict = super().to_info_dict()2588 info_dict.update(2589 help=self.help,
409 unmodified lines
modified:src/click/decorators.py+4 added-4 removed
147 unmodified lines
148 ...149150151def command(152 name: t.Union[str, t.Callable, None] = None,152 name: t.Union[str, t.Callable[..., t.Any], None] = None,153 cls: t.Optional[t.Type[Command]] = None,154 **attrs: t.Any,155) -> t.Union[Command, t.Callable[..., Command]]:156 r"""Creates a new :class:`Command` and uses the decorated function as
24 unmodified lines
181 The ``params`` argument can be used. Decorated params are182 appended to the end of the list.183 """184185 func: t.Optional[t.Callable] = None185 func: t.Optional[t.Callable[..., t.Any]] = None186187 if callable(name):188 func = name189 name = None
37 unmodified lines
227228229@t.overload230def group(231 __func: t.Callable,231 __func: t.Callable[..., t.Any],232) -> Group:233 ...234235
5 unmodified lines
241 ...242243244def group(245 name: t.Union[str, t.Callable, None] = None, **attrs: t.Any245 name: t.Union[str, t.Callable[..., t.Any], None] = None, **attrs: t.Any246) -> t.Union[Group, t.Callable[[F], Group]]:247 """Creates a new :class:`Group` with a function as callback. This248 works otherwise the same as :func:`command` just that the `cls`249 parameter is set to :class:`Group`.
248 unmodified lines
modified:tests/test_options.py+18 added
902 unmodified lines
903 ],904)905def test_is_bool_flag_is_correctly_set(option, expected):906 assert option.is_bool_flag is expected907908909@pytest.mark.parametrize(910 ("kwargs", "message"),911 [912 ({"count": True, "multiple": True}, "'count' is not valid with 'multiple'."),913 ({"count": True, "is_flag": True}, "'count' is not valid with 'is_flag'."),914 (915 {"multiple": True, "is_flag": True},916 "'multiple' is not valid with 'is_flag', use 'count'.",917 ),918 ],919)920def test_invalid_flag_combinations(runner, kwargs, message):921 with pytest.raises(TypeError) as e:922 click.Option(["-a"], **kwargs)923924 assert message in str(e.value)
modified:.pre-commit-config.yaml+1 added-1 removed
modified:CHANGES.rst+12 added
4 unmodified lines
56Unreleased789Version 8.1.310-------------1112Released 2022-04-281314- Use verbose form of ``typing.Callable`` for ``@command`` and15 ``@group``. :issue:`2255`16- Show error when attempting to create an option with17 ``multiple=True, is_flag=True``. Use ``count`` instead.18 :issue:`2246`192021Version 8.1.222-------------2324Released 2022-03-31
1026 unmodified lines