Provide Module(..., type_ignores) for Python 3.8

This commit is contained in:
Kodi Arfer 2019-04-08 15:38:03 -04:00
parent 0c7ada1e63
commit 8df0a41d7d
4 changed files with 9 additions and 6 deletions

View File

@ -11,6 +11,7 @@ import sys, keyword, textwrap
PY3 = sys.version_info[0] >= 3
PY36 = sys.version_info >= (3, 6)
PY37 = sys.version_info >= (3, 7)
PY38 = sys.version_info >= (3, 8)
# The value of UCS4 indicates whether Unicode strings are stored as UCS-4.
# It is always true on Pythons >= 3.3, which use USC-4 on all systems.

View File

@ -270,8 +270,9 @@ class HyREPL(code.InteractiveConsole, object):
try:
# Mush the two AST chunks into a single module for
# conversion into Python.
new_ast = ast.Module(exec_ast.body +
[ast.Expr(eval_ast.body)])
new_ast = ast.Module(
exec_ast.body + [ast.Expr(eval_ast.body)],
type_ignores=[])
print(astor.to_source(new_ast))
except Exception:
msg = 'Exception in AST callback:\n{}\n'.format(

View File

@ -2131,7 +2131,7 @@ def hy_compile(tree, module, root=ast.Module, get_expr=False,
key=lambda a: not (isinstance(a, ast.ImportFrom) and
a.module == '__future__'))
ret = root(body=body)
ret = root(body=body, type_ignores=[])
if get_expr:
expr = ast.Expression(body=expr)

View File

@ -11,7 +11,7 @@
pytest)
(import sys)
(import [hy._compat [PY3 PY37]])
(import [hy._compat [PY3 PY37 PY38]])
(defn test-sys-argv []
"NATIVE: test sys.argv"
@ -1550,10 +1550,11 @@ cee\"} dee" "ey bee\ncee dee"))
(defn test-disassemble []
"NATIVE: Test the disassemble function"
(assert (= (disassemble '(do (leaky) (leaky) (macros))) (cond
[PY3 "Module(
[PY3 (.format "Module(
body=[Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[])),
Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[])),
Expr(value=Call(func=Name(id='macros'), args=[], keywords=[]))])"]
Expr(value=Call(func=Name(id='macros'), args=[], keywords=[]))]{})"
(if PY38 ",\n type_ignores=[]" ""))]
[True "Module(
body=[
Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[], starargs=None, kwargs=None)),