PEP 572: disallow ungrouped assign-expr in annotations (#720)

This commit is contained in:
Georg Brandl 2018-07-10 17:05:11 +02:00 committed by Guido van Rossum
parent abab110be1
commit d6fcb1c735
1 changed files with 12 additions and 0 deletions

View File

@ -182,6 +182,18 @@ in order to avoid ambiguities or user confusion:
style recommendation against mutable default values), and also to style recommendation against mutable default values), and also to
echo the similar prohibition in calls (the previous bullet). echo the similar prohibition in calls (the previous bullet).
- Unparenthesized assignment expressions are prohibited as annotations
for arguments, return values and assignments. Example::
def foo(answer: p := 42 = 5): # INVALID
...
def foo(answer: (p := 42) = 5): # Valid, but probably never useful
...
The reasoning here is similar to the two previous cases; this
ungrouped assortment of symbols and operators composed of ``:`` and
``=`` is hard to read correctly.
Scope of the target Scope of the target
------------------- -------------------