-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
builtins.pyi: Return complex from __(r)pow__() #2662
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
Conversation
ff94bf6
to
7ac2fec
Compare
stdlib/3/builtins.pyi
Outdated
@@ -196,15 +196,15 @@ class float: | |||
def __truediv__(self, x: float) -> float: ... | |||
def __mod__(self, x: float) -> float: ... | |||
def __divmod__(self, x: float) -> Tuple[float, float]: ... | |||
def __pow__(self, x: float) -> float: ... | |||
def __pow__(self, x: float) -> complex: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have an overload for when x
is an int
, since it will never be complex in that case. See #2444 for an example. Apart from that this PR looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. On it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the CI failing now, @srittau? 😅
Would it be complex
, instead of float
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fails in mypy's test suite. It's likely the test suite needs to be adopted. I will have a closer look tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure.
Didn't quite get it.
This is necessary due to python/typeshed#2662, where float.__pow__() now returns complex in the general case.
I started a discussion about the build failure in #1406. |
This add a comment to the __pow__() function. Fixes python#1406
Done as asked. |
Thank you for your persistence! |
This returns
complex
, instead offloat
.Fixes #1406