mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
Added some missing types from various stdlib stubs (#4466)
This commit is contained in:
@@ -56,8 +56,8 @@ _reducedtype = Union[
|
||||
str,
|
||||
Tuple[Callable[..., Any], Tuple[Any, ...]],
|
||||
Tuple[Callable[..., Any], Tuple[Any, ...], Any],
|
||||
Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator]],
|
||||
Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator], Optional[Iterator]],
|
||||
Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]],
|
||||
Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]],
|
||||
]
|
||||
|
||||
class Pickler:
|
||||
|
||||
@@ -15,7 +15,7 @@ CPython C source: https://github.com/python/cpython/blob/master/Modules/socketmo
|
||||
# Ron Murawski <ron@horizonchess.com>
|
||||
# adapted for Python 2.7 by Michal Pokorny
|
||||
import sys
|
||||
from typing import Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, TypeVar, Union, overload
|
||||
from typing import Any, BinaryIO, Iterable, List, Optional, Sequence, Text, TextIO, Tuple, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
# ----- Constants -----
|
||||
@@ -713,11 +713,11 @@ class socket:
|
||||
self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., __flags: int = ..., __address: _Address = ...
|
||||
) -> int: ...
|
||||
if sys.platform == "linux" and sys.version_info >= (3, 6):
|
||||
# TODO add the parameter types for sendmsg_afalg
|
||||
def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> int: ...
|
||||
def sendmsg_afalg(
|
||||
self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||
) -> int: ...
|
||||
if sys.version_info >= (3,):
|
||||
# TODO determine legal types for file parameter
|
||||
def sendfile(self, file, offset: int = ..., count: Optional[int] = ...) -> int: ...
|
||||
def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ...
|
||||
def set_inheritable(self, inheritable: bool) -> None: ...
|
||||
def setblocking(self, flag: bool) -> None: ...
|
||||
def settimeout(self, value: Optional[float]) -> None: ...
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
import io
|
||||
from typing import Any
|
||||
from _typeshed import WriteableBuffer
|
||||
from io import BufferedIOBase, RawIOBase
|
||||
from typing import Any, Callable, Tuple, Type, Union
|
||||
|
||||
BUFFER_SIZE: Any
|
||||
|
||||
class BaseStream(io.BufferedIOBase): ...
|
||||
class BaseStream(BufferedIOBase): ...
|
||||
|
||||
class DecompressReader(io.RawIOBase):
|
||||
def readable(self): ...
|
||||
def __init__(self, fp, decomp_factory, trailing_error=..., **decomp_args): ...
|
||||
def close(self): ...
|
||||
def seekable(self): ...
|
||||
def readinto(self, b): ...
|
||||
class DecompressReader(RawIOBase):
|
||||
def __init__(
|
||||
self,
|
||||
fp: RawIOBase,
|
||||
decomp_factory: Callable[..., object],
|
||||
trailing_error: Union[Type[Exception], Tuple[Type[Exception], ...]] = ...,
|
||||
**decomp_args: Any,
|
||||
) -> None: ...
|
||||
def readable(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def readinto(self, b: WriteableBuffer) -> int: ...
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
def seek(self, offset, whence=...): ...
|
||||
def tell(self): ...
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def tell(self) -> int: ...
|
||||
|
||||
@@ -36,5 +36,5 @@ if sys.version_info >= (3, 8):
|
||||
exc_value: Optional[BaseException]
|
||||
exc_traceback: Optional[TracebackType]
|
||||
thread: Optional[Thread]
|
||||
def _ExceptHookArgs(args) -> ExceptHookArgs: ...
|
||||
def _ExceptHookArgs(args: Any) -> ExceptHookArgs: ...
|
||||
_excepthook: Callable[[ExceptHookArgs], Any]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import socket
|
||||
import sys
|
||||
from types import TracebackType
|
||||
from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Tuple, Type, Union, overload
|
||||
from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Sequence, Tuple, Type, Union, overload
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
# These are based in socket, maybe move them out into _typeshed.pyi or such
|
||||
@@ -44,13 +44,17 @@ if sys.version_info >= (3, 8):
|
||||
def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> NoReturn: ...
|
||||
def listen(self, __backlog: int = ...) -> None: ...
|
||||
def makefile(self) -> BinaryIO: ...
|
||||
def sendfile(self, file, offset: int = ..., count: Optional[int] = ...) -> int: ...
|
||||
def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ...
|
||||
def close(self) -> None: ...
|
||||
def detach(self) -> int: ...
|
||||
if sys.platform == "linux":
|
||||
def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> int: ...
|
||||
def sendmsg_afalg(
|
||||
self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||
) -> int: ...
|
||||
else:
|
||||
def sendmsg_afalg(self, msg=..., *, op, iv=..., assoclen=..., flags=...) -> NoReturn: ...
|
||||
def sendmsg_afalg(
|
||||
self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||
) -> NoReturn: ...
|
||||
def sendmsg(
|
||||
self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., __flags: int = ..., __address: _Address = ...
|
||||
) -> int: ...
|
||||
|
||||
@@ -3,7 +3,7 @@ from types import TracebackType
|
||||
from typing import Callable, Optional, Protocol, Tuple, Type
|
||||
|
||||
class _WarnFunction(Protocol):
|
||||
def __call__(self, message: str, category: Type[Warning], source: PipeHandle): ...
|
||||
def __call__(self, message: str, category: Type[Warning], source: PipeHandle) -> None: ...
|
||||
|
||||
BUFSIZE: int
|
||||
PIPE: int
|
||||
|
||||
@@ -2,7 +2,7 @@ import array
|
||||
import threading
|
||||
import weakref
|
||||
from queue import Queue as Queue
|
||||
from typing import Any, List, Optional
|
||||
from typing import Any, Callable, Iterable, List, Mapping, Optional, Sequence
|
||||
|
||||
JoinableQueue = Queue
|
||||
Barrier = threading.Barrier
|
||||
@@ -19,7 +19,14 @@ class DummyProcess(threading.Thread):
|
||||
_pid: None
|
||||
_start_called: int
|
||||
exitcode: Optional[int]
|
||||
def __init__(self, group=..., target=..., name=..., args=..., kwargs=...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
group: Any = ...,
|
||||
target: Optional[Callable[..., Any]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[str, Any] = ...,
|
||||
) -> None: ...
|
||||
|
||||
Process = DummyProcess
|
||||
|
||||
@@ -32,11 +39,13 @@ class Value:
|
||||
_typecode: Any
|
||||
_value: Any
|
||||
value: Any
|
||||
def __init__(self, typecode, value, lock=...) -> None: ...
|
||||
def __init__(self, typecode: Any, value: Any, lock: Any = ...) -> None: ...
|
||||
|
||||
def Array(typecode, sequence, lock=...) -> array.array[Any]: ...
|
||||
def Array(typecode: Any, sequence: Sequence[Any], lock: Any = ...) -> array.array[Any]: ...
|
||||
def Manager() -> Any: ...
|
||||
def Pool(processes=..., initializer=..., initargs=...) -> Any: ...
|
||||
def Pool(
|
||||
processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...
|
||||
) -> Any: ...
|
||||
def active_children() -> List[Any]: ...
|
||||
def current_process() -> threading.Thread: ...
|
||||
def freeze_support() -> None: ...
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from queue import Queue
|
||||
from typing import Any, List, Optional, Tuple, TypeVar
|
||||
from types import TracebackType
|
||||
from typing import Any, List, Optional, Tuple, Type, TypeVar, Union
|
||||
|
||||
families: List[None]
|
||||
|
||||
_TConnection = TypeVar("_TConnection", bound=Connection)
|
||||
_TListener = TypeVar("_TListener", bound=Listener)
|
||||
_Address = Union[str, Tuple[str, int]]
|
||||
|
||||
class Connection(object):
|
||||
_in: Any
|
||||
@@ -14,8 +16,10 @@ class Connection(object):
|
||||
send: Any
|
||||
send_bytes: Any
|
||||
def __enter__(self: _TConnection) -> _TConnection: ...
|
||||
def __exit__(self, exc_type, exc_value, exc_tb) -> None: ...
|
||||
def __init__(self, _in, _out) -> None: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
def __init__(self, _in: Any, _out: Any) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def poll(self, timeout: float = ...) -> bool: ...
|
||||
|
||||
@@ -24,10 +28,12 @@ class Listener(object):
|
||||
@property
|
||||
def address(self) -> Optional[Queue[Any]]: ...
|
||||
def __enter__(self: _TListener) -> _TListener: ...
|
||||
def __exit__(self, exc_type, exc_value, exc_tb) -> None: ...
|
||||
def __init__(self, address=..., family=..., backlog=...) -> None: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
def __init__(self, address: Optional[_Address] = ..., family: Optional[int] = ..., backlog: int = ...) -> None: ...
|
||||
def accept(self) -> Connection: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
def Client(address) -> Connection: ...
|
||||
def Client(address: _Address) -> Connection: ...
|
||||
def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ...
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
from types import ModuleType
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Dict, Optional, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class _TempModule:
|
||||
mod_name: str = ...
|
||||
module: ModuleType = ...
|
||||
def __init__(self, mod_name): ...
|
||||
def __enter__(self): ...
|
||||
def __exit__(self, *args): ...
|
||||
def __init__(self, mod_name: str) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
|
||||
class _ModifiedArgv0:
|
||||
value: Any = ...
|
||||
def __init__(self, value): ...
|
||||
def __enter__(self): ...
|
||||
def __exit__(self, *args): ...
|
||||
def __init__(self, value: Any) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
|
||||
def run_module(
|
||||
mod_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: Optional[str] = ..., alter_sys: bool = ...
|
||||
): ...
|
||||
def run_path(path_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: str = ...): ...
|
||||
) -> None: ...
|
||||
def run_path(path_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: str = ...) -> None: ...
|
||||
|
||||
@@ -281,7 +281,7 @@ if sys.version_info >= (3, 6):
|
||||
# Implement Sized (but don't have it as a base class).
|
||||
@abstractmethod
|
||||
def __len__(self) -> int: ...
|
||||
_Collection = Collection
|
||||
_Collection = Collection[_T_co]
|
||||
else:
|
||||
@runtime_checkable
|
||||
class _Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
|
||||
|
||||
Reference in New Issue
Block a user