Skip to content

Incorrect errors caused by boolean narrowing on attributes #11853

Open
@Dreamsorcerer

Description

@Dreamsorcerer

With mypy 0.930 (compared with 0.910), it now infers the type of self._changed = False as Literal[False] instead of bool. That doesn't bother me too much, but if I add a type annotation as self._changed: bool = False, it still marks the type as Literal[False] and we get type errors in the code about unreachable code.

Code available at: https://github.com/aio-libs/aiohttp-session/pull/651/files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-narrowingConditional type narrowing / binder

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions