Description
I am using Python 3.6.4. I have a file with these 2 lines:
from decimal import Decimal
1 + {'a': 1, 'b': Decimal('1.5')}['a']
If I run it through mypy, I get this error:
supports_int_test.py:2: error: Unsupported operand types for + ("int" and "object")
This is strange. I would think that mypy should be able to figure out that regardless of which value is picked from the dictionary, it should be something that can be added to 1. The expression 1 + {'b': Decimal('1.5')}['b']
does not produce any errors.
If I use an int for the 'b'
value (making all of the values ints), I don't get any errors. If I use a float for the 'b'
value, I also don't get any errors. But if I use a Fraction, I get a similar error.
The expression 1 + {'b': Decimal('1.5')}['c']
(which deliberately tries to access a nonexistent key) doesn't give me any errors but 1 + {'a': 1, 'b': Decimal('1.5')}['c']
gives me a similar error.
This is happening with both mypy 0.560 and with the latest version from master (mypy 0.570-dev-26b51e554d7426a0aed6ad55bae7b10a4619c093).