[multiprocessing] fixes some stubtest cases for Value and Array#4282
[multiprocessing] fixes some stubtest cases for Value and Array#4282hauntsaninja merged 6 commits intopython:masterfrom
Conversation
|
Second note is that |
|
Ooo, there are some easy fixes in that issue, but this is a tricky one. There are several improvements to be made to the stubs here, that are separate from stubtest's actual (but minor to the end user) complaint. I can explain a little more (and forgive me if I over-explain): So the core issue is that these class-looking things in multiprocessing are actually functions returning ctypes objects.
Why does stubtest complain here? stubtest sees that the stubs define a class, and so tries to confirm that the runtime object is an instance of What should we do? I would do the following:
This isn't all or nothing either, even just making a Also this turned out to be a hefty wall of text, I hope it makes sense!! |
|
Thanks for the detailed feedback, @hauntsaninja. I've added what I think is the right way to approach this.
One thing I'm not sure about - it seems like |
|
Ah I derped on 3, the context is from the sharedctypes method and not the |
|
This looks great! It's too bad pytype doesn't seem to understand the bound method :-( (pytype is often less sophisticated than mypy). I guess we can just duplicate the definition from |
|
Heh, I just came across typeshed/stdlib/2and3/turtle.pyi Lines 284 to 291 in ac234f2 |
hauntsaninja
left a comment
There was a problem hiding this comment.
Nice find, hopefully this gets everything green!
|
Sweet! Thanks for the help |
I wanted to get my toes a little more wet into stubtests so I tried to take a stab at #4266. I believe this fixes two test cases:
I'm still not sure I understand why this works. The only reason I arrived at this solution is by following the pattern for line 44 defined in the same file which uses a function for
Semaphoredespite it also being a class according to the docs. Does this have to do with mp having a dynamic nature? Is this the correct solution?Test Plan: