You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason ctypes.Structure instances pass mypy's isinstance checks although mypy also claims that they are not iterable.
For example, consider the following code:
I don't think a Structure is meant to be iterable, looks like it is not:
$ cat test.py
from ctypes import Structure
class S(Structure):
pass
s = S()
iter(s)
$ python test.py
Traceback (most recent call last):
File "/home/mdk/clones/JulienPalard/oeis/test.py", line 9, in <module>
iter(s)
TypeError: 'S' object is not iterable
So I think the bug is more than adding iter mutes the error, while it should not?
Presumably mypy conceptually looks at the instance for the isinstance() check, so the __getattr__ allows it to think there's an __iter__ method, but when checking for _ in s: it (correctly) looks at the class, which doesn't have an __iter__ method.
Bug Report
For some reason
ctypes.Structure
instances pass mypy'sisinstance
checks although mypy also claims that they are not iterable.For example, consider the following code:
mypy gives the following error:
replacing it with
iter(s)
make mypy happy again.Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: