|
1 | | -from typing import Any, Optional |
| 1 | +from types import TracebackType |
| 2 | +from typing import Any, Optional, Type |
| 3 | + |
| 4 | +from .concurrent import Future |
2 | 5 |
|
3 | 6 | class _TimeoutGarbageCollector: |
4 | | - def __init__(self): ... |
| 7 | + def __init__(self) -> None: ... |
5 | 8 |
|
6 | 9 | class Condition(_TimeoutGarbageCollector): |
7 | 10 | io_loop: Any |
8 | | - def __init__(self): ... |
9 | | - def wait(self, timeout: Optional[Any] = ...): ... |
10 | | - def notify(self, n: int = ...): ... |
11 | | - def notify_all(self): ... |
| 11 | + def __init__(self) -> None: ... |
| 12 | + def wait(self, timeout: Optional[float] = ...) -> Future: ... |
| 13 | + def notify(self, n: int = ...) -> None: ... |
| 14 | + def notify_all(self) -> None: ... |
12 | 15 |
|
13 | 16 | class Event: |
14 | | - def __init__(self): ... |
15 | | - def is_set(self): ... |
16 | | - def set(self): ... |
17 | | - def clear(self): ... |
| 17 | + def __init__(self) -> None: ... |
| 18 | + def is_set(self) -> bool: ... |
| 19 | + def set(self) -> None: ... |
| 20 | + def clear(self) -> None: ... |
18 | 21 | def wait(self, timeout: Optional[Any] = ...): ... |
19 | 22 |
|
20 | 23 | class _ReleasingContextManager: |
21 | | - def __init__(self, obj): ... |
22 | | - def __enter__(self): ... |
| 24 | + def __init__(self, obj) -> None: ... |
| 25 | + def __enter__(self) -> None: ... |
23 | 26 | def __exit__(self, exc_type, exc_val, exc_tb): ... |
24 | 27 |
|
25 | 28 | class Semaphore(_TimeoutGarbageCollector): |
26 | | - def __init__(self, value: int = ...): ... |
27 | | - def release(self): ... |
28 | | - def acquire(self, timeout: Optional[Any] = ...): ... |
29 | | - def __enter__(self): ... |
30 | | - __exit__: Any |
31 | | - def __aenter__(self): ... |
32 | | - def __aexit__(self, typ, value, tb): ... |
33 | | - |
34 | | -class BoundedSemaphore(Semaphore): |
35 | | - def __init__(self, value: int = ...): ... |
36 | | - def release(self): ... |
| 29 | + def __init__(self, value: int = ...) -> None: ... |
| 30 | + def release(self) -> None: ... |
| 31 | + def acquire(self, timeout: Optional[float] = ...) -> Future: ... |
| 32 | + # __enter__ and __exit__ exist but always throw an error, so we |
| 33 | + # omit them to give better error message while type checking. |
| 34 | + def __aenter__(self) -> Future: ... |
| 35 | + def __aexit__( |
| 36 | + self, typ: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType] |
| 37 | + ) -> Future: ... |
| 38 | + |
| 39 | +class BoundedSemaphore(Semaphore): ... |
37 | 40 |
|
38 | 41 | class Lock: |
39 | | - def __init__(self): ... |
40 | | - def acquire(self, timeout: Optional[Any] = ...): ... |
41 | | - def release(self): ... |
42 | | - def __enter__(self): ... |
43 | | - __exit__: Any |
44 | | - def __aenter__(self): ... |
45 | | - def __aexit__(self, typ, value, tb): ... |
| 42 | + def __init__(self) -> None: ... |
| 43 | + def acquire(self, timeout: Optional[float] = ...) -> Future: ... |
| 44 | + def release(self) -> None: ... |
| 45 | + # __enter__ and __exit__ exist but always throw an error, so we |
| 46 | + # omit them to give better error message while type checking. |
| 47 | + def __aenter__(self) -> Future: ... |
| 48 | + def __aexit__( |
| 49 | + self, typ: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType] |
| 50 | + ) -> Future: ... |
0 commit comments