Skip to content
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

&, |, and ^ bool stubs incorrect #1684

Closed
jhance opened this issue Jun 9, 2016 · 5 comments
Closed

&, |, and ^ bool stubs incorrect #1684

jhance opened this issue Jun 9, 2016 · 5 comments

Comments

@jhance
Copy link
Collaborator

jhance commented Jun 9, 2016

Not sure why this is, I would assume with the current code that __and__ would be used as a fallback.

a = True
a &= True

should typecheck.

@jhance jhance changed the title &= operator needs special treatment when __iand__ doesn't exist &= broken when __iand__ does not exist Jun 9, 2016
@gvanrossum
Copy link
Member

Why is '&=' special? What's different with all other binary operators?

@jhance
Copy link
Collaborator Author

jhance commented Jun 9, 2016

I just edited it after reading the code in not-11:30 mode, I agree completely now and am not sure why its broken for &=

@jhance jhance changed the title &= broken when __iand__ does not exist &= broken for bools Jun 9, 2016
@gvanrossum
Copy link
Member

Seems the problem really is that &, | and ^ on bool arguments should be defined to return bools. This can be fixed in the stubs.

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 9, 2016

Maybe the methods will have to be overloaded or use a type variable, since when calling with an int argument the result is int, whereas when called with bool the result is bool (similar to int/float).

@jhance jhance changed the title &= broken for bools &, |, and ^ bool stubs incorrect Jun 10, 2016
@gvanrossum
Copy link
Member

Closing in favor of python/typeshed#649

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants