Skip to content

Commit e2458c1

Browse files
committed
Complex
1 parent c81dbfb commit e2458c1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/python_minifier/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ def minify(
155155
module = RemoveExplicitReturnNone()(module)
156156

157157
if constant_folding:
158-
print(print_ast(module))
158+
#print(print_ast(module))
159159
module = FoldConstants()(module)
160-
print(print_ast(module))
160+
#print(print_ast(module))
161161

162162
bind_names(module)
163163
resolve_names(module)

src/python_minifier/transforms/constant_folding.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ def visit_BinOp(self, node):
3838
new_node = ast.Bytes(s=value)
3939
elif isinstance(value, bool):
4040
new_node = ast.NameConstant(value=value)
41-
elif isinstance(value, (int, float, complex)):
41+
elif isinstance(value, (int, float)):
4242
if value < 0:
4343
# Represent negative numbers as a USub UnaryOp, so that the ast roundtrip is correct
4444
new_node = ast.UnaryOp(op=ast.USub(), operand=ast.Num(n=-value))
4545
else:
4646
new_node = ast.Num(n=value)
47+
elif isinstance(value, complex):
48+
new_node = ast.Num(n=value)
4749
else:
4850
return node
4951

0 commit comments

Comments
 (0)