Unify file descriptor definitions (#3584)

The _types module can house any common type defintions used throughout
the rest of typeshed to keep defintions in sync.

First candidate is file descriptors where anything with `fileno()`
method is accepted. There were several different implementations in
various files that can be unified.
This commit is contained in:
Daniel Farley
2020-01-08 17:25:36 -08:00
committed by Rebecca Chen
parent 1651348a08
commit 955e9c7da4
10 changed files with 84 additions and 86 deletions

View File

@@ -1,17 +1,14 @@
import io
import sys
from typing import Union, Protocol
class _HasFileno(Protocol):
def fileno(self) -> int: ...
_File = Union[_HasFileno, int]
from _types import FileDescriptorLike
def cancel_dump_traceback_later() -> None: ...
def disable() -> None: ...
def dump_traceback(file: _File = ..., all_threads: bool = ...) -> None: ...
def dump_traceback_later(timeout: float, repeat: bool = ..., file: _File = ..., exit: bool = ...) -> None: ...
def enable(file: _File = ..., all_threads: bool = ...) -> None: ...
def dump_traceback(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ...
def dump_traceback_later(timeout: float, repeat: bool = ..., file: FileDescriptorLike = ..., exit: bool = ...) -> None: ...
def enable(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ...
def is_enabled() -> bool: ...
if sys.platform != "win32":
def register(signum: int, file: _File = ..., all_threads: bool = ..., chain: bool = ...) -> None: ...
def register(signum: int, file: FileDescriptorLike = ..., all_threads: bool = ..., chain: bool = ...) -> None: ...
def unregister(signum: int) -> None: ...