KEMBAR78
False positive with --warn-unreachable: TypedDict may be empty · Issue #7743 · python/mypy · GitHub
Skip to content

False positive with --warn-unreachable: TypedDict may be empty #7743

@ilai-deutel

Description

@ilai-deutel

Hi,

I believe there is a false positive related to empty TypedDicts with total=False.

Using --warn-unreachable:

from typing_extensions import TypedDict

class A(TypedDict, total=False):
    ...

class B(TypedDict, total=False):
    x: int

a: A = {}
b: B = {}

if not a:
    print('a is empty')

if not b:
    print('b is empty')  # error: Statement is unreachable

Using Python 3.7.4, tested with both mypy 0.740 and mypy master.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions