Skip to content

Commit

Permalink
[test/py3_parse] Ask for type_comments when available
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy C committed Nov 13, 2021
1 parent c1f2747 commit ccc289b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/py3_parse.py
Expand Up @@ -11,9 +11,17 @@
def main(argv):
for filename in argv[1:]:
with open(filename) as f:
# TODO: we need Python 3.8 or 3.10 because they support type_comments=True
contents = f.read()
try:
n = ast.parse(f.read())

try:
# Python 3.8+ supports type_comments=True
# TODO: make a custom build of Python 3.10
n = ast.parse(contents, type_comments=True)
except TypeError:
# Fallback
n = ast.parse(contents)

except SyntaxError as e:
print('Error parsing %s: %s' % (filename, e))
return 1
Expand Down

0 comments on commit ccc289b

Please sign in to comment.