Skip to content

Type is int in boolean logic with sys.flags #12099

@Dreamsorcerer

Description

@Dreamsorcerer
a: bool
b: int
reveal_type(a or not b)  # Revealed type is "builtins.bool"
reveal_type(sys.flags.dev_mode or not sys.flags.ignore_environment)  # Revealed type is "builtins.int"

I can find no reason why this should be interpreted as int. dev_mode is bool and ignore_environment is int. The not will convert the int to a bool, as correctly inferred in the first example.

Code from here: https://github.com/aio-libs/aiohttp/pull/6549/files#diff-b797dd8733928df191ba2061121ab8b69976c185fcbfad4534891d3252b9ac30R84

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions