Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions stdlib/asyncio/locks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ from typing_extensions import Literal, Self
from .events import AbstractEventLoop
from .futures import Future

if sys.version_info >= (3, 11):
if sys.version_info >= (3, 10):
from .mixins import _LoopBoundMixin
else:
_LoopBoundMixin = object

if sys.version_info >= (3, 11):
__all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore", "Barrier")
Expand Down Expand Up @@ -44,7 +46,7 @@ else:
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> None: ...

class Lock(_ContextManagerMixin):
class Lock(_ContextManagerMixin, _LoopBoundMixin):
if sys.version_info >= (3, 10):
def __init__(self) -> None: ...
else:
Expand All @@ -54,7 +56,7 @@ class Lock(_ContextManagerMixin):
async def acquire(self) -> Literal[True]: ...
def release(self) -> None: ...

class Event:
class Event(_LoopBoundMixin):
if sys.version_info >= (3, 10):
def __init__(self) -> None: ...
else:
Expand All @@ -65,7 +67,7 @@ class Event:
def clear(self) -> None: ...
async def wait(self) -> Literal[True]: ...

class Condition(_ContextManagerMixin):
class Condition(_ContextManagerMixin, _LoopBoundMixin):
if sys.version_info >= (3, 10):
def __init__(self, lock: Lock | None = None) -> None: ...
else:
Expand All @@ -79,7 +81,7 @@ class Condition(_ContextManagerMixin):
def notify(self, n: int = 1) -> None: ...
def notify_all(self) -> None: ...

class Semaphore(_ContextManagerMixin):
class Semaphore(_ContextManagerMixin, _LoopBoundMixin):
_value: int
_waiters: deque[Future[Any]]
if sys.version_info >= (3, 10):
Expand Down
9 changes: 8 additions & 1 deletion stdlib/asyncio/queues.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias

if sys.version_info >= (3, 10):
from .mixins import _LoopBoundMixin
else:
_LoopBoundMixin = object

__all__ = ("Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty")

class QueueEmpty(Exception): ...
class QueueFull(Exception): ...

_T = TypeVar("_T")

class Queue(Generic[_T]):
# If Generic[_T] is last and _LoopBoundMixin is object, pyright is unhappy.
# We can remove the noqa pragma when dropping 3.9 support.
class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059
if sys.version_info >= (3, 10):
def __init__(self, maxsize: int = 0) -> None: ...
else:
Expand Down