_utils.py
This file
Path
src/click/_utils.py
36 lines · 943 bytes · Python
Last changed by
Merge branch 'main' into stableDavid Lordbefore adoption81a482f
History of this fileTake it
1from __future__ import annotations23import enum4import typing as t567class Sentinel(enum.Enum):8 """Enum used to define sentinel values.910 .. seealso::1112 `PEP 661 - Sentinel Values <https://peps.python.org/pep-0661/>`_.13 """1415 UNSET = object()16 FLAG_NEEDS_VALUE = object()1718 def __repr__(self) -> str:19 return f"{self.__class__.__name__}.{self.name}"202122UNSET = Sentinel.UNSET23"""Sentinel used to indicate that a value is not set."""2425FLAG_NEEDS_VALUE = Sentinel.FLAG_NEEDS_VALUE26"""Sentinel used to indicate an option was passed as a flag without a27value but is not a flag option.2829``Option.consume_value`` uses this to prompt or use the ``flag_value``.30"""3132T_UNSET = t.Literal[UNSET] # type: ignore[valid-type]33"""Type hint for the :data:`UNSET` sentinel value."""3435T_FLAG_NEEDS_VALUE = t.Literal[FLAG_NEEDS_VALUE] # type: ignore[valid-type]36"""Type hint for the :data:`FLAG_NEEDS_VALUE` sentinel value."""