Skip to content

Use declared attribute types as type context #1375

@ibraheemdev

Description

@ibraheemdev

I believe this is the last source of type context we are missing, e.g.,

class X:
    x: list[int | str]

def _(x: X):
    x.x = [1]

See astral-sh/ruff#20796 (comment) for details.

Metadata

Metadata

Assignees

Labels

bidirectional inferenceInference of types that takes into account the context of a declared type or expected type

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions