Skip to content

Type inference for multi-statement initialization #254

Closed
@JukkaL

Description

@JukkaL

Improve type inference by making it possible to infer the type of a variable from multiple (conditional) assignments.

This should be valid:

x = None
if c:
    x = 'a'
# type of x is str

Another example:

if c:
    x = None
else:
    x = 'a'
# type of x is str

Later on, we could extend this to precise typing of None values using union types.

Edit: restricted this issue to multiple initialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions