Skip to content

Commit 3992a9c

Browse files
committed
Complex
1 parent e2458c1 commit 3992a9c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/python_minifier/transforms/constant_folding.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ 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)):
42-
if value < 0:
41+
elif isinstance(value, (int, float, complex)):
42+
if repr(value).startswith('-'):
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)
4947
else:
5048
return node
5149

0 commit comments

Comments
 (0)