]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add support for named exprs inside function calls as gen-exps (#3327)
authorBatuhan Taskaya <isidentical@gmail.com>
Mon, 10 Oct 2022 23:54:09 +0000 (02:54 +0300)
committerGitHub <noreply@github.com>
Mon, 10 Oct 2022 23:54:09 +0000 (10:54 +1100)
CHANGES.md
src/blib2to3/Grammar.txt
tests/data/py_310/pep_572_py310.py

index 3a8cf4d6af5c68f2d95f17d2071092d019ed75da..ba9f4c06f284d7464d9d012e5ef2541fa87dfc11 100644 (file)
 
 <!-- Changes to the parser or to version autodetection -->
 
 
 <!-- Changes to the parser or to version autodetection -->
 
+- Parsing support has been added for walruses inside generator expression that are
+  passed as function args (for example,
+  `any(match := my_re.match(text) for text in texts)`) (#3327).
+
 ### Performance
 
 <!-- Changes that improve Black's performance. -->
 ### Performance
 
 <!-- Changes that improve Black's performance. -->
index ac7ad7643ffb8deaef567e85849d7da140143a98..bd8a452a3862476be93bb95776cfe5e15db6f01e 100644 (file)
@@ -186,7 +186,7 @@ arglist: argument (',' argument)* [',']
 # multiple (test comp_for) arguments are blocked; keyword unpackings
 # that precede iterable unpackings are blocked; etc.
 argument: ( test [comp_for] |
 # multiple (test comp_for) arguments are blocked; keyword unpackings
 # that precede iterable unpackings are blocked; etc.
 argument: ( test [comp_for] |
-            test ':=' test |
+            test ':=' test [comp_for] |
             test 'as' test |
             test '=' asexpr_test |
            '**' test |
             test 'as' test |
             test '=' asexpr_test |
            '**' test |
index 2aef589ce8d1bf78edb14a940b0072379225a43b..cb82b2d23f8a49d54a615605105100c62942ebba 100644 (file)
@@ -2,3 +2,14 @@
 x[a:=0]
 x[a:=0, b:=1]
 x[5, b:=0]
 x[a:=0]
 x[a:=0, b:=1]
 x[5, b:=0]
+
+# Walruses are allowed inside generator expressions on function calls since 3.10.
+if any(match := pattern_error.match(s) for s in buffer):
+    if match.group(2) == data_not_available:
+        # Error OK to ignore.
+        pass
+
+f(a := b + c for c in range(10))
+f((a := b + c for c in range(10)), x)
+f(y=(a := b + c for c in range(10)))
+f(x, (a := b + c for c in range(10)), y=z, **q)