Skip to content

Name ... used when possibly not defined with NoReturn branch #17814

Closed as duplicate
@charliermarsh

Description

@charliermarsh

value here is always defined because exit is NoReturn, but ty reports it as possibly not defined.

import random


if random.random() > 0.5:
    exit(0)
else:
    value = 1

print(value)

See: https://types.ruff.rs/eef5be97-af38-4588-9c25-4fd69565baa3

Metadata

Metadata

Assignees

No one assigned

    Labels

    tyMulti-file analysis & type inference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions