You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exponentiating a float with fractional power can be float or a complex, but nothing else:
In [1]: 1.0 ** 0.5
Out[1]: 1.0
In [2]: (-1.0) ** 0.5
Out[2]: (6.123233995736766e-17+1j)
But the result is currently typed as Any, but float | complex would be stricter and more self-explanatory
I don't see any technical reason for not doing so, maybe I'm missing something? But getting Any and then have mypy --strict complain about it is definitely a headscratcher.
We've tried this before, and it causes too many false positive errors unfortunately. Most people most of the time are only using ** between two positive floats, so it's very confusing for those users to find that mypy infers the result as float | complex when they know it's a float at runtime. You can see some discussion in #7682.
Exponentiating a float with fractional power can be float or a complex, but nothing else:
But the result is currently typed as
Any
, butfloat | complex
would be stricter and more self-explanatoryI don't see any technical reason for not doing so, maybe I'm missing something? But getting Any and then have
mypy --strict
complain about it is definitely a headscratcher.Related issues:
The text was updated successfully, but these errors were encountered: