]> 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:

Use to handle legacy async/await handling in assert_equivalent
authorŁukasz Langa <lukasz@langa.pl>
Wed, 8 May 2019 21:33:39 +0000 (23:33 +0200)
committerŁukasz Langa <lukasz@langa.pl>
Wed, 8 May 2019 21:33:39 +0000 (23:33 +0200)
black.py

index 9494c4cf44fc20cc7b580d311e36c0bc46fa4fc2..2084e15147d6d904c0fb1c86f85aecad62ad83da 100644 (file)
--- a/black.py
+++ b/black.py
@@ -3382,10 +3382,15 @@ class Report:
 
 
 def parse_ast(src: str) -> Union[ast3.AST, ast27.AST]:
 
 
 def parse_ast(src: str) -> Union[ast3.AST, ast27.AST]:
-    try:
-        return ast3.parse(src)
-    except SyntaxError:
-        return ast27.parse(src)
+    for feature_version in (7, 6):
+        try:
+            print(f"-- 3.{feature_version}")
+            return ast3.parse(src, feature_version=feature_version)
+        except SyntaxError:
+            continue
+
+    print(f"-- 2.7")
+    return ast27.parse(src)
 
 
 def assert_equivalent(src: str, dst: str) -> None:
 
 
 def assert_equivalent(src: str, dst: str) -> None:
@@ -3438,11 +3443,9 @@ def assert_equivalent(src: str, dst: str) -> None:
     try:
         src_ast = parse_ast(src)
     except Exception as exc:
     try:
         src_ast = parse_ast(src)
     except Exception as exc:
-        major, minor = sys.version_info[:2]
         raise AssertionError(
         raise AssertionError(
-            f"cannot use --safe with this file; failed to parse source file "
-            f"with Python {major}.{minor}'s builtin AST. Re-run with --fast "
-            f"or stop using deprecated Python 2 syntax. AST error message: {exc}"
+            f"cannot use --safe with this file; failed to parse source file.  "
+            f"AST error message: {exc}"
         )
 
     try:
         )
 
     try: