Skip to content
Myr

Only try to set flag_value if is_flag is true (#2829)

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

authored by Leo Singer · committed by GitHub · parent 88328fc · Browse files · 3 files+6 added−4 removed
This commit

State

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

Trailers

  • Co-authored-by: Andreas Backx <andreas@backx.org>

Diff stats

3 files+6 added−4 removed

  • tests:+1 added−1 removed
  • other:+5 added−3 removed

3 files+6 added−4 removed

modified:src/click/core.py+2 added-3 removed
2595 unmodified lines
2596 self.default = ()2597 else:2598 self.default = False25992600 if flag_value is None:2601 flag_value = not self.default26022600 self.type: types.ParamType2601 if is_flag and type is None:2602 if flag_value is None:2603 flag_value = not self.default2604 # Re-guess the type from the flag value instead of the2605 # default.2606 self.type = types.convert_type(None, flag_value)2607
514 unmodified lines
modified:tests/test_info_dict.py+1 added-1 removed
56 unmodified lines
57 "envvar": None,58 "help": None,59 "prompt": None,60 "is_flag": False,61 "flag_value": False,61 "flag_value": None,62 "count": False,63 "hidden": False,64 },65)
210 unmodified lines
modified:CHANGES.rst+3 added
89 unmodified lines
9091- Add a ``catch_exceptions`` parameter to :class:`CliRunner`. If92 ``catch_exceptions`` is not passed to :meth:`CliRunner.invoke`,93 the value from :class:`CliRunner`. :issue:`2817` :pr:`2818`94- ``Option.flag_value`` will no longer have a default value set based on95 ``Option.default`` if ``Option.is_flag`` is ``False``. This results in96 ``Option.default`` not needing to implement `__bool__`. :pr:`2829`9798Version 8.1.899-------------100
1117 unmodified lines