mypy
mypy copied to clipboard
Mypy crashes when using `reveal_type` on large literal int
I noticed this issue when exploring a feature request in pyright.
The following code results in an "INTERNAL ERROR" when running mypy.
from typing import Final
MY_CONST: Final = 2**100000
reveal_type(MY_CONST)
This is admittedly an edge case, perhaps not worth fixing.
One option would be to detect the error ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit and use hex(self.value) instead of repr(self.value) for that case in https://github.com/python/mypy/blob/6a0657e5959ba1777c4d427f8f355d499035d145/mypy/types.py#L2793-L2800
Related: #17008