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
add SyncQueue and AsyncQueue Protocols #374
add SyncQueue and AsyncQueue Protocols #374
Conversation
|
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.
The proposed solution is a little verbose but technically should work perfectly fine.
Please apply a note about typing_extensions
before the PR merging.
janus/__init__.py
Outdated
@@ -7,7 +7,7 @@ | |||
from heapq import heappop, heappush | |||
from queue import Empty as SyncQueueEmpty | |||
from queue import Full as SyncQueueFull | |||
from typing import Any, Callable, Deque, Generic, List, Optional, Set, TypeVar | |||
from typing import Any, Callable, Deque, Generic, List, Optional, Protocol, Set, TypeVar |
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.
Please import Protocol
from typing_extensions
module; add typing-extensions>=3.7.4.3
here
610d860
to
03856ab
Compare
03856ab
to
3360844
Compare
Thanks! |
0.7.0 released |
What do these changes do?
Add protocols to avoid the use of private classes _SyncQueueProxy and _AsyncQueueProxy when adding type hints.
Are there changes in behavior for the user?
I assume that not. But it would be good if somebody more experienced could check this.
Related issue number
See #372
This PR is not intended to be directly merged, but to open a discussion about this approach.
Using this approach, the following seems to work for adding type hints:
Full disclaimer: I never used Protocols before. I skimmed https://www.python.org/dev/peps/pep-0544 and watched https://www.youtube.com/watch?v=kDDCKwP7QgQ
Also, I only recently started using typing with Python.
While this approach seems to work, it looks rather verbose.