diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index ecaaf42076f3..433bfdfa0833 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -53,30 +53,30 @@ class object: def __getattribute__(self, name: str) -> Any: ... def __delattr__(self, name: str) -> None: ... def __sizeof__(self) -> int: ... - def __reduce__(self) -> tuple: ... - def __reduce_ex__(self, protocol: int) -> tuple: ... + def __reduce__(self) -> Tuple[Any, ...]: ... + def __reduce_ex__(self, protocol: int) -> Tuple[Any, ...]: ... if sys.version_info >= (3,): def __dir__(self) -> Iterable[str]: ... if sys.version_info >= (3, 6): def __init_subclass__(cls) -> None: ... class staticmethod(object): # Special, only valid as a decorator. - __func__: Callable + __func__: Callable[..., Any] if sys.version_info >= (3,): __isabstractmethod__: bool - def __init__(self, f: Callable) -> None: ... + def __init__(self, f: Callable[..., Any]) -> None: ... def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ... + def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ... class classmethod(object): # Special, only valid as a decorator. - __func__: Callable + __func__: Callable[..., Any] if sys.version_info >= (3,): __isabstractmethod__: bool - def __init__(self, f: Callable) -> None: ... + def __init__(self, f: Callable[..., Any]) -> None: ... def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ... + def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ... class type(object): __base__: type @@ -1130,7 +1130,7 @@ if sys.version_info >= (3, 6): # See https://github.com/python/typeshed/pull/991#issuecomment-288160993 class _PathLike(Generic[AnyStr]): def __fspath__(self) -> AnyStr: ... - def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ... + def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike[Any]], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ... elif sys.version_info >= (3,): def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ... else: @@ -1187,8 +1187,8 @@ else: def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: _T) -> Iterator[_T]: ... -def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ... -def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ... +def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... def len(__o: Sized) -> int: ... if sys.version_info >= (3,): def license() -> None: ... @@ -1324,7 +1324,7 @@ def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(__i: Union[int, _SupportsIndex]) -> str: ... if sys.version_info >= (3, 6): - def open(file: Union[str, bytes, int, _PathLike], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., + def open(file: Union[str, bytes, int, _PathLike[Any]], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ..., opener: Optional[Callable[[str, int], int]] = ...) -> IO[Any]: ... elif sys.version_info >= (3,): diff --git a/stdlib/2and3/_weakrefset.pyi b/stdlib/2and3/_weakrefset.pyi index 950d3fe64265..f7dc56ec3295 100644 --- a/stdlib/2and3/_weakrefset.pyi +++ b/stdlib/2and3/_weakrefset.pyi @@ -2,7 +2,7 @@ from typing import Iterator, Any, Iterable, MutableSet, Optional, TypeVar, Gener _S = TypeVar('_S') _T = TypeVar('_T') -_SelfT = TypeVar('_SelfT', bound=WeakSet) +_SelfT = TypeVar('_SelfT', bound=WeakSet[Any]) class WeakSet(MutableSet[_T], Generic[_T]): def __init__(self, data: Optional[Iterable[_T]] = ...) -> None: ... diff --git a/stdlib/2and3/asyncore.pyi b/stdlib/2and3/asyncore.pyi index 8dc8f477543f..a7fb59c84644 100644 --- a/stdlib/2and3/asyncore.pyi +++ b/stdlib/2and3/asyncore.pyi @@ -50,8 +50,8 @@ class dispatcher: def readable(self) -> bool: ... def writable(self) -> bool: ... def listen(self, backlog: int) -> None: ... - def bind(self, address: Union[tuple, str]) -> None: ... - def connect(self, address: Union[tuple, str]) -> None: ... + def bind(self, address: Union[Tuple[Any, ...], str]) -> None: ... + def connect(self, address: Union[Tuple[Any, ...], str]) -> None: ... def accept(self) -> Optional[Tuple[SocketType, Any]]: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... @@ -103,7 +103,7 @@ class dispatcher: def recvfrom_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ... def recv_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ... def sendall(self, data: bytes, flags: int = ...) -> None: ... - def sendto(self, data: bytes, address: Union[tuple, str], flags: int = ...) -> int: ... + def sendto(self, data: bytes, address: Union[Tuple[str, int], str], flags: int = ...) -> int: ... def setblocking(self, flag: bool) -> None: ... def settimeout(self, value: Union[float, None]) -> None: ... def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... diff --git a/stdlib/2and3/bisect.pyi b/stdlib/2and3/bisect.pyi index 04229284f71a..c3075297c394 100644 --- a/stdlib/2and3/bisect.pyi +++ b/stdlib/2and3/bisect.pyi @@ -4,19 +4,10 @@ from typing import Any, Sequence, MutableSequence, TypeVar _T = TypeVar('_T') -# TODO uncomment when mypy# 2035 is fixed -# def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... -# def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... -# def bisect(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... -# -# def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... -# def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... -# def insort(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... +def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... +def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... +def bisect(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... -def bisect_left(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ... -def bisect_right(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ... -def bisect(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ... - -def insort_left(a: MutableSequence, x: Any, lo: int = ..., hi: int = ...) -> int: ... -def insort_right(a: MutableSequence, x: Any, lo: int = ..., hi: int = ...) -> int: ... -def insort(a: MutableSequence, x: Any, lo: int = ..., hi: int = ...) -> int: ... +def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... +def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... +def insort(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index ecaaf42076f3..433bfdfa0833 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -53,30 +53,30 @@ class object: def __getattribute__(self, name: str) -> Any: ... def __delattr__(self, name: str) -> None: ... def __sizeof__(self) -> int: ... - def __reduce__(self) -> tuple: ... - def __reduce_ex__(self, protocol: int) -> tuple: ... + def __reduce__(self) -> Tuple[Any, ...]: ... + def __reduce_ex__(self, protocol: int) -> Tuple[Any, ...]: ... if sys.version_info >= (3,): def __dir__(self) -> Iterable[str]: ... if sys.version_info >= (3, 6): def __init_subclass__(cls) -> None: ... class staticmethod(object): # Special, only valid as a decorator. - __func__: Callable + __func__: Callable[..., Any] if sys.version_info >= (3,): __isabstractmethod__: bool - def __init__(self, f: Callable) -> None: ... + def __init__(self, f: Callable[..., Any]) -> None: ... def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ... + def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ... class classmethod(object): # Special, only valid as a decorator. - __func__: Callable + __func__: Callable[..., Any] if sys.version_info >= (3,): __isabstractmethod__: bool - def __init__(self, f: Callable) -> None: ... + def __init__(self, f: Callable[..., Any]) -> None: ... def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ... + def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ... class type(object): __base__: type @@ -1130,7 +1130,7 @@ if sys.version_info >= (3, 6): # See https://github.com/python/typeshed/pull/991#issuecomment-288160993 class _PathLike(Generic[AnyStr]): def __fspath__(self) -> AnyStr: ... - def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ... + def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike[Any]], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ... elif sys.version_info >= (3,): def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ... else: @@ -1187,8 +1187,8 @@ else: def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: _T) -> Iterator[_T]: ... -def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ... -def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ... +def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... def len(__o: Sized) -> int: ... if sys.version_info >= (3,): def license() -> None: ... @@ -1324,7 +1324,7 @@ def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(__i: Union[int, _SupportsIndex]) -> str: ... if sys.version_info >= (3, 6): - def open(file: Union[str, bytes, int, _PathLike], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., + def open(file: Union[str, bytes, int, _PathLike[Any]], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ..., opener: Optional[Callable[[str, int], int]] = ...) -> IO[Any]: ... elif sys.version_info >= (3,): diff --git a/stdlib/2and3/cgi.pyi b/stdlib/2and3/cgi.pyi index 02979c090f20..0f580ccfce7f 100644 --- a/stdlib/2and3/cgi.pyi +++ b/stdlib/2and3/cgi.pyi @@ -101,7 +101,7 @@ class FieldStorage(object): if sys.version_info < (3, 0): from UserDict import UserDict - class FormContentDict(UserDict): + class FormContentDict(UserDict[str, List[str]]): query_string: str def __init__(self, environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ... diff --git a/stdlib/2and3/contextlib.pyi b/stdlib/2and3/contextlib.pyi index ab11501403b9..2832d94b8518 100644 --- a/stdlib/2and3/contextlib.pyi +++ b/stdlib/2and3/contextlib.pyi @@ -23,7 +23,7 @@ _F = TypeVar('_F', bound=Callable[..., Any]) _ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] -_CM_EF = TypeVar('_CM_EF', ContextManager, _ExitFunc) +_CM_EF = TypeVar('_CM_EF', ContextManager[Any], _ExitFunc) if sys.version_info >= (3, 2): class _GeneratorContextManager(ContextManager[_T], Generic[_T]): @@ -85,7 +85,7 @@ if sys.version_info >= (3, 7): Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] _CallbackCoroFunc = Callable[..., Awaitable[Any]] - _ACM_EF = TypeVar('_ACM_EF', AsyncContextManager, _ExitCoroFunc) + _ACM_EF = TypeVar('_ACM_EF', AsyncContextManager[Any], _ExitCoroFunc) class AsyncExitStack(AsyncContextManager[AsyncExitStack]): def __init__(self) -> None: ... diff --git a/stdlib/2and3/formatter.pyi b/stdlib/2and3/formatter.pyi index 77a4956260ed..b11ce7e56293 100644 --- a/stdlib/2and3/formatter.pyi +++ b/stdlib/2and3/formatter.pyi @@ -92,9 +92,9 @@ class AbstractWriter(NullWriter): def send_literal_data(self, data: str) -> None: ... class DumbWriter(NullWriter): - file: IO + file: IO[str] maxcol: int - def __init__(self, file: Optional[IO] = ..., maxcol: int = ...) -> None: ... + def __init__(self, file: Optional[IO[str]] = ..., maxcol: int = ...) -> None: ... def reset(self) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... diff --git a/stdlib/2and3/imaplib.pyi b/stdlib/2and3/imaplib.pyi index ab32e7bac31f..1653ae344a26 100644 --- a/stdlib/2and3/imaplib.pyi +++ b/stdlib/2and3/imaplib.pyi @@ -44,7 +44,7 @@ class IMAP4: def recent(self) -> CommandResults: ... def response(self, code: str) -> CommandResults: ... def append(self, mailbox: str, flags: str, date_time: str, message: str) -> str: ... - def authenticate(self, mechanism: str, authobject: Callable) -> Tuple[str, str]: ... + def authenticate(self, mechanism: str, authobject: Callable[[bytes], Optional[bytes]]) -> Tuple[str, str]: ... def capability(self) -> CommandResults: ... def check(self) -> CommandResults: ... def close(self) -> CommandResults: ... @@ -111,7 +111,7 @@ class IMAP4_stream(IMAP4): port: int = ... sock: _socket = ... file: IO[Any] = ... - process: subprocess.Popen = ... + process: subprocess.Popen[bytes] = ... writefile: IO[Any] = ... readfile: IO[Any] = ... def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... @@ -121,8 +121,8 @@ class IMAP4_stream(IMAP4): def shutdown(self) -> None: ... class _Authenticator: - mech: Callable = ... - def __init__(self, mechinst: Callable) -> None: ... + mech: Callable[[bytes], bytes] = ... + def __init__(self, mechinst: Callable[[bytes], bytes]) -> None: ... def process(self, data: str) -> str: ... def encode(self, inp: bytes) -> str: ... def decode(self, inp: str) -> bytes: ... diff --git a/stdlib/2and3/lib2to3/pgen2/literals.pyi b/stdlib/2and3/lib2to3/pgen2/literals.pyi index 8719500dadd0..3166ffbf304c 100644 --- a/stdlib/2and3/lib2to3/pgen2/literals.pyi +++ b/stdlib/2and3/lib2to3/pgen2/literals.pyi @@ -4,6 +4,6 @@ from typing import Dict, Match, Text simple_escapes: Dict[Text, Text] -def escape(m: Match) -> Text: ... +def escape(m: Match[str]) -> Text: ... def evalString(s: Text) -> Text: ... def test() -> None: ... diff --git a/stdlib/2and3/logging/__init__.pyi b/stdlib/2and3/logging/__init__.pyi index 32b2f117db8b..d95cf50e1ef4 100644 --- a/stdlib/2and3/logging/__init__.pyi +++ b/stdlib/2and3/logging/__init__.pyi @@ -39,7 +39,7 @@ if sys.version_info >= (3,): _levelToName: Dict[int, str] _nameToLevel: Dict[str, int] else: - _levelNames: dict + _levelNames: Dict[Union[int, str], Union[str, int]] # Union[int:str, str:int] class Filterer(object): filters: List[Filter] diff --git a/stdlib/2and3/logging/handlers.pyi b/stdlib/2and3/logging/handlers.pyi index 00a27c923b54..5b923ea8d5b5 100644 --- a/stdlib/2and3/logging/handlers.pyi +++ b/stdlib/2and3/logging/handlers.pyi @@ -198,19 +198,19 @@ class HTTPHandler(Handler): if sys.version_info >= (3,): class QueueHandler(Handler): if sys.version_info >= (3, 7): - def __init__(self, queue: Union[SimpleQueue, Queue]) -> None: ... + def __init__(self, queue: Union[SimpleQueue[Any], Queue[Any]]) -> None: ... else: - def __init__(self, queue: Queue) -> None: ... + def __init__(self, queue: Queue[Any]) -> None: ... def prepare(self, record: LogRecord) -> Any: ... def enqueue(self, record: LogRecord) -> None: ... class QueueListener: if sys.version_info >= (3, 7): - def __init__(self, queue: Union[SimpleQueue, Queue], + def __init__(self, queue: Union[SimpleQueue[Any], Queue[Any]], *handlers: Handler, respect_handler_level: bool = ...) -> None: ... elif sys.version_info >= (3, 5): - def __init__(self, queue: Queue, *handlers: Handler, + def __init__(self, queue: Queue[Any], *handlers: Handler, respect_handler_level: bool = ...) -> None: ... else: def __init__(self, diff --git a/stdlib/2and3/math.pyi b/stdlib/2and3/math.pyi index 25eb1c4ba127..b3b8579280cf 100644 --- a/stdlib/2and3/math.pyi +++ b/stdlib/2and3/math.pyi @@ -40,7 +40,7 @@ else: def floor(x: SupportsFloat) -> float: ... def fmod(x: SupportsFloat, y: SupportsFloat) -> float: ... def frexp(x: SupportsFloat) -> Tuple[float, int]: ... -def fsum(iterable: Iterable) -> float: ... +def fsum(iterable: Iterable[float]) -> float: ... def gamma(x: SupportsFloat) -> float: ... if sys.version_info >= (3, 5): def gcd(a: int, b: int) -> int: ... diff --git a/stdlib/2and3/mmap.pyi b/stdlib/2and3/mmap.pyi index 709d5d93f291..b8d040e9cf30 100644 --- a/stdlib/2and3/mmap.pyi +++ b/stdlib/2and3/mmap.pyi @@ -49,7 +49,7 @@ class _mmap(Generic[AnyStr]): def __len__(self) -> int: ... if sys.version_info >= (3,): - class mmap(_mmap, ContextManager[mmap], Iterable[bytes], Sized): + class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], Sized): closed: bool def rfind(self, sub: bytes, start: int = ..., stop: int = ...) -> int: ... @overload @@ -65,7 +65,7 @@ if sys.version_info >= (3,): # __len__, so we claim that there is also an __iter__ to help type checkers. def __iter__(self) -> Iterator[bytes]: ... else: - class mmap(_mmap, Sequence[bytes]): + class mmap(_mmap[bytes], Sequence[bytes]): def rfind(self, string: bytes, start: int = ..., stop: int = ...) -> int: ... def __getitem__(self, index: Union[int, slice]) -> bytes: ... def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... diff --git a/stdlib/2and3/operator.pyi b/stdlib/2and3/operator.pyi index eafc37cb36b9..3a70b47e9391 100644 --- a/stdlib/2and3/operator.pyi +++ b/stdlib/2and3/operator.pyi @@ -34,8 +34,8 @@ def is_(a: Any, b: Any) -> bool: ... def is_not(a: Any, b: Any) -> bool: ... -def abs(x: SupportsAbs) -> Any: ... -def __abs__(a: SupportsAbs) -> Any: ... +def abs(x: SupportsAbs[_T]) -> _T: ... +def __abs__(a: SupportsAbs[_T]) -> _T: ... def add(a: Any, b: Any) -> Any: ... def __add__(a: Any, b: Any) -> Any: ... diff --git a/stdlib/2and3/optparse.pyi b/stdlib/2and3/optparse.pyi index 9b8b8eac568c..e3fe3142a254 100644 --- a/stdlib/2and3/optparse.pyi +++ b/stdlib/2and3/optparse.pyi @@ -92,12 +92,12 @@ class Option: ACTIONS: Tuple[_Text, ...] ALWAYS_TYPED_ACTIONS: Tuple[_Text, ...] ATTRS: List[_Text] - CHECK_METHODS: Optional[List[Callable]] + CHECK_METHODS: Optional[List[Callable[..., Any]]] CONST_ACTIONS: Tuple[_Text, ...] STORE_ACTIONS: Tuple[_Text, ...] TYPED_ACTIONS: Tuple[_Text, ...] TYPES: Tuple[_Text, ...] - TYPE_CHECKER: Dict[_Text, Callable] + TYPE_CHECKER: Dict[_Text, Callable[..., Any]] _long_opts: List[_Text] _short_opts: List[_Text] action: _Text @@ -196,13 +196,13 @@ class OptionParser(OptionContainer): def _add_version_option(self) -> None: ... def _create_option_list(self) -> None: ... def _get_all_options(self) -> List[Option]: ... - def _get_args(self, args: Iterable) -> List[Any]: ... + def _get_args(self, args: Iterable[Any]) -> List[Any]: ... def _init_parsing_state(self) -> None: ... def _match_long_opt(self, opt: _Text) -> _Text: ... def _populate_option_list(self, option_list: Iterable[Option], add_help: bool = ...) -> None: ... - def _process_args(self, largs: List, rargs: List, values: Values) -> None: ... - def _process_long_opt(self, rargs: List, values: Any) -> None: ... - def _process_short_opts(self, rargs: List, values: Any) -> None: ... + def _process_args(self, largs: List[Any], rargs: List[Any], values: Values) -> None: ... + def _process_long_opt(self, rargs: List[Any], values: Any) -> None: ... + def _process_short_opts(self, rargs: List[Any], values: Any) -> None: ... def add_option_group(self, *args, **kwargs) -> OptionParser: ... def check_values(self, values: Values, args: List[_Text]) -> Tuple[Values, List[_Text]]: ... def disable_interspersed_args(self) -> None: ... diff --git a/stdlib/2and3/pickle.pyi b/stdlib/2and3/pickle.pyi index 7bfad8f3bf1b..e0222324cb20 100644 --- a/stdlib/2and3/pickle.pyi +++ b/stdlib/2and3/pickle.pyi @@ -26,11 +26,11 @@ class PicklingError(PickleError): ... class UnpicklingError(PickleError): ... _reducedtype = Union[str, - Tuple[Callable[..., Any], Tuple], - Tuple[Callable[..., Any], Tuple, Any], - Tuple[Callable[..., Any], Tuple, Any, + Tuple[Callable[..., Any], Tuple[Any, ...]], + Tuple[Callable[..., Any], Tuple[Any, ...], Any], + Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator]], - Tuple[Callable[..., Any], Tuple, Any, + Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator], Optional[Iterator]]] diff --git a/stdlib/2and3/plistlib.pyi b/stdlib/2and3/plistlib.pyi index ad5d51dff150..532be815ebd9 100644 --- a/stdlib/2and3/plistlib.pyi +++ b/stdlib/2and3/plistlib.pyi @@ -47,7 +47,7 @@ if sys.version_info < (3,): def writePlistToString(rootObject: Mapping[str, Any]) -> str: ... if sys.version_info < (3, 7): - class Dict(dict): + class Dict(DictT[str, Any]): def __getattr__(self, attr: str) -> Any: ... def __setattr__(self, attr: str, value: Any) -> None: ... def __delattr__(self, attr: str) -> None: ... diff --git a/stdlib/2and3/pydoc.pyi b/stdlib/2and3/pydoc.pyi index 1150741bd205..6a2385055695 100644 --- a/stdlib/2and3/pydoc.pyi +++ b/stdlib/2and3/pydoc.pyi @@ -81,7 +81,7 @@ class HTMLDoc(Doc): def modulelink(self, object: object) -> str: ... def modpkglink(self, data: Tuple[str, str, bool, bool]) -> str: ... def markup(self, text: str, escape: Optional[Callable[[str], str]] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ...) -> str: ... - def formattree(self, tree: List[Union[Tuple[type, Tuple[type, ...]], list]], modname: str, parent: Optional[type] = ...) -> str: ... + 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 docclass(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., *ignored) -> str: ... def formatvalue(self, object: object) -> str: ... @@ -108,7 +108,7 @@ class TextDoc(Doc): def bold(self, text: str) -> str: ... def indent(self, text: str, prefix: str = ...) -> str: ... def section(self, title: str, contents: str) -> str: ... - def formattree(self, tree: List[Union[Tuple[type, Tuple[type, ...]], list]], modname: str, parent: Optional[type] = ..., prefix: str = ...) -> str: ... + def formattree(self, tree: List[Union[Tuple[type, Tuple[type, ...]], List[Any]]], modname: str, 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 formatvalue(self, object: object) -> str: ... @@ -171,7 +171,7 @@ help: Helper class ModuleScanner: quit: bool - def run(self, callback: Callable[[Optional[str], str, str], None], key: Optional[Any] = ..., completer: Optional[Callable[[], None]] = ..., onerror: Optional[Callable] = ...) -> None: ... + def run(self, callback: Callable[[Optional[str], str, str], None], key: Optional[Any] = ..., completer: Optional[Callable[[], None]] = ..., onerror: Optional[Callable[[str], None]] = ...) -> None: ... def apropos(key: str) -> None: ... def serve(port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ...) -> None: ... diff --git a/stdlib/2and3/shutil.pyi b/stdlib/2and3/shutil.pyi index de1f8fcc8330..98761d046f76 100644 --- a/stdlib/2and3/shutil.pyi +++ b/stdlib/2and3/shutil.pyi @@ -73,15 +73,17 @@ else: def ignore_patterns(*patterns: _Path) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... if sys.version_info >= (3,): - _IgnoreFn = Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[_Path, List[str]], Iterable[str]]] def copytree(src: _Path, dst: _Path, symlinks: bool = ..., - ignore: _IgnoreFn = ..., + ignore: Union[None, + Callable[[str, List[str]], Iterable[str]], + Callable[[_Path, List[str]], Iterable[str]]] = ..., copy_function: Callable[[str, str], None] = ..., ignore_dangling_symlinks: bool = ...) -> _PathReturn: ... else: - _IgnoreFn = Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] def copytree(src: AnyStr, dst: AnyStr, symlinks: bool = ..., - ignore: _IgnoreFn = ...) -> _PathReturn: ... + ignore: Union[None, + Callable[[AnyStr, List[AnyStr]], + Iterable[AnyStr]]] = ...) -> _PathReturn: ... if sys.version_info >= (3,): @overload diff --git a/stdlib/2and3/socket.pyi b/stdlib/2and3/socket.pyi index 4d1916a58a4d..1a42632187a1 100644 --- a/stdlib/2and3/socket.pyi +++ b/stdlib/2and3/socket.pyi @@ -600,7 +600,7 @@ def gethostbyname(hostname: str) -> str: ... def gethostbyname_ex(hostname: str) -> Tuple[str, List[str], List[str]]: ... def gethostname() -> str: ... def gethostbyaddr(ip_address: str) -> Tuple[str, List[str], List[str]]: ... -def getnameinfo(sockaddr: tuple, flags: int) -> Tuple[str, int]: ... +def getnameinfo(sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int) -> Tuple[str, int]: ... def getprotobyname(protocolname: str) -> int: ... def getservbyname(servicename: str, protocolname: str = ...) -> int: ... def getservbyport(port: int, protocolname: str = ...) -> str: ... diff --git a/stdlib/2and3/sqlite3/dbapi2.pyi b/stdlib/2and3/sqlite3/dbapi2.pyi index 5b3d2a03ed1a..e338ebbe322b 100644 --- a/stdlib/2and3/sqlite3/dbapi2.pyi +++ b/stdlib/2and3/sqlite3/dbapi2.pyi @@ -130,9 +130,9 @@ class Connection(object): def create_collation(self, name: str, callable: Any) -> None: ... def create_function(self, name: str, num_params: int, func: Any) -> None: ... def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ... - def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... + def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this - def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]) -> Cursor: ... + 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) -> None: ... @@ -168,8 +168,8 @@ class Cursor(Iterator[Any]): # however, the name of the __init__ variable is unknown def __init__(self, *args, **kwargs) -> None: ... def close(self, *args, **kwargs) -> None: ... - def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... - def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]) -> Cursor: ... + 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]: ... diff --git a/stdlib/2and3/sre_compile.pyi b/stdlib/2and3/sre_compile.pyi index be39a314c84c..e6036e205454 100644 --- a/stdlib/2and3/sre_compile.pyi +++ b/stdlib/2and3/sre_compile.pyi @@ -15,4 +15,4 @@ else: _IsStringType = bool def isstring(obj: Any) -> _IsStringType: ... -def compile(p: Union[str, bytes, SubPattern], flags: int = ...) -> Pattern: ... +def compile(p: Union[str, bytes, SubPattern], flags: int = ...) -> Pattern[Any]: ... diff --git a/stdlib/2and3/threading.pyi b/stdlib/2and3/threading.pyi index b5d8f0d3569d..c8ed09611ec6 100644 --- a/stdlib/2and3/threading.pyi +++ b/stdlib/2and3/threading.pyi @@ -53,14 +53,14 @@ class Thread: def __init__(self, group: None = ..., target: Optional[Callable[..., Any]] = ..., name: Optional[str] = ..., - args: Iterable = ..., + args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ..., *, daemon: Optional[bool] = ...) -> None: ... else: def __init__(self, group: None = ..., target: Optional[Callable[..., Any]] = ..., name: Optional[str] = ..., - args: Iterable = ..., + args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ...) -> None: ... def start(self) -> None: ... def run(self) -> None: ... diff --git a/stdlib/2and3/traceback.pyi b/stdlib/2and3/traceback.pyi index cbefb62f020c..e6744007ace6 100644 --- a/stdlib/2and3/traceback.pyi +++ b/stdlib/2and3/traceback.pyi @@ -94,7 +94,7 @@ if sys.version_info >= (3, 5): def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ... def format_exception_only(self) -> Generator[str, None, None]: ... - class FrameSummary(Iterable): + class FrameSummary(Iterable[Any]): filename: str lineno: int name: str diff --git a/stdlib/2and3/xml/etree/ElementPath.pyi b/stdlib/2and3/xml/etree/ElementPath.pyi index 1477b329caf6..1250f0da42dd 100644 --- a/stdlib/2and3/xml/etree/ElementPath.pyi +++ b/stdlib/2and3/xml/etree/ElementPath.pyi @@ -3,7 +3,7 @@ from typing import Pattern, Dict, Generator, Tuple, List, Union, TypeVar, Callable, Optional from xml.etree.ElementTree import Element -xpath_tokenizer_re: Pattern +xpath_tokenizer_re: Pattern[str] _token = Tuple[str, str] _next = Callable[[], _token] diff --git a/stdlib/2and3/zipfile.pyi b/stdlib/2and3/zipfile.pyi index 8003cce68da0..a7737215d0dd 100644 --- a/stdlib/2and3/zipfile.pyi +++ b/stdlib/2and3/zipfile.pyi @@ -29,7 +29,7 @@ class ZipExtFile(io.BufferedIOBase): MIN_READ_SIZE: int = ... if sys.version_info < (3, 6): - PATTERN: Pattern = ... + PATTERN: Pattern[str] = ... if sys.version_info >= (3, 7): MAX_SEEK_READ: int = ...