Added some missing type annotations in stdlib stubs. (#4418)

Co-authored-by: Eric Traut <erictr@microsoft.com>
This commit is contained in:
Eric Traut
2020-08-08 11:49:37 -07:00
committed by GitHub
parent 030e5ad1dd
commit f46fb7ff59
16 changed files with 34 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
from tracemalloc import _FrameTupleT, _TraceTupleT
from typing import Optional, Sequence, Tuple
def _get_object_traceback(__obj) -> Optional[Sequence[_FrameTupleT]]: ...
def _get_object_traceback(__obj: object) -> Optional[Sequence[_FrameTupleT]]: ...
def _get_traces() -> Sequence[_TraceTupleT]: ...
def clear_traces() -> None: ...
def get_traceback_limit() -> int: ...

View File

@@ -1,5 +1,5 @@
import contextvars
from typing import Callable, List, Sequence, Tuple
from typing import Any, Callable, List, Sequence, Tuple
from typing_extensions import Literal
from . import futures
@@ -9,5 +9,5 @@ _CANCELLED: Literal["CANCELLED"] # undocumented
_FINISHED: Literal["FINISHED"] # undocumented
def isfuture(obj: object) -> bool: ...
def _format_callbacks(cb: Sequence[Tuple[Callable[[futures.Future], None], contextvars.Context]]) -> str: ... # undocumented
def _future_repr_info(future: futures.Future) -> List[str]: ... # undocumented
def _format_callbacks(cb: Sequence[Tuple[Callable[[futures.Future[Any]], None], contextvars.Context]]) -> str: ... # undocumented
def _future_repr_info(future: futures.Future[Any]) -> List[str]: ... # undocumented

View File

@@ -10,10 +10,10 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
_closed: bool # undocumented
_protocol: protocols.SubprocessProtocol # undocumented
_loop: events.AbstractEventLoop # undocumented
_proc: Optional[subprocess.Popen] # undocumented
_proc: Optional[subprocess.Popen[Any]] # undocumented
_pid: Optional[int] # undocumented
_returncode: Optional[int] # undocumented
_exit_waiters: List[futures.Future] # undocumented
_exit_waiters: List[futures.Future[Any]] # undocumented
_pending_calls: Deque[Tuple[Callable[..., Any], Tuple[Any, ...]]] # undocumented
_pipes: Dict[int, _File] # undocumented
_finished: bool # undocumented
@@ -27,7 +27,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
stdout: _File,
stderr: _File,
bufsize: int,
waiter: Optional[futures.Future] = ...,
waiter: Optional[futures.Future[Any]] = ...,
extra: Optional[Any] = ...,
**kwargs: Any,
) -> None: ...
@@ -40,7 +40,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
stderr: _File,
bufsize: int,
**kwargs: Any,
): ... # undocumented
) -> None: ... # undocumented
def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ...
def get_protocol(self) -> protocols.BaseProtocol: ...
def is_closing(self) -> bool: ...
@@ -52,7 +52,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
def send_signal(self, signal: int) -> None: ... # type: ignore
def terminate(self) -> None: ...
def kill(self) -> None: ...
async def _connect_pipes(self, waiter: Optional[futures.Future]) -> None: ... # undocumented
async def _connect_pipes(self, waiter: Optional[futures.Future[Any]]) -> None: ... # undocumented
def _call(self, cb: Callable[..., Any], *data: Any) -> None: ... # undocumented
def _pipe_connection_lost(self, fd: int, exc: Optional[BaseException]) -> None: ... # undocumented
def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented

View File

@@ -1,9 +1,9 @@
from _typeshed import AnyPath
from types import FrameType
from typing import List, Optional
from typing import Any, List, Optional
from . import tasks
def _task_repr_info(task: tasks.Task) -> List[str]: ... # undocumented
def _task_get_stack(task: tasks.Task, limit: Optional[int]) -> List[FrameType]: ... # undocumented
def _task_print_stack(task: tasks.Task, limit: Optional[int], file: AnyPath): ... # undocumented
def _task_repr_info(task: tasks.Task[Any]) -> List[str]: ... # undocumented
def _task_get_stack(task: tasks.Task[Any], limit: Optional[int]) -> List[FrameType]: ... # undocumented
def _task_print_stack(task: tasks.Task[Any], limit: Optional[int], file: AnyPath) -> None: ... # undocumented

View File

@@ -81,7 +81,7 @@ class SSLProtocol(protocols.Protocol):
_extra: Dict[str, Any]
_write_backlog: Deque[Tuple[bytes, int]]
_write_buffer_size: int
_waiter: futures.Future
_waiter: futures.Future[Any]
_loop: events.AbstractEventLoop
_app_transport: _SSLProtocolTransport
_sslpipe: Optional[_SSLPipe]
@@ -100,7 +100,7 @@ class SSLProtocol(protocols.Protocol):
loop: events.AbstractEventLoop,
app_protocol: protocols.BaseProtocol,
sslcontext: ssl.SSLContext,
waiter: futures.Future,
waiter: futures.Future[Any],
server_side: bool = ...,
server_hostname: Optional[str] = ...,
call_connection_made: bool = ...,

View File

@@ -5,5 +5,8 @@ from . import events
if sys.version_info >= (3, 8):
async def staggered_race(
coro_fns: Iterable[Callable[[], Awaitable]], delay: Optional[float], *, loop: Optional[events.AbstractEventLoop] = ...
coro_fns: Iterable[Callable[[], Awaitable[Any]]],
delay: Optional[float],
*,
loop: Optional[events.AbstractEventLoop] = ...,
) -> Tuple[Any, Optional[int], List[Optional[Exception]]]: ...

View File

@@ -83,9 +83,9 @@ class _GzipReader(_compression.DecompressReader):
def read(self, size: int = ...) -> bytes: ...
if sys.version_info >= (3, 8):
def compress(data, compresslevel: int = ..., *, mtime: Optional[float] = ...) -> bytes: ...
def compress(data: bytes, compresslevel: int = ..., *, mtime: Optional[float] = ...) -> bytes: ...
else:
def compress(data, compresslevel: int = ...) -> bytes: ...
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
def decompress(data: bytes) -> bytes: ...

View File

@@ -84,7 +84,7 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
def max_prefixlen(self) -> int: ...
@property
def num_addresses(self) -> int: ...
def overlaps(self, other: _BaseNetwork) -> bool: ...
def overlaps(self, other: _BaseNetwork[_A]) -> bool: ...
@property
def prefixlen(self) -> int: ...
if sys.version_info >= (3, 7):

View File

@@ -326,5 +326,5 @@ if sys.version_info >= (3, 9):
__origin__: type
__args__: Tuple[Any, ...]
__parameters__: Tuple[Any, ...]
def __init__(self, origin: type, args: Any): ...
def __init__(self, origin: type, args: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ... # incomplete

View File

@@ -46,5 +46,5 @@ def makeSuite(
suiteClass: _SuiteClass = ...,
) -> unittest.suite.TestSuite: ...
def findTestCases(
module, prefix: str = ..., sortUsing: _SortComparisonMethod = ..., suiteClass: _SuiteClass = ...
module: ModuleType, prefix: str = ..., sortUsing: _SortComparisonMethod = ..., suiteClass: _SuiteClass = ...
) -> unittest.suite.TestSuite: ...

View File

@@ -1,4 +1,4 @@
from typing import Union
from typing import IO, Mapping, Union
from urllib.response import addinfourl
# Stubs for urllib.error
@@ -8,6 +8,6 @@ class URLError(IOError):
class HTTPError(URLError, addinfourl):
code: int
def __init__(self, url, code, msg, hdrs, fp) -> None: ...
def __init__(self, url: str, code: int, msg: str, hdrs: Mapping[str, str], fp: IO[bytes]) -> None: ...
class ContentTooShortError(URLError): ...

View File

@@ -191,8 +191,8 @@ class UnknownHandler(BaseHandler):
def unknown_open(self, req: Request) -> NoReturn: ...
class HTTPErrorProcessor(BaseHandler):
def http_response(self, request, response) -> _UrlopenRet: ...
def https_response(self, request, response) -> _UrlopenRet: ...
def http_response(self, request: Request, response: HTTPResponse) -> _UrlopenRet: ...
def https_response(self, request: Request, response: HTTPResponse) -> _UrlopenRet: ...
if sys.version_info >= (3, 6):
def urlretrieve(

View File

@@ -4,7 +4,7 @@ from typing import Any, Optional, Tuple, Type, Union
_KeyType = Union[HKEYType, int]
def CloseKey(__hkey: _KeyType): ...
def CloseKey(__hkey: _KeyType) -> None: ...
def ConnectRegistry(__computer_name: Optional[str], __key: _KeyType) -> HKEYType: ...
def CreateKey(__key: _KeyType, __sub_key: Optional[str]) -> HKEYType: ...
def CreateKeyEx(key: _KeyType, sub_key: Optional[str], reserved: int = ..., access: int = ...) -> HKEYType: ...

View File

@@ -60,7 +60,7 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented
class DateTime:
value: str # undocumented
def __init__(self, value: Union[int, str, datetime, time.struct_time, Tuple[int, ...]] = ...): ...
def __init__(self, value: Union[int, str, datetime, time.struct_time, Tuple[int, ...]] = ...) -> None: ...
def __lt__(self, other: _DateTimeComparable) -> bool: ...
def __le__(self, other: _DateTimeComparable) -> bool: ...
def __gt__(self, other: _DateTimeComparable) -> bool: ...
@@ -268,7 +268,7 @@ class ServerProxy:
if sys.version_info >= (3, 8):
def __init__(
self,
uri,
uri: str,
transport: Optional[Transport] = ...,
encoding: Optional[str] = ...,
verbose: bool = ...,
@@ -282,7 +282,7 @@ class ServerProxy:
else:
def __init__(
self,
uri,
uri: str,
transport: Optional[Transport] = ...,
encoding: Optional[str] = ...,
verbose: bool = ...,