Skip to content

Commit

Permalink
use type_comments with ast.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Apr 29, 2021
1 parent b39999d commit e4b038f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/black/__init__.py
Expand Up @@ -6416,7 +6416,12 @@ def parse_ast(src: str) -> Union[ast.AST, ast3.AST, ast27.AST]:
# TODO: support Python 4+ ;)
for minor_version in range(sys.version_info[1], 4, -1):
try:
return ast.parse(src, filename, feature_version=(3, minor_version))
return ast.parse(
src,
filename,
feature_version=(3, minor_version),
type_comments=True,
)
except SyntaxError:
continue
else:
Expand Down

0 comments on commit e4b038f

Please sign in to comment.