Repository navigation
[multiprocessing] ShareableList is iterable but has no __iter__ - #16844
Conversation
|
Anyway, I am sorry for the amount of PRs lately but this is what I stumble upon while refactoring a legacy project :) |
|
Type checkers should implement special handling for this. Do you have a concrete type checker/code combo where this fails? |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Special handling in the checkers could perhaps cover Nevertheless, I face the problem when computing stats over sensor readings kept in shared memory: readings = ShareableList([0.5, 0.7, 0.6])
mean = statistics.fmean(readings)(based)pyright / mypy report: It works on runtime, but can't satisfy anything that takes an |
srittau
left a comment
There was a problem hiding this comment.
It seems we already do this in a few other cases.
Yes, at least in |
ShareableListis iterable at runtime (via__getitem__). However, the stub has no__iter__, so type checkers reject it as not iterable and it fails theIterableprotocol.