11import sys
2+ import types
23from collections import deque
34from collections .abc import Iterable
45
56# technically it is using _PySimpleQueue, which has the same interface as SimpleQueue
6- from queue import Empty as Empty , Full as Full , SimpleQueue as SimpleQueue
7+ from queue import Empty as Empty , Full as Full
78from typing import Any , Generic , Literal , TypeVar , final , overload
89from typing_extensions import Self
910
@@ -19,13 +20,16 @@ else:
1920
2021_T = TypeVar ("_T" )
2122
22- class Queue (Generic [_T ]):
23+ class SimpleQueue (Generic [_T ]):
2324 @property
2425 def hub (self ) -> Hub : ... # readonly in Cython
2526 @property
2627 def queue (self ) -> deque [_T ]: ... # readonly in Cython
2728 maxsize : int | None
2829 is_shutdown : bool
30+
31+ @classmethod
32+ def __class_getitem__ (cls , item : Any , / ) -> types .GenericAlias : ...
2933 @overload
3034 def __init__ (self , maxsize : int | None = None ) -> None : ...
3135 @overload
@@ -42,13 +46,27 @@ class Queue(Generic[_T]):
4246 def put (self , item : _T , block : bool = True , timeout : float | None = None ) -> None : ...
4347 def put_nowait (self , item : _T ) -> None : ...
4448 def qsize (self ) -> int : ...
45- def shutdown (self , immediate : bool = False ) -> None : ...
4649 def __bool__ (self ) -> bool : ...
4750 def __iter__ (self ) -> Self : ...
4851 def __len__ (self ) -> int : ...
4952 def __next__ (self ) -> _T : ...
5053 next = __next__
5154
55+ class Queue (SimpleQueue [_T ]):
56+ @property
57+ def unfinished_tasks (self ) -> int : ... # readonly in Cython
58+ @overload
59+ def __init__ (self , maxsize : int | None = None , * , unfinished_tasks : int | None = None ) -> None : ...
60+ @overload
61+ def __init__ (self , maxsize : int | None , items : Iterable [_T ], unfinished_tasks : int | None = None ) -> None : ...
62+ @overload
63+ def __init__ (self , maxsize : int | None = None , * , items : Iterable [_T ], unfinished_tasks : int | None = None ) -> None : ...
64+ def join (self , timeout : float | None = None ) -> bool : ...
65+ def task_done (self ) -> None : ...
66+ def shutdown (self , immediate : bool = False ) -> None : ...
67+
68+ JoinableQueue = Queue
69+
5270@final
5371class UnboundQueue (Queue [_T ]):
5472 @overload
@@ -61,18 +79,6 @@ class UnboundQueue(Queue[_T]):
6179class PriorityQueue (Queue [_T ]): ...
6280class LifoQueue (Queue [_T ]): ...
6381
64- class JoinableQueue (Queue [_T ]):
65- @property
66- def unfinished_tasks (self ) -> int : ... # readonly in Cython
67- @overload
68- def __init__ (self , maxsize : int | None = None , * , unfinished_tasks : int | None = None ) -> None : ...
69- @overload
70- def __init__ (self , maxsize : int | None , items : Iterable [_T ], unfinished_tasks : int | None = None ) -> None : ...
71- @overload
72- def __init__ (self , maxsize : int | None = None , * , items : Iterable [_T ], unfinished_tasks : int | None = None ) -> None : ...
73- def join (self , timeout : float | None = None ) -> bool : ...
74- def task_done (self ) -> None : ...
75-
7682class Channel (Generic [_T ]):
7783 @property
7884 def getters (self ) -> deque [Waiter [Any ]]: ... # readonly in Cython
@@ -81,6 +87,8 @@ class Channel(Generic[_T]):
8187 @property
8288 def hub (self ) -> Hub : ... # readonly in Cython
8389 def __init__ (self , maxsize : Literal [1 ] = 1 ) -> None : ...
90+ @classmethod
91+ def __class_getitem__ (cls , item : Any , / ) -> types .GenericAlias : ...
8492 @property
8593 def balance (self ) -> int : ...
8694 def qsize (self ) -> Literal [0 ]: ...
0 commit comments