Skip to content

Regression with type narrowing of bool #11839

Description

@cdce8p

Regression in 0.920 / 0.930 compared with 0.910.

fromtypingimportAnydeffunc() ->Any:
...
var=func()
reveal_type(var) # Anyassertisinstance(var, bool)
reveal_type(var) # boolifvar:
reveal_type(var) # Literal[True]passreveal_type(var) # Any -> should still be 'bool'!

The type should not be lost if it can't be narrowed to Literal[True] or Literal[False]. It's a side effect of #10389. The issue was already mentioned #10389 (comment) but hasn't been addressed yet.

/CC: @ethan-leba

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions