File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,15 @@ impl SourceOrderVisitor<'_> for InlayHintVisitor<'_, '_> {
264264 }
265265 source_order:: walk_expr ( self , expr) ;
266266 }
267+ Expr :: Attribute ( attribute) => {
268+ if self . in_assignment {
269+ if attribute. ctx . is_store ( ) {
270+ let ty = expr. inferred_type ( & self . model ) ;
271+ self . add_type_hint ( expr. range ( ) . end ( ) , ty) ;
272+ }
273+ }
274+ source_order:: walk_expr ( self , expr) ;
275+ }
267276 Expr :: Call ( call) => {
268277 let argument_names =
269278 inlay_hint_function_argument_details ( self . db , & self . model , call)
@@ -436,6 +445,31 @@ mod tests {
436445 " ) ;
437446 }
438447
448+ #[ test]
449+ fn test_assign_attribute_of_instance ( ) {
450+ let test = inlay_hint_test (
451+ "
452+ class A:
453+ def __init__(self, y):
454+ self.x = 1
455+ self.y = y
456+
457+ a = A(2)
458+ a.y = 3
459+ " ,
460+ ) ;
461+
462+ assert_snapshot ! ( test. inlay_hints( ) , @r"
463+ class A:
464+ def __init__(self, y):
465+ self.x[: Literal[1]] = 1
466+ self.y[: Unknown] = y
467+
468+ a[: A] = A([y=]2)
469+ a.y[: Literal[3]] = 3
470+ " ) ;
471+ }
472+
439473 #[ test]
440474 fn test_disabled_variable_types ( ) {
441475 let test = inlay_hint_test ( "x = 1" ) ;
You can’t perform that action at this time.
0 commit comments