Closed as duplicate of#14978
Description
Bug Report
mypy hangs and appears to have entered an infinite loop on some function argument type hints.
To Reproduce
The following code hangs mypy version 1.15.0 on my machine:
def normal_dist_intersection(m1: float | np.ndarray, m2: float | np.ndarray, s1: float | np.ndarray, s2: float | np.ndarray):
return (m2*s1*s1 - s2 * (m1*s2 + s1*np.sqrt((m1 - m2)**2 + 2*(s1*s1 - s2*s2) * np.log(s1/s2)))) / (s1*s1 - s2*s2)
The following code works as expected. Note that the only difference is the removal of the last float
type hint.
def normal_dist_intersection(m1: float | np.ndarray, m2: float | np.ndarray, s1: float | np.ndarray, s2: np.ndarray):
return (m2*s1*s1 - s2 * (m1*s2 + s1*np.sqrt((m1 - m2)**2 + 2*(s1*s1 - s2*s2) * np.log(s1/s2)))) / (s1*s1 - s2*s2)
Your Environment
- Mypy version used: 1.15.0
- Mypy command-line flags: python -m mypy some/path/to/file/under/test.py
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.11.11