Skip to content

Commit 2fcf336

Browse files
committed
Revert "Replace async def with @coroutine"
This reverts commit 66bcf8f.
1 parent 66bcf8f commit 2fcf336

File tree

2 files changed

+74
-106
lines changed

2 files changed

+74
-106
lines changed

stdlib/3/asyncio/base_events.pyi

+36-51
Original file line numberDiff line numberDiff line change
@@ -61,51 +61,41 @@ class BaseEventLoop(AbstractEventLoop):
6161
@coroutine
6262
def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
6363
if sys.version_info >= (3, 7):
64-
@coroutine
65-
def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
66-
fallback: bool = ...) -> Generator[Any, None, int]: ...
64+
async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
65+
fallback: bool = ...) -> int: ...
6766
@overload
68-
@coroutine
69-
def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
70-
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ...,
71-
local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...,
72-
ssl_handshake_timeout: Optional[float] = ...) -> Generator[Any, None, _TransProtPair]: ...
67+
async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
68+
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ...,
69+
sock: None = ..., local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...,
70+
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
7371
@overload
74-
@coroutine
75-
def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
76-
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket,
77-
local_addr: None = ..., server_hostname: Optional[str] = ...,
78-
ssl_handshake_timeout: Optional[float] = ...) -> Generator[Any, None, _TransProtPair]: ...
72+
async def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
73+
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ...,
74+
sock: socket, local_addr: None = ..., server_hostname: Optional[str] = ...,
75+
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
7976
@overload
80-
@coroutine
81-
def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ...,
82-
port: int = ..., *, family: int = ..., flags: int = ..., sock: None = ..., backlog: int = ...,
83-
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
84-
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> Generator[Any, None, AbstractServer]: ...
77+
async def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ...,
78+
port: int = ..., *, family: int = ..., flags: int = ..., sock: None = ..., backlog: int = ...,
79+
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
80+
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> AbstractServer: ...
8581
@overload
86-
@coroutine
87-
def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *, family: int = ...,
88-
flags: int = ..., sock: socket = ..., backlog: int = ..., ssl: _SSLContext = ...,
89-
reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
90-
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> Generator[Any, None, AbstractServer]: ...
91-
@coroutine
92-
def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *, ssl: _SSLContext = ...,
93-
sock: Optional[socket] = ..., server_hostname: str = ...,
94-
ssl_handshake_timeout: Optional[float]) -> Generator[Any, None, _TransProtPair]: ...
95-
@coroutine
96-
def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
97-
backlog: int = ..., ssl: _SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
98-
start_serving: bool = ...) -> Generator[Any, None, AbstractServer]: ...
99-
@coroutine
100-
def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...,
101-
ssl_handshake_timeout: Optional[float] = ...) -> Generator[Any, None, _TransProtPair]: ...
102-
@coroutine
103-
def sendfile(self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
104-
fallback: bool = ...) -> Generator[Any, None, int]: ...
105-
@coroutine
106-
def start_tls(self, transport: BaseTransport, protocol: BaseProtocol, sslcontext: ssl.SSLContext, *,
107-
server_side: bool = ..., server_hostname: Optional[str] = ...,
108-
ssl_handshake_timeout: Optional[float] = ...) -> Generator[Any, None, BaseTransport]: ...
82+
async def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
83+
family: int = ..., flags: int = ..., sock: socket = ..., backlog: int = ...,
84+
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
85+
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> AbstractServer: ...
86+
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *, ssl: _SSLContext = ...,
87+
sock: Optional[socket] = ..., server_hostname: str = ...,
88+
ssl_handshake_timeout: Optional[float]) -> _TransProtPair: ...
89+
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
90+
backlog: int = ..., ssl: _SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
91+
start_serving: bool = ...) -> AbstractServer: ...
92+
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...,
93+
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
94+
async def sendfile(self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
95+
fallback: bool = ...) -> int: ...
96+
async def start_tls(self, transport: BaseTransport, protocol: BaseProtocol, sslcontext: ssl.SSLContext, *,
97+
server_side: bool = ..., server_hostname: Optional[str] = ...,
98+
ssl_handshake_timeout: Optional[float] = ...) -> BaseTransport: ...
10999
else:
110100
@overload
111101
@coroutine
@@ -166,16 +156,11 @@ class BaseEventLoop(AbstractEventLoop):
166156
def remove_writer(self, fd: selectors._FileObject) -> None: ...
167157
# Completion based I/O methods returning Futures prior to 3.7
168158
if sys.version_info >= (3, 7):
169-
@coroutine
170-
def sock_recv(self, sock: socket, nbytes: int) -> Generator[Any, None, bytes]: ...
171-
@coroutine
172-
def sock_recv_into(self, sock: socket, buf: bytearray) -> Generator[Any, None, int]: ...
173-
@coroutine
174-
def sock_sendall(self, sock: socket, data: bytes) -> Generator[Any, None, None]: ...
175-
@coroutine
176-
def sock_connect(self, sock: socket, address: _Address) -> Generator[Any, None, None]: ...
177-
@coroutine
178-
def sock_accept(self, sock: socket) -> Generator[Any, None, Tuple[socket, _RetAddress]]: ...
159+
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
160+
async def sock_recv_into(self, sock: socket, buf: bytearray) -> int: ...
161+
async def sock_sendall(self, sock: socket, data: bytes) -> None: ...
162+
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
163+
async def sock_accept(self, sock: socket) -> Tuple[socket, _RetAddress]: ...
179164
else:
180165
def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ...
181166
def sock_sendall(self, sock: socket, data: bytes) -> Future[None]: ...

stdlib/3/asyncio/events.pyi

+38-55
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ class AbstractServer:
3939
if sys.version_info >= (3, 7):
4040
def get_loop(self) -> AbstractEventLoop: ...
4141
def is_serving(self) -> bool: ...
42-
@coroutine
43-
def start_serving(self) -> Generator[Any, None, None]: ...
44-
@coroutine
45-
def serve_forever(self) -> Generator[Any, None, None]: ...
42+
async def start_serving(self) -> None: ...
43+
async def serve_forever(self) -> None: ...
4644
@coroutine
4745
def wait_closed(self) -> Generator[Any, None, None]: ...
4846

@@ -113,60 +111,50 @@ class AbstractEventLoop(metaclass=ABCMeta):
113111
def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
114112
if sys.version_info >= (3, 7):
115113
@abstractmethod
116-
@coroutine
117-
def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
118-
fallback: bool = ...) -> Generator[Any, None, int]: ...
114+
async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
115+
fallback: bool = ...) -> int: ...
119116
@overload
120117
@abstractmethod
121-
@coroutine
122-
def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
123-
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ...,
124-
local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...,
125-
ssl_handshake_timeout: Optional[float] = ...) -> Generator[Any, None, _TransProtPair]: ...
118+
async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
119+
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ...,
120+
sock: None = ..., local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...,
121+
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
126122
@overload
127123
@abstractmethod
128-
@coroutine
129-
def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
130-
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket,
131-
local_addr: None = ..., server_hostname: Optional[str] = ...,
132-
ssl_handshake_timeout: Optional[float] = ...) -> Generator[Any, None, _TransProtPair]: ...
124+
async def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
125+
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ...,
126+
sock: socket, local_addr: None = ..., server_hostname: Optional[str] = ...,
127+
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
133128
@overload
134129
@abstractmethod
135-
@coroutine
136-
def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ...,
137-
port: int = ..., *, family: int = ..., flags: int = ..., sock: None = ..., backlog: int = ...,
138-
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
139-
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> Generator[Any, None, AbstractServer]: ...
130+
async def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ...,
131+
port: int = ..., *, family: int = ..., flags: int = ..., sock: None = ..., backlog: int = ...,
132+
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
133+
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> AbstractServer: ...
140134
@overload
141135
@abstractmethod
142-
@coroutine
143-
def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
144-
family: int = ..., flags: int = ..., sock: socket = ..., backlog: int = ...,
145-
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
146-
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> Generator[Any, None, AbstractServer]: ...
136+
async def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
137+
family: int = ..., flags: int = ..., sock: socket = ..., backlog: int = ...,
138+
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
139+
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> AbstractServer: ...
147140
@abstractmethod
148-
@coroutine
149-
def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *, ssl: _SSLContext = ...,
150-
sock: Optional[socket] = ..., server_hostname: str = ...,
151-
ssl_handshake_timeout: Optional[float]) -> Generator[Any, None, _TransProtPair]: ...
141+
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *, ssl: _SSLContext = ...,
142+
sock: Optional[socket] = ..., server_hostname: str = ...,
143+
ssl_handshake_timeout: Optional[float]) -> _TransProtPair: ...
152144
@abstractmethod
153-
@coroutine
154-
def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
155-
backlog: int = ..., ssl: _SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
156-
start_serving: bool = ...) -> Generator[Any, None, AbstractServer]: ...
145+
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
146+
backlog: int = ..., ssl: _SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
147+
start_serving: bool = ...) -> AbstractServer: ...
157148
@abstractmethod
158-
@coroutine
159-
def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...,
160-
ssl_handshake_timeout: Optional[float] = ...) -> Generator[Any, None, _TransProtPair]: ...
149+
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...,
150+
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
161151
@abstractmethod
162-
@coroutine
163-
def sendfile(self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
164-
fallback: bool = ...) -> Generator[Any, None, int]: ...
152+
async def sendfile(self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
153+
fallback: bool = ...) -> int: ...
165154
@abstractmethod
166-
@coroutine
167-
def start_tls(self, transport: BaseTransport, protocol: BaseProtocol, sslcontext: ssl.SSLContext, *,
168-
server_side: bool = ..., server_hostname: Optional[str] = ..., ssl_handshake_timeout: Optional[float] = ...
169-
) -> Generator[Any, None, BaseTransport]: ...
155+
async def start_tls(self, transport: BaseTransport, protocol: BaseProtocol, sslcontext: ssl.SSLContext, *,
156+
server_side: bool = ..., server_hostname: Optional[str] = ...,
157+
ssl_handshake_timeout: Optional[float] = ...) -> BaseTransport: ...
170158
else:
171159
@overload
172160
@abstractmethod
@@ -244,20 +232,15 @@ class AbstractEventLoop(metaclass=ABCMeta):
244232
# Completion based I/O methods returning Futures prior to 3.7
245233
if sys.version_info >= (3, 7):
246234
@abstractmethod
247-
@coroutine
248-
def sock_recv(self, sock: socket, nbytes: int) -> Generator[Any, None, bytes]: ...
235+
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
249236
@abstractmethod
250-
@coroutine
251-
def sock_recv_into(self, sock: socket, buf: bytearray) -> Generator[Any, None, int]: ...
237+
async def sock_recv_into(self, sock: socket, buf: bytearray) -> int: ...
252238
@abstractmethod
253-
@coroutine
254-
def sock_sendall(self, sock: socket, data: bytes) -> Generator[Any, None, None]: ...
239+
async def sock_sendall(self, sock: socket, data: bytes) -> None: ...
255240
@abstractmethod
256-
@coroutine
257-
def sock_connect(self, sock: socket, address: _Address) -> Generator[Any, None, None]: ...
241+
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
258242
@abstractmethod
259-
@coroutine
260-
def sock_accept(self, sock: socket) -> Generator[Any, None, Tuple[socket, _RetAddress]]: ...
243+
async def sock_accept(self, sock: socket) -> Tuple[socket, _RetAddress]: ...
261244
else:
262245
@abstractmethod
263246
def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ...

0 commit comments

Comments
 (0)