Skip to content

Commit 680f9bd

Browse files
authored
Fix crash in multiple assignment when "__iter__" returns Any (python#7462)
Fixes a regression introduced in commit f9396ef.
1 parent 6338078 commit 680f9bd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mypy/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4075,7 +4075,7 @@ def iterable_item_type(self, instance: Instance) -> Type:
40754075
if isinstance(ret_type, Instance):
40764076
iterator = map_instance_to_supertype(ret_type,
40774077
self.lookup_typeinfo('typing.Iterator'))
4078-
item_type = iterator.args[0]
4078+
item_type = iterator.args[0]
40794079
return item_type
40804080

40814081
def function_type(self, func: FuncBase) -> FunctionLike:

test-data/unit/check-generics.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,3 +2053,12 @@ class C(Generic[T]):
20532053
def func(x: S) -> S:
20542054
return C[S].get()
20552055
[builtins fixtures/classmethod.pyi]
2056+
2057+
[case testMultipleAssignmentFromAnyIterable]
2058+
from typing import Any
2059+
class A:
2060+
def __iter__(self) -> Any: ...
2061+
2062+
x, y = A()
2063+
reveal_type(x) # N: Revealed type is 'Any'
2064+
reveal_type(y) # N: Revealed type is 'Any'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy