Skip to content

Commit 486a51b

Browse files
authored
Fix misleading TODO comment in testIterableUnpackingWithGetAttr (#14894)
Follow-up to #14893 See #14892 for more discussion
1 parent 895a821 commit 486a51b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test-data/unit/check-classes.test

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7810,6 +7810,12 @@ class D:
78107810
return C()
78117811

78127812
def g(self) -> None:
7813-
# TODO: This is a false positive
7813+
# iter(x) looks up `__iter__` on the type of x rather than x itself,
7814+
# so this is correct behaviour.
7815+
# Instances of C should not be treated as being iterable,
7816+
# despite having a __getattr__ method
7817+
# that could allow for arbitrary attributes to be accessed on instances,
7818+
# since `type(C()).__iter__` still raises AttributeError at runtime,
7819+
# and that's what matters.
78147820
a, b = self.f() # E: "C" has no attribute "__iter__" (not iterable)
78157821
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)