PEP 677: Clarify support for PEP 646 Unpack/* (#2198)
This commit is contained in:
parent
80e009085f
commit
21f6df59ed
15
pep-0677.rst
15
pep-0677.rst
|
@ -450,7 +450,8 @@ Here are our proposed changes to the `Python Grammar
|
|||
|
||||
|
||||
If PEP 646 is accepted, we intend to include support for unpacked
|
||||
types by modifying the grammar for
|
||||
types in two ways. To support the "star-for-unpack" syntax proposed in
|
||||
PEP 646, we will modify the grammar for
|
||||
``callable_type_positional_argument`` as follows::
|
||||
|
||||
callable_type_positional_argument:
|
||||
|
@ -459,11 +460,21 @@ types by modifying the grammar for
|
|||
| '*' expression ','
|
||||
| '*' expression &')'
|
||||
|
||||
With this change, a type of the form ``(int, *Ts) -> bool`` should
|
||||
evaluate the AST form::
|
||||
|
||||
CallableType(
|
||||
ArgumentsList(Name("int"), Starred(Name("Ts")),
|
||||
Name("bool")
|
||||
)
|
||||
|
||||
and be treated by type checkers as equivalent to
|
||||
``Callable[[int, Unpack[Ts]], bool]``.
|
||||
|
||||
|
||||
Implications of the Grammar
|
||||
---------------------------
|
||||
|
||||
|
||||
Precedence of ->
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
Loading…
Reference in New Issue