New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It seems that the operator ':=' in python3.8 is not supported #894
Comments
YAPF uses lib2to3, which is shipped with Python. If that doesn't support something, then we can't. :-( |
since the Change was merged on 2020-12-14 17:10:37, YAPF should work in the next version (Python). |
@HungChien r u using Py3.8.7? if not, as |
There are a number of updates to lib2to3, depending on which version of Python you're using. This broke some of my code ... I've solved the versioning problem by taking a snapshot of lib2to3.pygram.Grammar.txt and checking its sha1 chksum: # Verify that the Grammar.txt file matches what we expect.
# The check is generated by this command: sha1sum pygram/Grammar.txt
# (which is copied from /usr/lib/python3.7/lib2to3/Grammar.txt)
with open(pygram._GRAMMAR_FILE, 'rb') as grammar_file:
if (hashlib.sha1(grammar_file.read()).hexdigest() !=
'2713b32f014ddd6268ed4396ee95f960123e6e7d'):
raise RuntimeError(
'lib2to3 grammar file (%s) is an unexpected version' % pygram._GRAMMAR_FILE) |
This does not reproduce as far back as at least 0.30.0. (tested on python 3.10) and I think this issue may be closed. > yapf --diff .\yapf#894.py
--- .\yapf#894.py (original)
+++ .\yapf#894.py (reformatted)
@@ -1,4 +1,5 @@
import os
-a=[1,2,3,4]
-if (n:=len(a))>2:
+
+a = [1, 2, 3, 4]
+if (n := len(a)) > 2:
print() |
For example, a file named as test.py is as follow:
when you use
yapf test.py
to format it, error occurs:When will yapf support ':=' operator?
The text was updated successfully, but these errors were encountered: