We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 307949a commit ceedd28Copy full SHA for ceedd28
mypy/fastparse.py
@@ -1218,8 +1218,13 @@ def visit_UnaryOp(self, n: UnaryOp) -> Type:
1218
1219
# Num(number n)
1220
def visit_Num(self, n: Num) -> Type:
1221
- if isinstance(n.n, int):
1222
- numeric_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
1223
+ # to think that the complex branch is always picked. Avoid
1224
+ # this by throwing away the type.
1225
+ value = n.n # type: object
1226
+ if isinstance(value, int):
1227
+ numeric_value = value # type: Optional[int]
1228
type_name = 'builtins.int'
1229
else:
1230
# Other kinds of numbers (floats, complex) are not valid parameters for
0 commit comments