Skip to content
20 changes: 20 additions & 0 deletions typer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ def make_metavar(self, ctx: Union[click.Context, None] = None) -> str:
var += "..."
return var

def value_is_missing(self, value: Any) -> bool:
return _value_is_missing(self, value)


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

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

def value_is_missing(self, value: Any) -> bool:
return _value_is_missing(self, value)


def _value_is_missing(param: click.Parameter, value: Any) -> bool:
if value is None:
return True

# Click 8.3 and beyond
# if value is UNSET:
# return True

if (param.nargs != 1 or param.multiple) and value == ():
return True # pragma: no cover

return False


def _typer_format_options(
self: click.core.Command, *, ctx: click.Context, formatter: click.HelpFormatter
Expand Down
Loading