Skip to content

Commit 4666ea9

Browse files
authored
Merge branch 'master' into updatemypy
2 parents cffd04a + f046590 commit 4666ea9

File tree

11 files changed

+56
-56
lines changed

11 files changed

+56
-56
lines changed

async_generator-stubs/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ def aclosing(obj: _T_closeable) -> AsyncContextManager[_T_closeable]: ...
5757
_AsyncGenHooks = NamedTuple(
5858
"AsyncGenHooks",
5959
[
60-
("firstiter", Optional[Callable[[AsyncGenerator[Any, Any]], None]]),
61-
("finalizer", Optional[Callable[[AsyncGenerator[Any, Any]], None]]),
60+
("firstiter", Optional[Callable[[AsyncGenerator[Any, Any]], Any]]),
61+
("finalizer", Optional[Callable[[AsyncGenerator[Any, Any]], Any]]),
6262
],
6363
)
6464

6565
def get_asyncgen_hooks() -> _AsyncGenHooks: ...
6666
def set_asyncgen_hooks(
67-
firstiter: Optional[Callable[[AsyncGenerator[Any, Any]], None]] = ...,
68-
finalizer: Optional[Callable[[AsyncGenerator[Any, Any]], None]] = ...,
67+
firstiter: Optional[Callable[[AsyncGenerator[Any, Any]], Any]] = ...,
68+
finalizer: Optional[Callable[[AsyncGenerator[Any, Any]], Any]] = ...,
6969
) -> None: ...

ci/travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ex
44

5-
BLACK_VERSION=19.3b0
5+
BLACK_VERSION=19.10b0
66
MYPY_VERSION=0.750
77

88
pip install -U pip setuptools wheel

trio-stubs/__init__.pyi

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ class Nursery(_NotConstructible, metaclass=ABCMeta):
117117
def start_soon(
118118
self,
119119
async_fn: Union[
120-
# List these explicitly instead of Callable[..., Awaitable[None]]
120+
# List these explicitly instead of Callable[..., Awaitable[Any]]
121121
# so that even without the plugin we catch cases of passing a
122122
# function with keyword-only arguments to start_soon().
123-
Callable[[], Awaitable[None]],
124-
Callable[[Any], Awaitable[None]],
125-
Callable[[Any, Any], Awaitable[None]],
126-
Callable[[Any, Any, Any], Awaitable[None]],
127-
Callable[[Any, Any, Any, Any], Awaitable[None]],
128-
Callable[[VarArg()], Awaitable[None]],
123+
Callable[[], Awaitable[Any]],
124+
Callable[[Any], Awaitable[Any]],
125+
Callable[[Any, Any], Awaitable[Any]],
126+
Callable[[Any, Any, Any], Awaitable[Any]],
127+
Callable[[Any, Any, Any, Any], Awaitable[Any]],
128+
Callable[[VarArg()], Awaitable[Any]],
129129
],
130130
*args: Any,
131131
name: object = None,
@@ -134,24 +134,24 @@ class Nursery(_NotConstructible, metaclass=ABCMeta):
134134
async def start(
135135
self,
136136
async_fn: Union[
137-
# List these explicitly instead of Callable[..., Awaitable[None]]
137+
# List these explicitly instead of Callable[..., Awaitable[Any]]
138138
# so that even without the plugin we can infer the return type
139139
# of start(), and fail when a function is passed that doesn't
140140
# accept task_status.
141-
Callable[[NamedArg(TaskStatus[T], "task_status")], Awaitable[None]],
142-
Callable[[Any, NamedArg(TaskStatus[T], "task_status")], Awaitable[None]],
141+
Callable[[NamedArg(TaskStatus[T], "task_status")], Awaitable[Any]],
142+
Callable[[Any, NamedArg(TaskStatus[T], "task_status")], Awaitable[Any]],
143143
Callable[
144-
[Any, Any, NamedArg(TaskStatus[T], "task_status")], Awaitable[None]
144+
[Any, Any, NamedArg(TaskStatus[T], "task_status")], Awaitable[Any]
145145
],
146146
Callable[
147-
[Any, Any, Any, NamedArg(TaskStatus[T], "task_status")], Awaitable[None]
147+
[Any, Any, Any, NamedArg(TaskStatus[T], "task_status")], Awaitable[Any]
148148
],
149149
Callable[
150150
[Any, Any, Any, Any, NamedArg(TaskStatus[T], "task_status")],
151-
Awaitable[None],
151+
Awaitable[Any],
152152
],
153153
Callable[
154-
[VarArg(), NamedArg(TaskStatus[T], "task_status")], Awaitable[None]
154+
[VarArg(), NamedArg(TaskStatus[T], "task_status")], Awaitable[Any]
155155
],
156156
],
157157
*args: Any,
@@ -204,7 +204,7 @@ class CapacityLimiter:
204204
def release_on_behalf_of(self, borrower: object) -> None: ...
205205
def statistics(self) -> _Statistics: ...
206206
async def __aenter__(self) -> None: ...
207-
async def __aexit__(self, *exc: object) -> bool: ...
207+
async def __aexit__(self, *exc: object) -> None: ...
208208

209209
class Semaphore:
210210
value: int
@@ -215,7 +215,7 @@ class Semaphore:
215215
def release(self) -> None: ...
216216
def statistics(self) -> _Statistics: ...
217217
async def __aenter__(self) -> None: ...
218-
async def __aexit__(self, *exc: object) -> bool: ...
218+
async def __aexit__(self, *exc: object) -> None: ...
219219

220220
class Lock:
221221
def locked(self) -> bool: ...
@@ -224,7 +224,7 @@ class Lock:
224224
def release(self) -> None: ...
225225
def statistics(self) -> _Statistics: ...
226226
async def __aenter__(self) -> None: ...
227-
async def __aexit__(self, *exc: object) -> bool: ...
227+
async def __aexit__(self, *exc: object) -> None: ...
228228

229229
class StrictFIFOLock(Lock):
230230
pass
@@ -240,7 +240,7 @@ class Condition:
240240
def notify_all(self) -> None: ...
241241
def statistics(self) -> _Statistics: ...
242242
async def __aenter__(self) -> None: ...
243-
async def __aexit__(self, *exc: object) -> bool: ...
243+
async def __aexit__(self, *exc: object) -> None: ...
244244

245245
# _highlevel_generic
246246
async def aclose_forcefully(resource: trio.abc.AsyncResource) -> None: ...
@@ -281,7 +281,7 @@ class open_memory_channel(Tuple[MemorySendChannel[T], MemoryReceiveChannel[T]]):
281281

282282
# _signals
283283
def open_signal_receiver(
284-
*signals: signal.Signals
284+
*signals: signal.Signals,
285285
) -> ContextManager[AsyncIterator[signal.Signals]]: ...
286286

287287
# _highlevel_socket
@@ -433,7 +433,7 @@ class Path(pathlib.PurePath):
433433
T_resource = TypeVar("T_resource", bound=trio.abc.AsyncResource)
434434

435435
async def serve_listeners(
436-
handler: Callable[[T_resource], Awaitable[None]],
436+
handler: Callable[[T_resource], Awaitable[Any]],
437437
listeners: Sequence[trio.abc.Listener[T_resource]],
438438
*,
439439
handler_nursery: Optional[Nursery] = None,
@@ -450,7 +450,7 @@ async def open_tcp_listeners(
450450
port: int, *, host: Optional[AnyStr] = None, backlog: Optional[int] = None
451451
) -> Sequence[SocketListener]: ...
452452
async def serve_tcp(
453-
handler: Callable[[SocketStream], Awaitable[None]],
453+
handler: Callable[[SocketStream], Awaitable[Any]],
454454
port: int,
455455
*,
456456
host: Optional[AnyStr] = None,
@@ -480,7 +480,7 @@ async def open_ssl_over_tcp_listeners(
480480
backlog: Optional[int] = None,
481481
) -> Sequence[trio.SSLListener]: ...
482482
async def serve_ssl_over_tcp(
483-
handler: Callable[[trio.SSLStream], Awaitable[None]],
483+
handler: Callable[[trio.SSLStream], Awaitable[Any]],
484484
port: int,
485485
ssl_context: ssl.SSLContext,
486486
*,
@@ -618,7 +618,7 @@ else:
618618
shell: Literal[True],
619619
cwd: str = ...,
620620
env: Mapping[str, str] = ...,
621-
preexec_fn: Optional[Callable[[], None]] = ...,
621+
preexec_fn: Optional[Callable[[], Any]] = ...,
622622
restore_signals: bool = ...,
623623
start_new_session: bool = ...,
624624
pass_fds: Sequence[int] = ...,
@@ -634,7 +634,7 @@ else:
634634
shell: bool = ...,
635635
cwd: str = ...,
636636
env: Mapping[str, str] = ...,
637-
preexec_fn: Optional[Callable[[], None]] = ...,
637+
preexec_fn: Optional[Callable[[], Any]] = ...,
638638
restore_signals: bool = ...,
639639
start_new_session: bool = ...,
640640
pass_fds: Sequence[int] = ...,
@@ -653,7 +653,7 @@ else:
653653
shell: Literal[True],
654654
cwd: str = ...,
655655
env: Mapping[str, str] = ...,
656-
preexec_fn: Optional[Callable[[], None]] = ...,
656+
preexec_fn: Optional[Callable[[], Any]] = ...,
657657
restore_signals: bool = ...,
658658
start_new_session: bool = ...,
659659
pass_fds: Sequence[int] = ...,
@@ -672,7 +672,7 @@ else:
672672
shell: bool = ...,
673673
cwd: str = ...,
674674
env: Mapping[str, str] = ...,
675-
preexec_fn: Optional[Callable[[], None]] = ...,
675+
preexec_fn: Optional[Callable[[], Any]] = ...,
676676
restore_signals: bool = ...,
677677
start_new_session: bool = ...,
678678
pass_fds: Sequence[int] = ...,

trio-stubs/abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AsyncResource(metaclass=ABCMeta):
5252
@abstractmethod
5353
async def aclose(self) -> None: ...
5454
async def __aenter__(self: T) -> T: ...
55-
async def __aexit__(self, *exc: object) -> bool: ...
55+
async def __aexit__(self, *exc: object) -> None: ...
5656

5757
class SendStream(AsyncResource):
5858
@abstractmethod

trio-stubs/hazmat.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TrioToken:
3939
@takes_callable_and_args
4040
def run_sync_soon(
4141
self,
42-
sync_fn: Union[Callable[..., None], Callable[[VarArg()], None]],
42+
sync_fn: Union[Callable[..., Any], Callable[[VarArg()], Any]],
4343
*args: Any,
4444
idempotent: bool = False,
4545
) -> None: ...
@@ -75,7 +75,7 @@ def reschedule(task: Task, next_send: outcome.Outcome[Any] = ...) -> None: ...
7575
@takes_callable_and_args
7676
def spawn_system_task(
7777
async_fn: Union[
78-
Callable[..., Awaitable[None]], Callable[[VarArg()], Awaitable[None]]
78+
Callable[..., Awaitable[Any]], Callable[[VarArg()], Awaitable[Any]]
7979
],
8080
*args: Any,
8181
name: object = ...,
@@ -117,7 +117,7 @@ async def wait_task_rescheduled(
117117
abort_func: Callable[[Callable[[], NoReturn]], Abort]
118118
) -> Any: ...
119119
async def permanently_detach_coroutine_object(
120-
final_outcome: outcome.Outcome[object]
120+
final_outcome: outcome.Outcome[object],
121121
) -> Any: ...
122122
async def temporarily_detach_coroutine_object(
123123
abort_func: Callable[[Callable[[], NoReturn]], Abort]

trio-stubs/socket.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ from socket import (
408408
)
409409

410410
def set_custom_hostname_resolver(
411-
hostname_resolver: Optional[trio.abc.HostnameResolver]
411+
hostname_resolver: Optional[trio.abc.HostnameResolver],
412412
) -> Optional[trio.abc.HostnameResolver]: ...
413413
def set_custom_socket_factory(
414-
socket_factory: Optional[trio.abc.SocketFactory]
414+
socket_factory: Optional[trio.abc.SocketFactory],
415415
) -> Optional[trio.abc.SocketFactory]: ...
416416
async def getnameinfo(sockaddr: Tuple[Any, ...], flags: int) -> Tuple[str, int]: ...
417417
async def getprotobyname(name: str) -> int: ...
@@ -476,8 +476,8 @@ class SocketType:
476476
def get_inheritable(self) -> bool: ...
477477
def set_inheritable(self, inheritable: bool) -> None: ...
478478
def fileno(self) -> int: ...
479-
def getpeername(self) -> Union[None, Tuple[Any, ...], str]: ...
480-
def getsockname(self) -> Union[None, Tuple[Any, ...], str]: ...
479+
def getpeername(self) -> Any: ...
480+
def getsockname(self) -> Any: ...
481481
@overload
482482
def getsockopt(self, level: int, optname: int) -> int: ...
483483
@overload

trio-stubs/testing.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ async def check_half_closeable_stream(
4848
stream_maker: _StreamMaker, clogged_stream_maker: Optional[_StreamMaker]
4949
) -> None: ...
5050

51-
MemoryStreamHook = Optional[Callable[[], Awaitable[None]]]
52-
MemoryStreamSyncHook = Optional[Callable[[], None]]
51+
MemoryStreamHook = Optional[Callable[[], Awaitable[Any]]]
52+
MemoryStreamSyncHook = Optional[Callable[[], Any]]
5353
@attr.s(auto_attribs=True)
5454
class MemorySendStream(trio.abc.SendStream):
5555
send_all_hook: MemoryStreamHook = ...
@@ -83,5 +83,5 @@ def memory_stream_pair() -> Tuple[trio.StapledStream, trio.StapledStream]: ...
8383
def lockstep_stream_one_way_pair() -> Tuple[MemorySendStream, MemoryReceiveStream]: ...
8484
def lockstep_stream_pair() -> Tuple[trio.StapledStream, trio.StapledStream]: ...
8585
async def open_stream_to_socket_listener(
86-
socket_listener: trio.SocketListener
86+
socket_listener: trio.SocketListener,
8787
) -> trio.SocketStream: ...

trio_typing/_tests/test-data/async_generator.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async def dummy():
6161
firstiter = agen.get_asyncgen_hooks().firstiter
6262
if firstiter is not None:
6363
firstiter(iter([])) # E: Argument 1 has incompatible type "Iterator[<nothing>]"; expected "AsyncGenerator[Any, Any]"
64-
reveal_type(firstiter(dummy())) # N: Revealed type is 'None'
64+
reveal_type(firstiter(dummy())) # N: Revealed type is 'Any'
6565
agen.set_asyncgen_hooks(firstiter)
6666
agen.set_asyncgen_hooks(firstiter, finalizer=firstiter)
6767

trio_typing/_tests/test-data/taskstatus.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ async def child2(
1616

1717
async def parent() -> None:
1818
async with trio.open_nursery() as nursery:
19-
nursery.start_soon(child, 10) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[int], Awaitable[None]]"
20-
nursery.start_soon(child2) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, DefaultNamedArg(TaskStatus[None], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[], Awaitable[None]]"
21-
nursery.start_soon(child2, "hi") # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, DefaultNamedArg(TaskStatus[None], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[str], Awaitable[None]]"
19+
nursery.start_soon(child, 10) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[int], Awaitable[Any]]"
20+
nursery.start_soon(child2) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, DefaultNamedArg(TaskStatus[None], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[], Awaitable[Any]]"
21+
nursery.start_soon(child2, "hi") # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, DefaultNamedArg(TaskStatus[None], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[str], Awaitable[Any]]"
2222
nursery.start_soon(child2, 50)
23-
await nursery.start(child) # E: Argument 1 to "start" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[NamedArg(TaskStatus[<nothing>], 'task_status')], Awaitable[None]]"
24-
await nursery.start(child, "hi") # E: Argument 1 to "start" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[str, NamedArg(TaskStatus[int], 'task_status')], Awaitable[None]]"
23+
await nursery.start(child) # E: Argument 1 to "start" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[NamedArg(TaskStatus[<nothing>], 'task_status')], Awaitable[Any]]"
24+
await nursery.start(child, "hi") # E: Argument 1 to "start" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Callable[[str, NamedArg(TaskStatus[int], 'task_status')], Awaitable[Any]]"
2525
result = await nursery.start(child, 10)
2626
result2 = await nursery.start(child2, 10)
2727
reveal_type(result) # N: Revealed type is 'builtins.int*'
@@ -45,7 +45,7 @@ async def child2(
4545

4646
async def parent() -> None:
4747
async with trio.open_nursery() as nursery:
48-
nursery.start_soon(child, 10) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Union[Callable[[], Awaitable[None]], Callable[[Any], Awaitable[None]], Callable[[Any, Any], Awaitable[None]], Callable[[Any, Any, Any], Awaitable[None]], Callable[[Any, Any, Any, Any], Awaitable[None]], Callable[[VarArg(Any)], Awaitable[None]]]"
48+
nursery.start_soon(child, 10) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[int, NamedArg(TaskStatus[int], 'task_status')], Coroutine[Any, Any, None]]"; expected "Union[Callable[[], Awaitable[Any]], Callable[[Any], Awaitable[Any]], Callable[[Any, Any], Awaitable[Any]], Callable[[Any, Any, Any], Awaitable[Any]], Callable[[Any, Any, Any, Any], Awaitable[Any]], Callable[[VarArg(Any)], Awaitable[Any]]]"
4949
nursery.start_soon(child2)
5050
nursery.start_soon(child2, "hi")
5151
nursery.start_soon(child2, 50)

trio_typing/_tests/test-data/trio-basic.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ async def sleep_sort(values: Sequence[float]) -> List[float]:
1515
reveal_type(nursery.cancel_scope) # N: Revealed type is 'trio.CancelScope'
1616
for value in values:
1717
nursery.start_soon(worker, value)
18-
nursery.start_soon(worker) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[float], Coroutine[Any, Any, None]]"; expected "Callable[[], Awaitable[None]]"
19-
nursery.start_soon(worker, "hi") # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[float], Coroutine[Any, Any, None]]"; expected "Callable[[str], Awaitable[None]]"
20-
nursery.start_soon(worker, value, value) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[float], Coroutine[Any, Any, None]]"; expected "Callable[[float, float], Awaitable[None]]"
18+
nursery.start_soon(worker) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[float], Coroutine[Any, Any, None]]"; expected "Callable[[], Awaitable[Any]]"
19+
nursery.start_soon(worker, "hi") # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[float], Coroutine[Any, Any, None]]"; expected "Callable[[str], Awaitable[Any]]"
20+
nursery.start_soon(worker, value, value) # E: Argument 1 to "start_soon" of "Nursery" has incompatible type "Callable[[float], Coroutine[Any, Any, None]]"; expected "Callable[[float, float], Awaitable[Any]]"
2121

2222
return result
2323

trio_typing/plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def takes_callable_and_args_callback(ctx: FunctionContext) -> Type:
417417
@trio_typing.takes_callable_and_args
418418
def start_soon(
419419
self,
420-
async_fn: Callable[[VarArg()], None],
420+
async_fn: Callable[[VarArg()], Any],
421421
*args: Any,
422422
) -> None: ...
423423
@@ -431,20 +431,20 @@ def start_soon(
431431
@overload
432432
def start_soon(
433433
self,
434-
async_fn: Callable[[], None],
434+
async_fn: Callable[[], Any],
435435
) -> None: ...
436436
437437
@overload
438438
def start_soon(
439439
self,
440-
async_fn: Callable[[T1], None],
440+
async_fn: Callable[[T1], Any],
441441
__arg1: T1,
442442
) -> None: ...
443443
444444
@overload
445445
def start_soon(
446446
self,
447-
async_fn: Callable[[T1, T2], None],
447+
async_fn: Callable[[T1, T2], Any],
448448
__arg1: T1,
449449
__arg2: T2
450450
) -> None: ...

0 commit comments

Comments
 (0)