Skip to content

Error for undefined local variables #12597

Closed
@Akuli

Description

@Akuli

Feature

Emit error if local var is undefined, example code that currently fails at runtime but passes type check:

def get_lines_to_render() -> list[str] | tuple[list[str], int]:
    return []

lines = get_lines_to_render()
if isinstance(lines, tuple):
    lines, cursor_pos = lines
else:
    cursor_pos
    cursor_pos = len(lines)

Pitch

Would be nice if I wouldn't have to run the code only to find out I had a typo. That's what type checking is all about....

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions