mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Mypy crashes when using `reveal_type` on large literal int

Open erictraut opened this issue 1 year ago • 2 comments

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.

erictraut avatar Jul 15 '24 18:07 erictraut

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

devdanzin avatar Jul 17 '24 18:07 devdanzin

Related: #17008

brianschubert avatar Oct 06 '24 19:10 brianschubert