Added missing type annotations in various stdlib stubs. (#4402)

Co-authored-by: Eric Traut <erictr@microsoft.com>
This commit is contained in:
Eric Traut
2020-08-06 18:27:21 -07:00
committed by GitHub
parent 10a5b070ab
commit baaffed1ac
7 changed files with 43 additions and 42 deletions

View File

@@ -3,6 +3,7 @@ import sys
import time
from socket import socket as _socket
from ssl import SSLContext, SSLSocket
from types import TracebackType
from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Text, Tuple, Type, Union
from typing_extensions import Literal
@@ -60,7 +61,7 @@ class IMAP4:
if sys.version_info >= (3, 5):
def enable(self, capability: str) -> _CommandResults: ...
def __enter__(self) -> IMAP4: ...
def __exit__(self, *args) -> None: ...
def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ...
def expunge(self) -> _CommandResults: ...
def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ...
def getacl(self, mailbox: str) -> _CommandResults: ...

View File

@@ -100,7 +100,7 @@ class HTMLDoc(Doc):
marginalia: Optional[str] = ...,
gap: str = ...,
) -> str: ...
def bigsection(self, title: str, *args) -> str: ...
def bigsection(self, title: str, *args: Any) -> str: ...
def preformat(self, text: str) -> str: ...
def multicolumn(self, list: List[Any], format: Callable[[Any], str], cols: int = ...) -> str: ...
def grey(self, text: str) -> str: ...
@@ -119,7 +119,7 @@ class HTMLDoc(Doc):
def formattree(
self, tree: List[Union[Tuple[type, Tuple[type, ...]], List[Any]]], modname: str, parent: Optional[type] = ...
) -> str: ...
def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored) -> str: ...
def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored: Any) -> str: ...
def docclass(
self,
object: object,
@@ -127,7 +127,7 @@ class HTMLDoc(Doc):
mod: Optional[str] = ...,
funcs: Mapping[str, str] = ...,
classes: Mapping[str, str] = ...,
*ignored,
*ignored: Any,
) -> str: ...
def formatvalue(self, object: object) -> str: ...
def docroutine(
@@ -139,14 +139,14 @@ class HTMLDoc(Doc):
classes: Mapping[str, str] = ...,
methods: Mapping[str, str] = ...,
cl: Optional[type] = ...,
*ignored,
*ignored: Any,
) -> str: ...
def docproperty(
self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored
self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored: Any
) -> str: ...
def docother(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored) -> str: ...
def docother(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored: Any) -> str: ...
def docdata(
self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored
self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored: Any
) -> str: ...
def index(self, dir: str, shadowed: Optional[MutableMapping[str, bool]] = ...) -> str: ...
def filelink(self, url: str, path: str) -> str: ...
@@ -175,17 +175,17 @@ class TextDoc(Doc):
parent: Optional[type] = ...,
prefix: str = ...,
) -> str: ...
def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored) -> str: ...
def docclass(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored) -> str: ...
def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored: Any) -> str: ...
def docclass(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored: Any) -> str: ...
def formatvalue(self, object: object) -> str: ...
def docroutine(
self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored
self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored: Any
) -> str: ...
def docproperty(
self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored
self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored: Any
) -> str: ...
def docdata(
self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored
self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored: Any
) -> str: ...
def docother(
self,
@@ -195,7 +195,7 @@ class TextDoc(Doc):
parent: Optional[str] = ...,
maxlen: Optional[int] = ...,
doc: Optional[Any] = ...,
*ignored,
*ignored: Any,
) -> str: ...
def pager(text: str) -> None: ...

View File

@@ -15,9 +15,9 @@ Date = date
Time = time
Timestamp = datetime
def DateFromTicks(ticks): ...
def TimeFromTicks(ticks): ...
def TimestampFromTicks(ticks): ...
def DateFromTicks(ticks: float) -> Date: ...
def TimeFromTicks(ticks: float) -> Time: ...
def TimestampFromTicks(ticks: float) -> Timestamp: ...
version_info: str
sqlite_version_info: Tuple[int, int, int]
@@ -26,8 +26,6 @@ if sys.version_info >= (3,):
else:
Binary = buffer
def register_adapters_and_converters(): ...
# The remaining definitions are imported from _sqlite3.
PARSE_COLNAMES: int
@@ -134,7 +132,7 @@ class Connection(object):
row_factory: Any
text_factory: Any
total_changes: Any
def __init__(self, *args, **kwargs): ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def close(self) -> None: ...
def commit(self) -> None: ...
def create_aggregate(self, name: str, num_params: int, aggregate_class: type) -> None: ...
@@ -148,16 +146,16 @@ class Connection(object):
# TODO: please check in executemany() if seq_of_parameters type is possible like this
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ...
def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
def interrupt(self, *args, **kwargs) -> None: ...
def iterdump(self, *args, **kwargs) -> Generator[str, None, None]: ...
def rollback(self, *args, **kwargs) -> None: ...
def interrupt(self, *args: Any, **kwargs: Any) -> None: ...
def iterdump(self, *args: Any, **kwargs: Any) -> Generator[str, None, None]: ...
def rollback(self, *args: Any, **kwargs: Any) -> None: ...
# TODO: set_authorizer(authorzer_callback)
# see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_authorizer
# returns [SQLITE_OK, SQLITE_DENY, SQLITE_IGNORE] so perhaps int
def set_authorizer(self, *args, **kwargs) -> None: ...
def set_authorizer(self, *args: Any, **kwargs: Any) -> None: ...
# set_progress_handler(handler, n) -> see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_progress_handler
def set_progress_handler(self, *args, **kwargs) -> None: ...
def set_trace_callback(self, *args, **kwargs): ...
def set_progress_handler(self, *args: Any, **kwargs: Any) -> None: ...
def set_trace_callback(self, *args: Any, **kwargs: Any) -> None: ...
# enable_load_extension and load_extension is not available on python distributions compiled
# without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1
def enable_load_extension(self, enabled: bool) -> None: ...
@@ -172,9 +170,9 @@ class Connection(object):
name: str = ...,
sleep: float = ...,
) -> None: ...
def __call__(self, *args, **kwargs): ...
def __enter__(self, *args, **kwargs) -> Connection: ...
def __exit__(self, *args, **kwargs): ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __enter__(self) -> Connection: ...
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> None: ...
class Cursor(Iterator[Any]):
arraysize: Any
@@ -186,16 +184,16 @@ class Cursor(Iterator[Any]):
# TODO: Cursor class accepts exactly 1 argument
# required type is sqlite3.Connection (which is imported as _Connection)
# however, the name of the __init__ variable is unknown
def __init__(self, *args, **kwargs) -> None: ...
def close(self, *args, **kwargs) -> None: ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def close(self, *args: Any, **kwargs: Any) -> None: ...
def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ...
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ...
def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
def fetchall(self) -> List[Any]: ...
def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ...
def fetchone(self) -> Any: ...
def setinputsizes(self, *args, **kwargs) -> None: ...
def setoutputsize(self, *args, **kwargs) -> None: ...
def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ...
def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ...
def __iter__(self) -> Cursor: ...
if sys.version_info >= (3, 0):
def __next__(self) -> Any: ...
@@ -280,13 +278,13 @@ else:
def __rmul__(self, other): ...
class PrepareProtocol(object):
def __init__(self, *args, **kwargs): ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class ProgrammingError(DatabaseError): ...
class Row(object):
def __init__(self, *args, **kwargs): ...
def keys(self, *args, **kwargs): ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def keys(self, *args: Any, **kwargs: Any): ...
def __eq__(self, other): ...
def __ge__(self, other): ...
def __getitem__(self, index): ...
@@ -294,7 +292,7 @@ class Row(object):
def __hash__(self): ...
def __iter__(self): ...
def __le__(self, other): ...
def __len__(self, *args, **kwargs): ...
def __len__(self, *args: Any, **kwargs: Any): ...
def __lt__(self, other): ...
def __ne__(self, other): ...

View File

@@ -1,3 +1,5 @@
from typing import Any
class Node:
ELEMENT_NODE: int
ATTRIBUTE_NODE: int
@@ -32,7 +34,7 @@ VALIDATION_ERR: int
class DOMException(Exception):
code: int
def __init__(self, *args, **kw) -> None: ...
def __init__(self, *args: Any, **kw: Any) -> None: ...
def _get_code(self) -> int: ...
class IndexSizeErr(DOMException): ...

View File

@@ -1,7 +1,7 @@
import os
import typing
from datetime import tzinfo
from typing import Any, Iterable, Optional, Protocol, Sequence, Set, Type, Union
from typing import Any, AnyStr, Iterable, Optional, Protocol, Sequence, Set, Type, Union
_T = typing.TypeVar("_T", bound="ZoneInfo")
@@ -23,7 +23,7 @@ class ZoneInfo(tzinfo):
# Note: Both here and in clear_cache, the types allow the use of `str` where
# a sequence of strings is required. This should be remedied if a solution
# to this typing bug is found: https://github.com/python/typing/issues/256
def reset_tzpath(to: Optional[Sequence[Union[os.PathLike, str]]] = ...) -> None: ...
def reset_tzpath(to: Optional[Sequence[Union[os.PathLike[AnyStr], str]]] = ...) -> None: ...
def available_timezones() -> Set[str]: ...
TZPATH: Sequence[str]

View File

@@ -13,7 +13,7 @@ class JSONDecoder:
object_hook: Callable[[Dict[str, Any]], Any]
parse_float: Callable[[str], Any]
parse_int: Callable[[str], Any]
parse_constant = ... # Callable[[str], Any]
parse_constant: Callable[[str], Any] = ...
strict: bool
object_pairs_hook: Callable[[List[Tuple[str, Any]]], Any]

View File

@@ -11,7 +11,7 @@ _Number = TypeVar("_Number", float, Decimal, Fraction)
# Used in median_high, median_low
class _Sortable(Protocol):
def __lt__(self, other) -> bool: ...
def __lt__(self, other: Any) -> bool: ...
_SortableT = TypeVar("_SortableT", bound=_Sortable)