Skip to content

fix handling of bool and abs values #924

@maggiemoss

Description

@maggiemoss

Describe the Bug


from typing import *


def foo(expected: Union[bool, int, float, complex]):
    return abs(expected) # this is an error
    

foo(False) # outputs 0 in abs

abs(False) # is fine - only when bool is part of a union

Sandbox Link

https://pyrefly.org/sandbox/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoBUAUCQCYCmwUwYYAFOQB4LkDGM5pAXFAKopIwKANoAjWgBsANJhQwZwCWACG8qK0gIJTALoBKLkSjGoIcjACuIFFGWiAzg2ZsOpPVADEsABZJ7mf2UbchBwECMTEhp6ADFlCXtydy8wCxgENP8ABllbBxI7RziEpM8A6lRyKABaKCEJOCgAd29yG3EwCXKEZTw6qmUoCwEhIA&version=3.12

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions