Skip to content

Diagnostic range for invalid-assignment should only cover the right-hand side #1556

@lucach

Description

@lucach

Summary

When an assignment has a type annotation, the blame for an invalid assignment should fall on the RHS expression, instead of the assignee. The current diagnostic message is already great ("Object of type <rhs_type> is not assignable to <annotated_type>") but its position is suboptimal.

Compare ty on the Playground:

Image

with Pylance in VSCode:

Image

(The last statement is there to show that not all invalid-assignment diagnostics should automatically placed on the RHS. For those, the current behavior is already correct.)

Version

5f501374c

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdiagnosticsRelated to reporting of diagnostics.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions