Skip to content

&, |, and ^ bool stubs incorrect #1684

Closed

Description

@jhance

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.

Activity

  1. changed the title [-]`&=` operator needs special treatment when `__iand__` doesn't exist[/-] [+]`&=` broken when `__iand__` does not exist[/+] on Jun 9, 2016
  2. gvanrossum commented on Jun 9, 2016

    @gvanrossum
    Member

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

  3. jhance commented on Jun 9, 2016

    @jhance
    CollaboratorAuthor

    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 &=

  4. changed the title [-]`&=` broken when `__iand__` does not exist[/-] [+]`&=` broken for bools[/+] on Jun 9, 2016
  5. gvanrossum commented on Jun 9, 2016

    @gvanrossum
    Member

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

  6. JukkaL commented on Jun 9, 2016

    @JukkaL
    Collaborator

    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).

  7. changed the title [-]`&=` broken for bools[/-] [+]`&`, `|`, and `^` bool stubs incorrect[/+] on Jun 10, 2016
  8. gvanrossum commented on Nov 1, 2016

    @gvanrossum
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions