◐ Shell
clean mode source ↗

bpo-35224: Add support for NamedExpr to unparse.py by vstinner · Pull Request #11670 · python/cpython

Oh, my first attempt without parenthesis failed: "(x := 1)" became "x := 1" which raises a SyntaxError. I modified my PR to always add parenthesis.

I will push this change to repair buildbots. If someone finds a smarter solution to omit parenthesis in some cases, please go ahead. I never used unparse.py. I don't think that it should nor that it can produce exactly the same input file, since Python looses many formatting information with code is compiled to bytecode (or even just when compiled to AST).