Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,11 @@ def visit_Call(self, n: Call) -> CallExpr:

# Num(object n) -- a number as a PyObject.
def visit_Num(self, n: ast3.Num) -> Union[IntExpr, FloatExpr, ComplexExpr]:
val = n.n
# The n field has the type complex, but complex isn't *really*
# a parent of int and float, and this causes isinstance below
# to think that the complex branch is always picked. Avoid
# this by throwing away the type.
val = n.n # type: object
if isinstance(val, int):
e = IntExpr(val) # type: Union[IntExpr, FloatExpr, ComplexExpr]
elif isinstance(val, float):
Expand Down
6 changes: 5 additions & 1 deletion mypy/fastparse2.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,11 @@ def visit_Call(self, n: Call) -> CallExpr:

# Num(object n) -- a number as a PyObject.
def visit_Num(self, n: ast27.Num) -> Expression:
value = n.n
# The n field has the type complex, but complex isn't *really*
# a parent of int and float, and this causes isinstance below
# to think that the complex branch is always picked. Avoid
# this by throwing away the type.
value = n.n # type: object
is_inverse = False
if str(n.n).startswith('-'): # Hackish because of complex.
value = -n.n
Expand Down