File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -3839,6 +3839,8 @@ def check_multi_assignment_from_tuple(
3839
3839
self .expr_checker .accept (rvalue , lvalue_type )
3840
3840
)
3841
3841
3842
+ if isinstance (reinferred_rvalue_type , TypeVarLikeType ):
3843
+ reinferred_rvalue_type = get_proper_type (reinferred_rvalue_type .upper_bound )
3842
3844
if isinstance (reinferred_rvalue_type , UnionType ):
3843
3845
# If this is an Optional type in non-strict Optional code, unwrap it.
3844
3846
relevant_items = reinferred_rvalue_type .relevant_items ()
Original file line number Diff line number Diff line change @@ -1412,3 +1412,14 @@ A(x=0).__replace__(x="asdf") # E: Argument "x" to "__replace__" of "A" has inco
1412
1412
A(x=0).__replace__(y=1) # E: Unexpected keyword argument "y" for "__replace__" of "A"
1413
1413
[builtins fixtures/tuple.pyi]
1414
1414
[typing fixtures/typing-namedtuple.pyi]
1415
+
1416
+ [case testUnpackSelfNamedTuple]
1417
+ import typing
1418
+
1419
+ class Foo(typing.NamedTuple):
1420
+ bar: int
1421
+ def baz(self: typing.Self) -> None:
1422
+ x, = self
1423
+ reveal_type(x) # N: Revealed type is "builtins.int"
1424
+ [builtins fixtures/tuple.pyi]
1425
+ [typing fixtures/typing-namedtuple.pyi]
You can’t perform that action at this time.
0 commit comments