Use mkexpr in HyASTCompiler.imports_as_stmts

This commit is contained in:
Kodi Arfer 2019-07-08 15:40:45 -04:00
parent 349da353d6
commit 3afb4fdabe

View File

@ -402,21 +402,11 @@ class HyASTCompiler(object):
ret = Result()
for module, names in self.imports.items():
if None in names:
e = HyExpression([
HySymbol("import"),
HySymbol(module),
]).replace(expr)
ret += self.compile(e)
ret += self.compile(mkexpr('import', module).replace(expr))
names = sorted(name for name in names if name)
if names:
e = HyExpression([
HySymbol("import"),
HyList([
HySymbol(module),
HyList([HySymbol(name) for name in names])
])
]).replace(expr)
ret += self.compile(e)
ret += self.compile(mkexpr('import',
mklist(module, mklist(*names))))
self.imports = defaultdict(set)
return ret.stmts