Skip to content

Commit e56c383

Browse files
luk3yxdflook
authored andcommitted
Make relative imports more compact
1 parent 2a479ee commit e56c383

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/python_minifier/module_printer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ def visit_Import(self, node):
268268
def visit_ImportFrom(self, node):
269269
assert isinstance(node, ast.ImportFrom)
270270

271-
if node.module is None:
272-
self.code += 'from ' + ('.' * node.level) + ' '
273-
else:
274-
self.code += 'from ' + ('.' * node.level)
275-
self.code += node.module
271+
self.code += 'from' + ('.' * node.level)
272+
if node.module is not None:
273+
if node.level == 0:
274+
self.code += ' '
275+
self.code += node.module + ' '
276276

277-
self.code += ' import '
277+
self.code += 'import '
278278
first = True
279279
for n in node.names:
280280
if first:

0 commit comments

Comments
 (0)