Skip to content

Commit 7a23d25

Browse files
👽️ Ensure compatibility with Click 8.3.0 by restoring the original value_is_missing function (#1333)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 47e3bd6 commit 7a23d25

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎typer/core.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ def make_metavar(self, ctx: Union[click.Context, None] = None) -> str:
403403
var += "..."
404404
return var
405405

406+
def value_is_missing(self, value: Any) -> bool:
407+
return _value_is_missing(self, value)
408+
406409

407410
class TyperOption(click.core.Option):
408411
def __init__(
@@ -593,6 +596,23 @@ def _write_opts(opts: Sequence[str]) -> str:
593596

594597
return ("; " if any_prefix_is_slash else " / ").join(rv), help
595598

599+
def value_is_missing(self, value: Any) -> bool:
600+
return _value_is_missing(self, value)
601+
602+
603+
def _value_is_missing(param: click.Parameter, value: Any) -> bool:
604+
if value is None:
605+
return True
606+
607+
# Click 8.3 and beyond
608+
# if value is UNSET:
609+
# return True
610+
611+
if (param.nargs != 1 or param.multiple) and value == ():
612+
return True # pragma: no cover
613+
614+
return False
615+
596616

597617
def _typer_format_options(
598618
self: click.core.Command, *, ctx: click.Context, formatter: click.HelpFormatter

0 commit comments

Comments
 (0)