Dummy thread improvements (#1309)

* dummy_thread improvements

- Complete the Python 3 stub
- Add a Python 2 stub. They're close enough that they should go into 2and3, but
  the module name changed so we can't do that.

* fix my bugs
This commit is contained in:
Jelle Zijlstra
2017-05-23 12:46:42 -07:00
committed by Matthias Kramm
parent 48796411ed
commit 3267e2396b
2 changed files with 41 additions and 8 deletions

22
stdlib/2/dummy_thread.pyi Normal file
View File

@@ -0,0 +1,22 @@
from mypy_extensions import NoReturn
from typing import Any, Callable, Dict, Optional, Tuple
class error(Exception):
def __init__(self, *args: Any) -> None: ...
def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> None: ...
def exit() -> NoReturn: ...
def get_ident() -> int: ...
def allocate_lock() -> LockType: ...
def stack_size(size: Optional[int] = ...) -> int: ...
class LockType(object):
locked_status: bool
def __init__(self) -> None: ...
def acquire(self, waitflag: Optional[bool] = ...) -> bool: ...
def __enter__(self, waitflag: Optional[bool] = ...) -> bool: ...
def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ...
def release(self) -> bool: ...
def locked(self) -> bool: ...
def interrupt_main() -> None: ...

View File

@@ -1,11 +1,22 @@
# Stubs for _dummy_thread
from mypy_extensions import NoReturn
from typing import Any, Callable, Dict, Optional, Tuple
# NOTE: These are incomplete!
from typing import Any
class LockType:
def acquire(self) -> None: ...
def release(self) -> None: ...
TIMEOUT_MAX: int
error = RuntimeError
def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> None: ...
def exit() -> NoReturn: ...
def get_ident() -> int: ...
def allocate_lock() -> LockType: ...
def stack_size(size: Optional[int] = ...) -> int: ...
class LockType(object):
locked_status: bool
def __init__(self) -> None: ...
def acquire(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ...
def __enter__(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ...
def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ...
def release(self) -> bool: ...
def locked(self) -> bool: ...
def interrupt_main() -> None: ...