mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
threading: fix ExceptHookArgs being a function instead of a type (#4768)
The previous typing meant `threading.ExceptHookArgs` could not be used to type a value. The new typing follows what cpython does in the happy path (`_thread` exists rather than the pure-python fallback being used). Fixes #4767.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from threading import Thread
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Dict, NamedTuple, NoReturn, Optional, Tuple, Type
|
||||
from typing import Any, Callable, Dict, NoReturn, Optional, Tuple, Type
|
||||
|
||||
error = RuntimeError
|
||||
|
||||
@@ -29,10 +29,13 @@ TIMEOUT_MAX: float
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_native_id() -> int: ... # only available on some platforms
|
||||
class ExceptHookArgs(NamedTuple):
|
||||
exc_type: Type[BaseException]
|
||||
exc_value: Optional[BaseException]
|
||||
exc_traceback: Optional[TracebackType]
|
||||
thread: Optional[Thread]
|
||||
def _ExceptHookArgs(args: Any) -> ExceptHookArgs: ...
|
||||
_excepthook: Callable[[ExceptHookArgs], Any]
|
||||
class _ExceptHookArgs(Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]):
|
||||
@property
|
||||
def exc_type(self) -> Type[BaseException]: ...
|
||||
@property
|
||||
def exc_value(self) -> Optional[BaseException]: ...
|
||||
@property
|
||||
def exc_traceback(self) -> Optional[TracebackType]: ...
|
||||
@property
|
||||
def thread(self) -> Optional[Thread]: ...
|
||||
_excepthook: Callable[[_ExceptHookArgs], Any]
|
||||
|
||||
Reference in New Issue
Block a user