Repository navigation
Fix use of unexported Pool type in multiprocessing.pool - #6111
Conversation
hauntsaninja
left a comment
There was a problem hiding this comment.
Thanks! I vaguely prefer import multiprocessing.pool as the solution, since it's one less lookup for anyone wondering what _Pool is.
|
It could be |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
|
Yes, understood, I meant literally Anyway was just a nit, thanks for fixing this :-) |
|
Ah, I see. I can do that. |
|
Hm, doing so doesn't make |
|
At runtime, if any module anywhere in the program imports anything from I had the same problem with tkinter stubs: because |
|
FWIW pyright/pylance make no attempt to simulate these sorts of side effects; our old language server sort of did (to work around libraries which had been poorly structured or not explicit), and from the above mypy must too. Originally, I was pretty pro-side effect simulation, but having had the exact opposite for well over a year now, I think it's worth avoiding the complexity (and preserving the stub authorship power of explicit exports). It'd be nice to get everything consistent on this front, though. |
|
I appreciate pyright's behavior here. At work we had a few issues recently where a module was imported as a side effect by some unrelated module, and then when we removed that import, tests elsewhere in the codebase started failing because they relied on the import elsewhere. |
For #6110.
poolisn't exported frommultiprocessing. ImportPoolfrommultiprocessing.pooldirectly rather than relying on the side effect of it being loaded bymultiprocessingat some point.