The threading.excepthook variable (added in Python 3.8) accepts a threading.ExceptHookArgs argument (available at runtime). The typing around it in typeshed is not straightforward:
|
if sys.version_info >= (3, 8): |
|
import _thread |
|
|
|
# don't ask... |
|
_ExceptHookArgs = _thread.ExceptHookArgs |
|
ExceptHookArgs = _thread._ExceptHookArgs |
|
|
|
excepthook: Callable[[_ExceptHookArgs], Any] |
Sorry but I guess I have to ask 😀
The _thread part is:
|
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] |
My practical issue is that this:
import threading
def my_hook(args: threading.ExceptHookArgs) -> None:
...
results in
Function "_thread._ExceptHookArgs" is not valid as a type [valid-type]
The
threading.excepthookvariable (added in Python 3.8) accepts athreading.ExceptHookArgsargument (available at runtime). The typing around it in typeshed is not straightforward:typeshed/stdlib/2and3/threading.pyi
Lines 157 to 164 in 8c20938
Sorry but I guess I have to ask 😀
The
_threadpart is:typeshed/stdlib/3/_thread.pyi
Lines 30 to 38 in 8c20938
My practical issue is that this:
results in