@@ -379,29 +379,32 @@ We introduce a ``Param`` type that contains all the information about a function
379379 class Param[
380380 N: str | None,
381381 T,
382- K: ParamKind = Literal["positional_or_keyword" ],
382+ K: ParamKind = Literal[ParamKind.POSITIONAL_OR_KEYWORD ],
383383 D = typing.Never,
384384 ]:
385385 pass
386386
387- ParamKind = typing.Literal[
388- "*", "**", "keyword", "positional", "positional_or_keyword"
389- ]
387+ class ParamKind(enum.IntEnum):
388+ POSITIONAL_ONLY = 0
389+ POSITIONAL_OR_KEYWORD = 1
390+ VAR_POSITIONAL = 2
391+ KEYWORD_ONLY = 3
392+ VAR_KEYWORD = 4
390393
391- type PosParam[T] = Param[None, T, Literal["positional" ]]
392- type PosDefaultParam[T] = Param[None, T, Literal["positional" ], T]
393- type DefaultParam[N: str, T] = Param[N, T, Literal["positional_or_keyword" ], T]
394- type NamedParam[N: str, T] = Param[N, T, Literal["keyword" ]]
395- type NamedDefaultParam[N: str, T] = Param[N, T, Literal["keyword" ], T]
396- type ArgsParam[T] = Param[None, T, Literal["*" ]]
397- type KwargsParam[T] = Param[None, T, Literal["**" ]]
394+ type PosParam[T] = Param[None, T, Literal[ParamKind.POSITIONAL_ONLY ]]
395+ type PosDefaultParam[T] = Param[None, T, Literal[ParamKind.POSITIONAL_ONLY ], T]
396+ type DefaultParam[N: str, T] = Param[N, T, Literal[ParamKind.POSITIONAL_OR_KEYWORD ], T]
397+ type NamedParam[N: str, T] = Param[N, T, Literal[ParamKind.KEYWORD_ONLY ]]
398+ type NamedDefaultParam[N: str, T] = Param[N, T, Literal[ParamKind.KEYWORD_ONLY ], T]
399+ type ArgsParam[T] = Param[None, T, Literal[ParamKind.VAR_POSITIONAL ]]
400+ type KwargsParam[T] = Param[None, T, Literal[ParamKind.VAR_KEYWORD ]]
398401
399402
400403The argument ``K ``, of type ``ParamKind ``, represents the parameter
401404kind of the parameter, and defaults to the ordinary
402- ``Literal["positional_or_keyword" ] ``. It is an error to create
403- ``Callable `` with a `` Param `` containing multiple kinds unioned
404- together.
405+ ``Literal[ParamKind.POSITIONAL_OR_KEYWORD ] ``. `` ParamKind `` mirrors
406+ ``inspect._ParameterKind ``. It is an error to create `` Callable ``
407+ with a `` Param `` containing multiple kinds unioned together.
405408
406409The argument ``D `` carries the type of the parameter's default, if one
407410exists, and is ``Never `` otherwise. When the default value is a
@@ -438,13 +441,13 @@ as::
438441
439442 Callable[
440443 Params[
441- Param[Literal["a"], int, Literal["positional" ]],
444+ Param[Literal["a"], int, Literal[ParamKind.POSITIONAL_ONLY ]],
442445 Param[Literal["b"], int],
443- Param[Literal["c"], int, Literal["positional_or_keyword" ], Literal[0]],
444- Param[None, int, Literal["*" ]],
445- Param[Literal["d"], int, Literal["keyword" ]],
446- Param[Literal["e"], int, Literal["keyword" ], Literal[0]],
447- Param[None, int, Literal["**" ]],
446+ Param[Literal["c"], int, Literal[ParamKind.POSITIONAL_OR_KEYWORD ], Literal[0]],
447+ Param[None, int, Literal[ParamKind.VAR_POSITIONAL ]],
448+ Param[Literal["d"], int, Literal[ParamKind.KEYWORD_ONLY ]],
449+ Param[Literal["e"], int, Literal[ParamKind.KEYWORD_ONLY ], Literal[0]],
450+ Param[None, int, Literal[ParamKind.VAR_KEYWORD ]],
448451 ],
449452 int,
450453 ]
@@ -1124,7 +1127,7 @@ based on iterating over all attributes.
11241127 p.name,
11251128 p.type,
11261129 # All arguments are keyword-only
1127- Literal["keyword" ],
1130+ Literal[ParamKind.KEYWORD_ONLY ],
11281131 # GetDefault is Never when there's no default, so use it
11291132 # directly as D.
11301133 GetDefault[p.init],
@@ -1903,11 +1906,6 @@ Open Issues
19031906 ``readonly `` had been added as a parameter to ``TypedDict `` we would
19041907 use that, but it wasn't.
19051908
1906- * :ref: `Extended Callables <pep827-extended-callables-prereq >`: Currently the
1907- qualifiers are short strings for code brevity, but an alternate approach
1908- would be to mirror ``inspect.Signature `` more directly, and have an enum
1909- with names like ``ParamKind.POSITIONAL_OR_KEYWORD ``. Would that be better?
1910-
19111909* :ref: `Members <pep827-members >`: Should ``Members `` return all
19121910 methods, even those without annotations? We excluded them out of the
19131911 desire for some consistency with attributes, but it would not be
0 commit comments