Skip to content
Myr

fix generic typed dict `TypeError` on Python 3.10

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

authored by jorenham · committed by jorenham · parent 77bd81f · Browse files · 1 file+40 added−11 removed
This commit

State

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

Diff stats

1 file+40 added−11 removed

  • other:+40 added−11 removed

1 file+40 added−11 removed

modified:src/click/types.py+40 added-11 removed
187 unmodified lines
188 @abc.abstractmethod189 def arity(self) -> int: ... # type: ignore[override]190191192class FuncParamTypeInfoDict(ParamTypeInfoDict, t.Generic[_ValueT_contra, _ValueT_co]):193 func: t.Callable[[_ValueT_contra], _ValueT_co]192if t.TYPE_CHECKING:193 # on Python 3.10 this will raise a TypeError194195 class FuncParamTypeInfoDict(196 ParamTypeInfoDict,197 t.Generic[_ValueT_contra, _ValueT_co],198 ):199 func: t.Callable[[_ValueT_contra], _ValueT_co]200else:201202 class FuncParamTypeInfoDict(ParamTypeInfoDict):203 func: t.Callable[[t.Any], t.Any]204205206class FuncParamType(ParamType[_ValueT_co], t.Generic[_ValueT_contra, _ValueT_co]):207 name: str208 func: t.Callable[[_ValueT_contra], _ValueT_co]209
57 unmodified lines
267 def __repr__(self) -> str:268 return "STRING"269270261class ChoiceInfoDict(ParamTypeInfoDict, t.Generic[_ValueT_co]):262 choices: tuple[_ValueT_co, ...]263 case_sensitive: bool271if t.TYPE_CHECKING:272 # on Python 3.10 this will raise a TypeError273274 class ChoiceInfoDict(ParamTypeInfoDict, t.Generic[_ValueT_co]):275 choices: tuple[_ValueT_co, ...]276 case_sensitive: bool277else:278279 class ChoiceInfoDict(ParamTypeInfoDict):280 choices: tuple[t.Any, ...]281 case_sensitive: bool282283284class Choice(ParamType[_ValueT_co], t.Generic[_ValueT_co]):285 """The choice type allows a value to be checked against a fixed set286 of supported values.287
263 unmodified lines
551 ctx,552 )553554537class NumberRangeInfoDict(ParamTypeInfoDict, t.Generic[_FloatValueT_co]):538 min: _FloatValueT_co | None539 max: _FloatValueT_co | None540 min_open: bool541 max_open: bool542 clamp: bool555if t.TYPE_CHECKING:556 # on Python 3.10 this will raise a TypeError557558 class NumberRangeInfoDict(ParamTypeInfoDict, t.Generic[_FloatValueT_co]):559 min: _FloatValueT_co | None560 max: _FloatValueT_co | None561 min_open: bool562 max_open: bool563 clamp: bool564else:565566 class NumberRangeInfoDict(ParamTypeInfoDict):567 min: t.Any | None568 max: t.Any | None569 min_open: bool570 max_open: bool571 clamp: bool572573574class _NumberRangeBase(575 _NumberParamTypeBase[_ValueT_contra, _FloatValueT_co],576 t.Generic[_ValueT_contra, _FloatValueT_co],577):
797 unmodified lines