-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Add missing multiprocessing/resource-tracker type hints #8405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add missing multiprocessing/resource-tracker type hints #8405
Conversation
This comment has been minimized.
This comment has been minimized.
It sounds like this is Python 3.8+ only from this error:
Before making changes though, would someone be able to confirm the correct way to address this? I want to avoid unnecessary emails and whatnot as I try to work it out myself |
You may need to add it to the VERSIONS file if it's new in 3.8. |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Fixed via c74e59c, thank you for the feedback! |
This comment has been minimized.
This comment has been minimized.
def register(self, name: Sized, rtype: object) -> None: ... | ||
def unregister(self, name: Sized, rtype: object) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true that these methods can be passed literally any object without raising an exception, so your instinct here to annotate these parameters with object
was good. However, I feel like it's unlikely that you're actually meant to be passing literally any object to these methods. I think it's more likely that you're meant to be passing some kind of "resource" to these methods (the "shared memory segments, semaphores, etc." referenced in the block comment at the top of the module). I don't know enough about multiprocessing
to know what the true type is, so I'd rather we went for _typeshed.Incomplete
for now, which serves as an explicit marker of "we're not quite sure what this type should be".
def register(self, name: Sized, rtype: object) -> None: ... | |
def unregister(self, name: Sized, rtype: object) -> None: ... | |
def register(self, name: Sized, rtype: Incomplete) -> None: ... | |
def unregister(self, name: Sized, rtype: Incomplete) -> None: ... |
(You'll have to import Incomplete
from _typeshed
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, updated :) thanks for explaining that 👍
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
X-Ref: #6799
This adds best-effort types to
multiprocessing.resource_tracker
to begin to address issue #6799The source file can be viewed here:
https://github.com/python/cpython/blob/main/Lib/multiprocessing/resource_tracker.py