From d6fcb1c735ab08e6915741e4d47895796901435e Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 10 Jul 2018 17:05:11 +0200 Subject: [PATCH] PEP 572: disallow ungrouped assign-expr in annotations (#720) --- pep-0572.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pep-0572.rst b/pep-0572.rst index 2577fe208..80ea56a45 100644 --- a/pep-0572.rst +++ b/pep-0572.rst @@ -182,6 +182,18 @@ in order to avoid ambiguities or user confusion: style recommendation against mutable default values), and also to 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 -------------------