Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a098a8

Browse files
authored
Various asyncio classes: remove the loop argument on 3.10 (#9630)
1 parent 94065d3 commit 8a098a8

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

stdlib/asyncio/locks.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,31 @@ else:
4545
) -> None: ...
4646

4747
class Lock(_ContextManagerMixin):
48-
if sys.version_info >= (3, 11):
48+
if sys.version_info >= (3, 10):
4949
def __init__(self) -> None: ...
5050
else:
51-
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
51+
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...
5252

5353
def locked(self) -> bool: ...
5454
async def acquire(self) -> Literal[True]: ...
5555
def release(self) -> None: ...
5656

5757
class Event:
58-
if sys.version_info >= (3, 11):
58+
if sys.version_info >= (3, 10):
5959
def __init__(self) -> None: ...
6060
else:
61-
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
61+
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...
6262

6363
def is_set(self) -> bool: ...
6464
def set(self) -> None: ...
6565
def clear(self) -> None: ...
6666
async def wait(self) -> Literal[True]: ...
6767

6868
class Condition(_ContextManagerMixin):
69-
if sys.version_info >= (3, 11):
69+
if sys.version_info >= (3, 10):
7070
def __init__(self, lock: Lock | None = None) -> None: ...
7171
else:
72-
def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = ...) -> None: ...
72+
def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = None) -> None: ...
7373

7474
def locked(self) -> bool: ...
7575
async def acquire(self) -> Literal[True]: ...
@@ -82,10 +82,10 @@ class Condition(_ContextManagerMixin):
8282
class Semaphore(_ContextManagerMixin):
8383
_value: int
8484
_waiters: deque[Future[Any]]
85-
if sys.version_info >= (3, 11):
85+
if sys.version_info >= (3, 10):
8686
def __init__(self, value: int = 1) -> None: ...
8787
else:
88-
def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = ...) -> None: ...
88+
def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = None) -> None: ...
8989

9090
def locked(self) -> bool: ...
9191
async def acquire(self) -> Literal[True]: ...

stdlib/asyncio/queues.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class QueueFull(Exception): ...
1313
_T = TypeVar("_T")
1414

1515
class Queue(Generic[_T]):
16-
if sys.version_info >= (3, 11):
16+
if sys.version_info >= (3, 10):
1717
def __init__(self, maxsize: int = 0) -> None: ...
1818
else:
19-
def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = ...) -> None: ...
19+
def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = None) -> None: ...
2020

2121
def _init(self, maxsize: int) -> None: ...
2222
def _get(self) -> _T: ...

tests/stubtest_allowlists/py310.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ tempfile.SpooledTemporaryFile.readable
6565
tempfile.SpooledTemporaryFile.seekable
6666
tempfile.SpooledTemporaryFile.writable
6767

68+
# The "loop" argument exists at runtime,
69+
# but raises TypeError if you try to provide any value for it
70+
asyncio.BoundedSemaphore.__init__
71+
asyncio.Condition.__init__
72+
asyncio.Event.__init__
73+
asyncio.Lock.__init__
74+
asyncio.Queue.__init__
75+
asyncio.Semaphore.__init__
76+
asyncio.locks.BoundedSemaphore.__init__
77+
asyncio.locks.Semaphore.__init__
78+
asyncio.locks.Condition.__init__
79+
asyncio.locks.Event.__init__
80+
asyncio.locks.Lock.__init__
81+
asyncio.locks.Semaphore.__init__
82+
asyncio.queues.Queue.__init__
83+
6884
# Exists at runtime, but missing from stubs
6985
_collections_abc.AsyncIterable.__class_getitem__
7086
_collections_abc.Awaitable.__class_getitem__

0 commit comments

Comments
 (0)