-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
False negative when using the power (**) operator #7765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is an issue with typeshed due to a limitation in the type system. We would need a range type to be able to express this. |
Wouldn't |
Also, a related problem is that def foo(x: int) -> float:
return 2 ** x fails with |
We try to avoid that sort of union return in typeshed stubs because they produce a pretty bad user experience. |
Yeah, probably. |
For some reason (python/mypy#7765) `**` has a return type of `Any` so just use `math.pow()` instead.
For some reason (python/mypy#7765) `**` has a return type of `Any` so just use `math.pow()` instead.
When checking the following function with mypy 0.730 (Python version 3.7.4):
mypy reports no errors:
With the
--strict
option turned on, mypy reports:The expected output would be something like
The text was updated successfully, but these errors were encountered: