Skip to content

False positive: unreachable #10806

Open
Open
@KotlinIsland

Description

@KotlinIsland

Bug Report

false positive unreachable

To Reproduce

a: object = None

def foo() -> None:
    global a
    a = None
    bar()
    if a:
        print("hi")

def bar() -> None:
    global a
    a = 1

Expected Behavior

no error

Actual Behavior

main.py:8: error: Statement is unreachable
Found 1 error in 1 file (checked 1 source file)

(Write what happened.)

Your Environment
https://mypy-play.net/?mypy=latest&python=3.10&flags=warn-unreachable&gist=c41cd432e95c591743aa1369f36823d1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct codetopic-reachabilityDetecting unreachable code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions