Skip to content

(🐞) always-true/always-false doesn't activate until it's truth is checked #12325

Description

@KotlinIsland

test.py:

fromtypingimportLiteraldeffoo(a: Literal[True]) ->None:
...
FOO: boolfoo(FOO) # error: Argument 1 to "foo" has incompatible type "bool"; expected "Literal[True]" [arg-type]reveal_type(FOO) # note: Revealed type is "builtins.bool"ifnotFOO:
passreveal_type(FOO) # note: Revealed type is "Literal[True]"ifnotFOO:
passimporttest2

test2.py:

fromtestimportFOOreveal_type(FOO) # note: Revealed type is "builtins.bool"ifFOO:
passreveal_type(FOO) # note: Revealed type is "Literal[True]"

> mypy --always-true FOO test.py

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