diff --git a/mypy/test/testpep561.py b/mypy/test/testpep561.py index 97229b03ed22..dfe226643fd3 100644 --- a/mypy/test/testpep561.py +++ b/mypy/test/testpep561.py @@ -114,7 +114,7 @@ def test_pep561(testcase: DataDrivenTestCase) -> None: steps = testcase.find_steps() if steps != [[]]: - steps = [[]] + steps # type: ignore[operator,assignment] + steps = [[]] + steps # type: ignore[assignment] for i, operations in enumerate(steps): perform_file_operations(operations) diff --git a/mypy/typeshed/stdlib/@python2/BaseHTTPServer.pyi b/mypy/typeshed/stdlib/@python2/BaseHTTPServer.pyi deleted file mode 100644 index 9aad705bde6c..000000000000 --- a/mypy/typeshed/stdlib/@python2/BaseHTTPServer.pyi +++ /dev/null @@ -1,41 +0,0 @@ -import mimetools -import SocketServer -from typing import Any, BinaryIO, Callable, Mapping - -class HTTPServer(SocketServer.TCPServer): - server_name: str - server_port: int - def __init__(self, server_address: tuple[str, int], RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ... - -class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): - client_address: tuple[str, int] - server: SocketServer.BaseServer - close_connection: bool - command: str - path: str - request_version: str - headers: mimetools.Message - rfile: BinaryIO - wfile: BinaryIO - server_version: str - sys_version: str - error_message_format: str - error_content_type: str - protocol_version: str - MessageClass: type - responses: Mapping[int, tuple[str, str]] - def __init__(self, request: bytes, client_address: tuple[str, int], server: SocketServer.BaseServer) -> None: ... - def handle(self) -> None: ... - def handle_one_request(self) -> None: ... - def send_error(self, code: int, message: str | None = ...) -> None: ... - def send_response(self, code: int, message: str | None = ...) -> None: ... - def send_header(self, keyword: str, value: str) -> None: ... - def end_headers(self) -> None: ... - def flush_headers(self) -> None: ... - def log_request(self, code: int | str = ..., size: int | str = ...) -> None: ... - def log_error(self, format: str, *args: Any) -> None: ... - def log_message(self, format: str, *args: Any) -> None: ... - def version_string(self) -> str: ... - def date_time_string(self, timestamp: int | None = ...) -> str: ... - def log_date_time_string(self) -> str: ... - def address_string(self) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/CGIHTTPServer.pyi b/mypy/typeshed/stdlib/@python2/CGIHTTPServer.pyi deleted file mode 100644 index cc08bc02d666..000000000000 --- a/mypy/typeshed/stdlib/@python2/CGIHTTPServer.pyi +++ /dev/null @@ -1,5 +0,0 @@ -import SimpleHTTPServer - -class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): - cgi_directories: list[str] - def do_POST(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/ConfigParser.pyi b/mypy/typeshed/stdlib/@python2/ConfigParser.pyi deleted file mode 100644 index ebf2a434e596..000000000000 --- a/mypy/typeshed/stdlib/@python2/ConfigParser.pyi +++ /dev/null @@ -1,95 +0,0 @@ -from _typeshed import SupportsNoArgReadline -from typing import IO, Any, Sequence - -DEFAULTSECT: str -MAX_INTERPOLATION_DEPTH: int - -class Error(Exception): - message: Any - def __init__(self, msg: str = ...) -> None: ... - def _get_message(self) -> None: ... - def _set_message(self, value: str) -> None: ... - -class NoSectionError(Error): - section: str - def __init__(self, section: str) -> None: ... - -class DuplicateSectionError(Error): - section: str - def __init__(self, section: str) -> None: ... - -class NoOptionError(Error): - section: str - option: str - def __init__(self, option: str, section: str) -> None: ... - -class InterpolationError(Error): - section: str - option: str - msg: str - def __init__(self, option: str, section: str, msg: str) -> None: ... - -class InterpolationMissingOptionError(InterpolationError): - reference: str - def __init__(self, option: str, section: str, rawval: str, reference: str) -> None: ... - -class InterpolationSyntaxError(InterpolationError): ... - -class InterpolationDepthError(InterpolationError): - def __init__(self, option: str, section: str, rawval: str) -> None: ... - -class ParsingError(Error): - filename: str - errors: list[tuple[Any, Any]] - def __init__(self, filename: str) -> None: ... - def append(self, lineno: Any, line: Any) -> None: ... - -class MissingSectionHeaderError(ParsingError): - lineno: Any - line: Any - def __init__(self, filename: str, lineno: Any, line: Any) -> None: ... - -class RawConfigParser: - _dict: Any - _sections: dict[Any, Any] - _defaults: dict[Any, Any] - _optcre: Any - SECTCRE: Any - OPTCRE: Any - OPTCRE_NV: Any - def __init__(self, defaults: dict[Any, Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ... - def defaults(self) -> dict[Any, Any]: ... - def sections(self) -> list[str]: ... - def add_section(self, section: str) -> None: ... - def has_section(self, section: str) -> bool: ... - def options(self, section: str) -> list[str]: ... - def read(self, filenames: str | Sequence[str]) -> list[str]: ... - def readfp(self, fp: SupportsNoArgReadline[str], filename: str = ...) -> None: ... - def get(self, section: str, option: str) -> str: ... - def items(self, section: str) -> list[tuple[Any, Any]]: ... - def _get(self, section: str, conv: type, option: str) -> Any: ... - def getint(self, section: str, option: str) -> int: ... - def getfloat(self, section: str, option: str) -> float: ... - _boolean_states: dict[str, bool] - def getboolean(self, section: str, option: str) -> bool: ... - def optionxform(self, optionstr: str) -> str: ... - def has_option(self, section: str, option: str) -> bool: ... - def set(self, section: str, option: str, value: Any = ...) -> None: ... - def write(self, fp: IO[str]) -> None: ... - def remove_option(self, section: str, option: Any) -> bool: ... - def remove_section(self, section: str) -> bool: ... - def _read(self, fp: IO[str], fpname: str) -> None: ... - -class ConfigParser(RawConfigParser): - _KEYCRE: Any - def get(self, section: str, option: str, raw: bool = ..., vars: dict[Any, Any] | None = ...) -> Any: ... - def items(self, section: str, raw: bool = ..., vars: dict[Any, Any] | None = ...) -> list[tuple[str, Any]]: ... - def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ... - def _interpolation_replace(self, match: Any) -> str: ... - -class SafeConfigParser(ConfigParser): - _interpvar_re: Any - def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ... - def _interpolate_some( - self, option: str, accum: list[Any], rest: str, section: str, map: dict[Any, Any], depth: int - ) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/Cookie.pyi b/mypy/typeshed/stdlib/@python2/Cookie.pyi deleted file mode 100644 index dcc27a2d349d..000000000000 --- a/mypy/typeshed/stdlib/@python2/Cookie.pyi +++ /dev/null @@ -1,40 +0,0 @@ -from typing import Any - -class CookieError(Exception): ... - -class Morsel(dict[Any, Any]): - key: Any - def __init__(self): ... - def __setitem__(self, K, V): ... - def isReservedKey(self, K): ... - value: Any - coded_value: Any - def set(self, key, val, coded_val, LegalChars=..., idmap=..., translate=...): ... - def output(self, attrs: Any | None = ..., header=...): ... - def js_output(self, attrs: Any | None = ...): ... - def OutputString(self, attrs: Any | None = ...): ... - -class BaseCookie(dict[Any, Any]): - def value_decode(self, val): ... - def value_encode(self, val): ... - def __init__(self, input: Any | None = ...): ... - def __setitem__(self, key, value): ... - def output(self, attrs: Any | None = ..., header=..., sep=...): ... - def js_output(self, attrs: Any | None = ...): ... - def load(self, rawdata): ... - -class SimpleCookie(BaseCookie): - def value_decode(self, val): ... - def value_encode(self, val): ... - -class SerialCookie(BaseCookie): - def __init__(self, input: Any | None = ...): ... - def value_decode(self, val): ... - def value_encode(self, val): ... - -class SmartCookie(BaseCookie): - def __init__(self, input: Any | None = ...): ... - def value_decode(self, val): ... - def value_encode(self, val): ... - -Cookie: Any diff --git a/mypy/typeshed/stdlib/@python2/HTMLParser.pyi b/mypy/typeshed/stdlib/@python2/HTMLParser.pyi deleted file mode 100644 index 755f0d058b15..000000000000 --- a/mypy/typeshed/stdlib/@python2/HTMLParser.pyi +++ /dev/null @@ -1,28 +0,0 @@ -from typing import AnyStr - -from markupbase import ParserBase - -class HTMLParser(ParserBase): - def __init__(self) -> None: ... - def feed(self, feed: AnyStr) -> None: ... - def close(self) -> None: ... - def reset(self) -> None: ... - def get_starttag_text(self) -> AnyStr: ... - def set_cdata_mode(self, AnyStr) -> None: ... - def clear_cdata_mode(self) -> None: ... - def handle_startendtag(self, tag: AnyStr, attrs: list[tuple[AnyStr, AnyStr]]): ... - def handle_starttag(self, tag: AnyStr, attrs: list[tuple[AnyStr, AnyStr]]): ... - def handle_endtag(self, tag: AnyStr): ... - def handle_charref(self, name: AnyStr): ... - def handle_entityref(self, name: AnyStr): ... - def handle_data(self, data: AnyStr): ... - def handle_comment(self, data: AnyStr): ... - def handle_decl(self, decl: AnyStr): ... - def handle_pi(self, data: AnyStr): ... - def unknown_decl(self, data: AnyStr): ... - def unescape(self, s: AnyStr) -> AnyStr: ... - -class HTMLParseError(Exception): - msg: str - lineno: int - offset: int diff --git a/mypy/typeshed/stdlib/@python2/Queue.pyi b/mypy/typeshed/stdlib/@python2/Queue.pyi deleted file mode 100644 index a53380723188..000000000000 --- a/mypy/typeshed/stdlib/@python2/Queue.pyi +++ /dev/null @@ -1,29 +0,0 @@ -from collections import deque -from typing import Any, Generic, TypeVar - -_T = TypeVar("_T") - -class Empty(Exception): ... -class Full(Exception): ... - -class Queue(Generic[_T]): - maxsize: Any - mutex: Any - not_empty: Any - not_full: Any - all_tasks_done: Any - unfinished_tasks: Any - queue: deque[Any] # undocumented - def __init__(self, maxsize: int = ...) -> None: ... - def task_done(self) -> None: ... - def join(self) -> None: ... - def qsize(self) -> int: ... - def empty(self) -> bool: ... - def full(self) -> bool: ... - def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ... - def put_nowait(self, item: _T) -> None: ... - def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... - def get_nowait(self) -> _T: ... - -class PriorityQueue(Queue[_T]): ... -class LifoQueue(Queue[_T]): ... diff --git a/mypy/typeshed/stdlib/@python2/SimpleHTTPServer.pyi b/mypy/typeshed/stdlib/@python2/SimpleHTTPServer.pyi deleted file mode 100644 index 758d5bd6d515..000000000000 --- a/mypy/typeshed/stdlib/@python2/SimpleHTTPServer.pyi +++ /dev/null @@ -1,14 +0,0 @@ -import BaseHTTPServer -from StringIO import StringIO -from typing import IO, Any, AnyStr, Mapping - -class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): - server_version: str - def do_GET(self) -> None: ... - def do_HEAD(self) -> None: ... - def send_head(self) -> IO[str] | None: ... - def list_directory(self, path: str | unicode) -> StringIO[Any] | None: ... - def translate_path(self, path: AnyStr) -> AnyStr: ... - def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ... - def guess_type(self, path: str | unicode) -> str: ... - extensions_map: Mapping[str, str] diff --git a/mypy/typeshed/stdlib/@python2/SocketServer.pyi b/mypy/typeshed/stdlib/@python2/SocketServer.pyi deleted file mode 100644 index 545ee8464f16..000000000000 --- a/mypy/typeshed/stdlib/@python2/SocketServer.pyi +++ /dev/null @@ -1,115 +0,0 @@ -import sys -from socket import SocketType -from typing import Any, BinaryIO, Callable, ClassVar, Text - -class BaseServer: - address_family: int - RequestHandlerClass: Callable[..., BaseRequestHandler] - server_address: tuple[str, int] - socket: SocketType - allow_reuse_address: bool - request_queue_size: int - socket_type: int - timeout: float | None - def __init__(self, server_address: Any, RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ... - def fileno(self) -> int: ... - def handle_request(self) -> None: ... - def serve_forever(self, poll_interval: float = ...) -> None: ... - def shutdown(self) -> None: ... - def server_close(self) -> None: ... - def finish_request(self, request: bytes, client_address: tuple[str, int]) -> None: ... - def get_request(self) -> tuple[SocketType, tuple[str, int]]: ... - def handle_error(self, request: bytes, client_address: tuple[str, int]) -> None: ... - def handle_timeout(self) -> None: ... - def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ... - def server_activate(self) -> None: ... - def server_bind(self) -> None: ... - def verify_request(self, request: bytes, client_address: tuple[str, int]) -> bool: ... - -class TCPServer(BaseServer): - def __init__( - self, - server_address: tuple[str, int], - RequestHandlerClass: Callable[..., BaseRequestHandler], - bind_and_activate: bool = ..., - ) -> None: ... - -class UDPServer(BaseServer): - def __init__( - self, - server_address: tuple[str, int], - RequestHandlerClass: Callable[..., BaseRequestHandler], - bind_and_activate: bool = ..., - ) -> None: ... - -if sys.platform != "win32": - class UnixStreamServer(BaseServer): - def __init__( - self, - server_address: Text | bytes, - RequestHandlerClass: Callable[..., BaseRequestHandler], - bind_and_activate: bool = ..., - ) -> None: ... - - class UnixDatagramServer(BaseServer): - def __init__( - self, - server_address: Text | bytes, - RequestHandlerClass: Callable[..., BaseRequestHandler], - bind_and_activate: bool = ..., - ) -> None: ... - -if sys.platform != "win32": - class ForkingMixIn: - timeout: float | None # undocumented - active_children: list[int] | None # undocumented - max_children: int # undocumented - def collect_children(self) -> None: ... # undocumented - def handle_timeout(self) -> None: ... # undocumented - def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ... - -class ThreadingMixIn: - daemon_threads: bool - def process_request_thread(self, request: bytes, client_address: tuple[str, int]) -> None: ... # undocumented - def process_request(self, request: bytes, client_address: tuple[str, int]) -> None: ... - -if sys.platform != "win32": - class ForkingTCPServer(ForkingMixIn, TCPServer): ... - class ForkingUDPServer(ForkingMixIn, UDPServer): ... - -class ThreadingTCPServer(ThreadingMixIn, TCPServer): ... -class ThreadingUDPServer(ThreadingMixIn, UDPServer): ... - -if sys.platform != "win32": - class ThreadingUnixStreamServer(ThreadingMixIn, UnixStreamServer): ... - class ThreadingUnixDatagramServer(ThreadingMixIn, UnixDatagramServer): ... - -class BaseRequestHandler: - # Those are technically of types, respectively: - # * Union[SocketType, Tuple[bytes, SocketType]] - # * Union[Tuple[str, int], str] - # But there are some concerns that having unions here would cause - # too much inconvenience to people using it (see - # https://github.com/python/typeshed/pull/384#issuecomment-234649696) - request: Any - client_address: Any - server: BaseServer - def __init__(self, request: Any, client_address: Any, server: BaseServer) -> None: ... - def setup(self) -> None: ... - def handle(self) -> None: ... - def finish(self) -> None: ... - -class StreamRequestHandler(BaseRequestHandler): - rbufsize: ClassVar[int] # undocumented - wbufsize: ClassVar[int] # undocumented - timeout: ClassVar[float | None] # undocumented - disable_nagle_algorithm: ClassVar[bool] # undocumented - connection: SocketType # undocumented - rfile: BinaryIO - wfile: BinaryIO - -class DatagramRequestHandler(BaseRequestHandler): - packet: SocketType # undocumented - socket: SocketType # undocumented - rfile: BinaryIO - wfile: BinaryIO diff --git a/mypy/typeshed/stdlib/@python2/StringIO.pyi b/mypy/typeshed/stdlib/@python2/StringIO.pyi deleted file mode 100644 index 4aa0cb3fcd5a..000000000000 --- a/mypy/typeshed/stdlib/@python2/StringIO.pyi +++ /dev/null @@ -1,28 +0,0 @@ -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator - -class StringIO(IO[AnyStr], Generic[AnyStr]): - closed: bool - softspace: int - len: int - name: str - def __init__(self, buf: AnyStr = ...) -> None: ... - def __iter__(self) -> Iterator[AnyStr]: ... - def next(self) -> AnyStr: ... - def close(self) -> None: ... - def isatty(self) -> bool: ... - def seek(self, pos: int, mode: int = ...) -> int: ... - def tell(self) -> int: ... - def read(self, n: int = ...) -> AnyStr: ... - def readline(self, length: int = ...) -> AnyStr: ... - def readlines(self, sizehint: int = ...) -> list[AnyStr]: ... - def truncate(self, size: int | None = ...) -> int: ... - def write(self, s: AnyStr) -> int: ... - def writelines(self, iterable: Iterable[AnyStr]) -> None: ... - def flush(self) -> None: ... - def getvalue(self) -> AnyStr: ... - def __enter__(self) -> Any: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> Any: ... - def fileno(self) -> int: ... - def readable(self) -> bool: ... - def seekable(self) -> bool: ... - def writable(self) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/UserDict.pyi b/mypy/typeshed/stdlib/@python2/UserDict.pyi deleted file mode 100644 index fd21ff0e684b..000000000000 --- a/mypy/typeshed/stdlib/@python2/UserDict.pyi +++ /dev/null @@ -1,38 +0,0 @@ -from typing import Any, Container, Generic, Iterable, Iterator, Mapping, Sized, TypeVar, overload - -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") -_T = TypeVar("_T") - -class UserDict(dict[_KT, _VT], Generic[_KT, _VT]): - data: dict[_KT, _VT] - def __init__(self, initialdata: Mapping[_KT, _VT] = ...) -> None: ... - # TODO: __iter__ is not available for UserDict - -class IterableUserDict(UserDict[_KT, _VT], Generic[_KT, _VT]): ... - -class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]): - def has_key(self, key: _KT) -> bool: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_KT]: ... - # From typing.Mapping[_KT, _VT] - # (can't inherit because of keys()) - @overload - def get(self, k: _KT) -> _VT | None: ... - @overload - def get(self, k: _KT, default: _VT | _T) -> _VT | _T: ... - def values(self) -> list[_VT]: ... - def items(self) -> list[tuple[_KT, _VT]]: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT]: ... - def iteritems(self) -> Iterator[tuple[_KT, _VT]]: ... - def __contains__(self, o: Any) -> bool: ... - # From typing.MutableMapping[_KT, _VT] - def clear(self) -> None: ... - def pop(self, k: _KT, default: _VT = ...) -> _VT: ... - def popitem(self) -> tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... - @overload - def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def update(self, m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/UserList.pyi b/mypy/typeshed/stdlib/@python2/UserList.pyi deleted file mode 100644 index 36a4bc6a001c..000000000000 --- a/mypy/typeshed/stdlib/@python2/UserList.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from _typeshed import Self -from typing import Iterable, MutableSequence, TypeVar, overload - -_T = TypeVar("_T") - -class UserList(MutableSequence[_T]): - data: list[_T] - def insert(self, index: int, object: _T) -> None: ... - @overload - def __setitem__(self, i: int, o: _T) -> None: ... - @overload - def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: int | slice) -> None: ... - def __len__(self) -> int: ... - @overload - def __getitem__(self, i: int) -> _T: ... - @overload - def __getitem__(self: Self, s: slice) -> Self: ... - def sort(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/UserString.pyi b/mypy/typeshed/stdlib/@python2/UserString.pyi deleted file mode 100644 index 7598fcaee04d..000000000000 --- a/mypy/typeshed/stdlib/@python2/UserString.pyi +++ /dev/null @@ -1,72 +0,0 @@ -from _typeshed import Self -from typing import Any, Iterable, MutableSequence, Sequence, Text, overload - -class UserString(Sequence[UserString]): - data: unicode - def __init__(self, seq: object) -> None: ... - def __int__(self) -> int: ... - def __long__(self) -> long: ... - def __float__(self) -> float: ... - def __complex__(self) -> complex: ... - def __hash__(self) -> int: ... - def __len__(self) -> int: ... - @overload - def __getitem__(self: Self, i: int) -> Self: ... - @overload - def __getitem__(self: Self, s: slice) -> Self: ... - def __add__(self: Self, other: Any) -> Self: ... - def __radd__(self: Self, other: Any) -> Self: ... - def __mul__(self: Self, other: int) -> Self: ... - def __rmul__(self: Self, other: int) -> Self: ... - def __mod__(self: Self, args: Any) -> Self: ... - def capitalize(self: Self) -> Self: ... - def center(self: Self, width: int, *args: Any) -> Self: ... - def count(self, sub: int, start: int = ..., end: int = ...) -> int: ... - def decode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ... - def encode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ... - def endswith(self, suffix: Text | tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ... - def expandtabs(self: Self, tabsize: int = ...) -> Self: ... - def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ... - def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ... - def isalpha(self) -> bool: ... - def isalnum(self) -> bool: ... - def isdecimal(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isnumeric(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, seq: Iterable[Text]) -> Text: ... - def ljust(self: Self, width: int, *args: Any) -> Self: ... - def lower(self: Self) -> Self: ... - def lstrip(self: Self, chars: Text | None = ...) -> Self: ... - def partition(self, sep: Text) -> tuple[Text, Text, Text]: ... - def replace(self: Self, old: Text, new: Text, maxsplit: int = ...) -> Self: ... - def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ... - def rjust(self: Self, width: int, *args: Any) -> Self: ... - def rpartition(self, sep: Text) -> tuple[Text, Text, Text]: ... - def rstrip(self: Self, chars: Text | None = ...) -> Self: ... - def split(self, sep: Text | None = ..., maxsplit: int = ...) -> list[Text]: ... - def rsplit(self, sep: Text | None = ..., maxsplit: int = ...) -> list[Text]: ... - def splitlines(self, keepends: int = ...) -> list[Text]: ... - def startswith(self, prefix: Text | tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ... - def strip(self: Self, chars: Text | None = ...) -> Self: ... - def swapcase(self: Self) -> Self: ... - def title(self: Self) -> Self: ... - def translate(self: Self, *args: Any) -> Self: ... - def upper(self: Self) -> Self: ... - def zfill(self: Self, width: int) -> Self: ... - -class MutableString(UserString, MutableSequence[MutableString]): - @overload - def __getitem__(self: Self, i: int) -> Self: ... - @overload - def __getitem__(self: Self, s: slice) -> Self: ... - def __setitem__(self, index: int | slice, sub: Any) -> None: ... - def __delitem__(self, index: int | slice) -> None: ... - def immutable(self) -> UserString: ... - def __iadd__(self: Self, other: Any) -> Self: ... - def __imul__(self: Self, n: int) -> Self: ... - def insert(self, index: int, value: Any) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/__builtin__.pyi b/mypy/typeshed/stdlib/@python2/__builtin__.pyi deleted file mode 100644 index 4ede9dc9d8bd..000000000000 --- a/mypy/typeshed/stdlib/@python2/__builtin__.pyi +++ /dev/null @@ -1,1165 +0,0 @@ -# True and False are deliberately omitted because they are keywords in -# Python 3, and stub files conform to Python 3 syntax. - -from _typeshed import ReadableBuffer, Self, SupportsKeysAndGetItem, SupportsWrite -from abc import ABCMeta -from ast import mod -from types import CodeType -from typing import ( - AbstractSet, - Any, - AnyStr, - BinaryIO, - ByteString, - Callable, - ClassVar, - Container, - Generic, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableMapping, - MutableSequence, - MutableSet, - NoReturn, - Protocol, - Reversible, - Sequence, - Sized, - SupportsAbs, - SupportsComplex, - SupportsFloat, - SupportsInt, - Text, - TypeVar, - ValuesView, - overload, -) -from typing_extensions import Literal, final - -class _SupportsIndex(Protocol): - def __index__(self) -> int: ... - -class _SupportsTrunc(Protocol): - def __trunc__(self) -> int: ... - -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") -_S = TypeVar("_S") -_T1 = TypeVar("_T1") -_T2 = TypeVar("_T2") -_T3 = TypeVar("_T3") -_T4 = TypeVar("_T4") -_T5 = TypeVar("_T5") -_TT = TypeVar("_TT", bound=type) - -class object: - __doc__: str | None - __dict__: dict[str, Any] - __module__: str - @property - def __class__(self: _T) -> type[_T]: ... - @__class__.setter - def __class__(self, __type: type[object]) -> None: ... # noqa: F811 - def __init__(self) -> None: ... - def __new__(cls) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __eq__(self, o: object) -> bool: ... - def __ne__(self, o: object) -> bool: ... - def __str__(self) -> str: ... # noqa: Y029 - def __repr__(self) -> str: ... # noqa: Y029 - def __hash__(self) -> int: ... - def __format__(self, format_spec: str) -> str: ... - def __getattribute__(self, name: str) -> Any: ... - def __delattr__(self, name: str) -> None: ... - def __sizeof__(self) -> int: ... - def __reduce__(self) -> str | tuple[Any, ...]: ... - def __reduce_ex__(self, protocol: int) -> str | tuple[Any, ...]: ... - -class staticmethod(object): # Special, only valid as a decorator. - __func__: Callable[..., Any] - def __init__(self, f: Callable[..., Any]) -> None: ... - def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ... - def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ... - -class classmethod(object): # Special, only valid as a decorator. - __func__: Callable[..., Any] - def __init__(self, f: Callable[..., Any]) -> None: ... - def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ... - def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ... - -class type(object): - __base__: type - __bases__: tuple[type, ...] - __basicsize__: int - __dict__: dict[str, Any] - __dictoffset__: int - __flags__: int - __itemsize__: int - __module__: str - __mro__: tuple[type, ...] - __name__: str - __weakrefoffset__: int - @overload - def __init__(self, o: object) -> None: ... - @overload - def __init__(self, name: str, bases: tuple[type, ...], dict: dict[str, Any]) -> None: ... - @overload - def __new__(cls, o: object) -> type: ... - @overload - def __new__(cls, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> type: ... - def __call__(self, *args: Any, **kwds: Any) -> Any: ... - def __subclasses__(self: _TT) -> list[_TT]: ... - # Note: the documentation doesn't specify what the return type is, the standard - # implementation seems to be returning a list. - def mro(self) -> list[type]: ... - def __instancecheck__(self, instance: Any) -> bool: ... - def __subclasscheck__(self, subclass: type) -> bool: ... - -class super(object): - @overload - def __init__(self, t: Any, obj: Any) -> None: ... - @overload - def __init__(self, t: Any) -> None: ... - -class int: - @overload - def __new__(cls: type[Self], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> Self: ... - @overload - def __new__(cls: type[Self], x: Text | bytes | bytearray, base: int) -> Self: ... - @property - def real(self) -> int: ... - @property - def imag(self) -> int: ... - @property - def numerator(self) -> int: ... - @property - def denominator(self) -> int: ... - def conjugate(self) -> int: ... - def bit_length(self) -> int: ... - def __add__(self, x: int) -> int: ... - def __sub__(self, x: int) -> int: ... - def __mul__(self, x: int) -> int: ... - def __floordiv__(self, x: int) -> int: ... - def __div__(self, x: int) -> int: ... - def __truediv__(self, x: int) -> float: ... - def __mod__(self, x: int) -> int: ... - def __divmod__(self, x: int) -> tuple[int, int]: ... - def __radd__(self, x: int) -> int: ... - def __rsub__(self, x: int) -> int: ... - def __rmul__(self, x: int) -> int: ... - def __rfloordiv__(self, x: int) -> int: ... - def __rdiv__(self, x: int) -> int: ... - def __rtruediv__(self, x: int) -> float: ... - def __rmod__(self, x: int) -> int: ... - def __rdivmod__(self, x: int) -> tuple[int, int]: ... - @overload - def __pow__(self, __x: Literal[2], __modulo: int | None = ...) -> int: ... - @overload - def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... # Return type can be int or float, depending on x. - def __rpow__(self, x: int, mod: int | None = ...) -> Any: ... - def __and__(self, n: int) -> int: ... - def __or__(self, n: int) -> int: ... - def __xor__(self, n: int) -> int: ... - def __lshift__(self, n: int) -> int: ... - def __rshift__(self, n: int) -> int: ... - def __rand__(self, n: int) -> int: ... - def __ror__(self, n: int) -> int: ... - def __rxor__(self, n: int) -> int: ... - def __rlshift__(self, n: int) -> int: ... - def __rrshift__(self, n: int) -> int: ... - def __neg__(self) -> int: ... - def __pos__(self) -> int: ... - def __invert__(self) -> int: ... - def __trunc__(self) -> int: ... - def __getnewargs__(self) -> tuple[int]: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: int) -> bool: ... - def __le__(self, x: int) -> bool: ... - def __gt__(self, x: int) -> bool: ... - def __ge__(self, x: int) -> bool: ... - def __float__(self) -> float: ... - def __int__(self) -> int: ... - def __abs__(self) -> int: ... - def __hash__(self) -> int: ... - def __nonzero__(self) -> bool: ... - def __index__(self) -> int: ... - -class float: - def __new__(cls: type[Self], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> Self: ... - def as_integer_ratio(self) -> tuple[int, int]: ... - def hex(self) -> str: ... - def is_integer(self) -> bool: ... - @classmethod - def fromhex(cls, __s: str) -> float: ... - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - def conjugate(self) -> float: ... - def __add__(self, x: float) -> float: ... - def __sub__(self, x: float) -> float: ... - def __mul__(self, x: float) -> float: ... - def __floordiv__(self, x: float) -> float: ... - def __div__(self, x: float) -> float: ... - def __truediv__(self, x: float) -> float: ... - def __mod__(self, x: float) -> float: ... - def __divmod__(self, x: float) -> tuple[float, float]: ... - def __pow__( - self, x: float, mod: None = ... - ) -> float: ... # In Python 3, returns complex if self is negative and x is not whole - def __radd__(self, x: float) -> float: ... - def __rsub__(self, x: float) -> float: ... - def __rmul__(self, x: float) -> float: ... - def __rfloordiv__(self, x: float) -> float: ... - def __rdiv__(self, x: float) -> float: ... - def __rtruediv__(self, x: float) -> float: ... - def __rmod__(self, x: float) -> float: ... - def __rdivmod__(self, x: float) -> tuple[float, float]: ... - def __rpow__(self, x: float, mod: None = ...) -> float: ... - def __getnewargs__(self) -> tuple[float]: ... - def __trunc__(self) -> int: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: float) -> bool: ... - def __le__(self, x: float) -> bool: ... - def __gt__(self, x: float) -> bool: ... - def __ge__(self, x: float) -> bool: ... - def __neg__(self) -> float: ... - def __pos__(self) -> float: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __abs__(self) -> float: ... - def __hash__(self) -> int: ... - def __nonzero__(self) -> bool: ... - -class complex: - @overload - def __new__(cls: type[Self], real: float = ..., imag: float = ...) -> Self: ... - @overload - def __new__(cls: type[Self], real: str | SupportsComplex | _SupportsIndex) -> Self: ... - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - def conjugate(self) -> complex: ... - def __add__(self, x: complex) -> complex: ... - def __sub__(self, x: complex) -> complex: ... - def __mul__(self, x: complex) -> complex: ... - def __pow__(self, x: complex, mod: None = ...) -> complex: ... - def __div__(self, x: complex) -> complex: ... - def __truediv__(self, x: complex) -> complex: ... - def __radd__(self, x: complex) -> complex: ... - def __rsub__(self, x: complex) -> complex: ... - def __rmul__(self, x: complex) -> complex: ... - def __rpow__(self, x: complex, mod: None = ...) -> complex: ... - def __rdiv__(self, x: complex) -> complex: ... - def __rtruediv__(self, x: complex) -> complex: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __neg__(self) -> complex: ... - def __pos__(self) -> complex: ... - def __complex__(self) -> complex: ... - def __abs__(self) -> float: ... - def __hash__(self) -> int: ... - def __nonzero__(self) -> bool: ... - -class basestring(metaclass=ABCMeta): ... - -class unicode(basestring, Sequence[unicode]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, o: object) -> None: ... - @overload - def __init__(self, o: str, encoding: unicode = ..., errors: unicode = ...) -> None: ... - def capitalize(self) -> unicode: ... - def center(self, width: int, fillchar: unicode = ...) -> unicode: ... - def count(self, x: unicode) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, __suffix: unicode | tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> unicode: ... - def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def format(self, *args: object, **kwargs: object) -> unicode: ... - def index(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdecimal(self) -> bool: ... - def isdigit(self) -> bool: ... - def isidentifier(self) -> bool: ... - def islower(self) -> bool: ... - def isnumeric(self) -> bool: ... - def isprintable(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, iterable: Iterable[unicode]) -> unicode: ... - def ljust(self, width: int, fillchar: unicode = ...) -> unicode: ... - def lower(self) -> unicode: ... - def lstrip(self, chars: unicode = ...) -> unicode: ... - def partition(self, sep: unicode) -> tuple[unicode, unicode, unicode]: ... - def replace(self, old: unicode, new: unicode, count: int = ...) -> unicode: ... - def rfind(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: unicode = ...) -> unicode: ... - def rpartition(self, sep: unicode) -> tuple[unicode, unicode, unicode]: ... - def rsplit(self, sep: unicode | None = ..., maxsplit: int = ...) -> list[unicode]: ... - def rstrip(self, chars: unicode = ...) -> unicode: ... - def split(self, sep: unicode | None = ..., maxsplit: int = ...) -> list[unicode]: ... - def splitlines(self, keepends: bool = ...) -> list[unicode]: ... - def startswith(self, __prefix: unicode | tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def strip(self, chars: unicode = ...) -> unicode: ... - def swapcase(self) -> unicode: ... - def title(self) -> unicode: ... - def translate(self, table: dict[int, Any] | unicode) -> unicode: ... - def upper(self) -> unicode: ... - def zfill(self, width: int) -> unicode: ... - @overload - def __getitem__(self, i: int) -> unicode: ... - @overload - def __getitem__(self, s: slice) -> unicode: ... - def __getslice__(self, start: int, stop: int) -> unicode: ... - def __add__(self, s: unicode) -> unicode: ... - def __mul__(self, n: int) -> unicode: ... - def __rmul__(self, n: int) -> unicode: ... - def __mod__(self, x: Any) -> unicode: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... - def __len__(self) -> int: ... - # The argument type is incompatible with Sequence - def __contains__(self, s: unicode | bytes) -> bool: ... # type: ignore[override] - def __iter__(self) -> Iterator[unicode]: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __hash__(self) -> int: ... - def __getnewargs__(self) -> tuple[unicode]: ... - -class _FormatMapMapping(Protocol): - def __getitem__(self, __key: str) -> Any: ... - -class str(Sequence[str], basestring): - def __init__(self, o: object = ...) -> None: ... - def capitalize(self) -> str: ... - def center(self, __width: int, __fillchar: str = ...) -> str: ... - def count(self, x: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... - def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... - def endswith(self, __suffix: Text | tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> str: ... - def find(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def format(self, *args: object, **kwargs: object) -> str: ... - def format_map(self, map: _FormatMapMapping) -> str: ... - def index(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, __iterable: Iterable[AnyStr]) -> AnyStr: ... - def ljust(self, __width: int, __fillchar: str = ...) -> str: ... - def lower(self) -> str: ... - @overload - def lstrip(self, __chars: str = ...) -> str: ... - @overload - def lstrip(self, __chars: unicode) -> unicode: ... - @overload - def partition(self, __sep: bytearray) -> tuple[str, bytearray, str]: ... - @overload - def partition(self, __sep: str) -> tuple[str, str, str]: ... - @overload - def partition(self, __sep: unicode) -> tuple[unicode, unicode, unicode]: ... - def replace(self, __old: AnyStr, __new: AnyStr, __count: int = ...) -> AnyStr: ... - def rfind(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def rindex(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def rjust(self, __width: int, __fillchar: str = ...) -> str: ... - @overload - def rpartition(self, __sep: bytearray) -> tuple[str, bytearray, str]: ... - @overload - def rpartition(self, __sep: str) -> tuple[str, str, str]: ... - @overload - def rpartition(self, __sep: unicode) -> tuple[unicode, unicode, unicode]: ... - @overload - def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... - @overload - def rsplit(self, sep: unicode, maxsplit: int = ...) -> list[unicode]: ... - @overload - def rstrip(self, __chars: str = ...) -> str: ... - @overload - def rstrip(self, __chars: unicode) -> unicode: ... - @overload - def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... - @overload - def split(self, sep: unicode, maxsplit: int = ...) -> list[unicode]: ... - def splitlines(self, keepends: bool = ...) -> list[str]: ... - def startswith(self, __prefix: Text | tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - @overload - def strip(self, __chars: str = ...) -> str: ... - @overload - def strip(self, chars: unicode) -> unicode: ... - def swapcase(self) -> str: ... - def title(self) -> str: ... - def translate(self, __table: AnyStr | None, deletechars: AnyStr = ...) -> AnyStr: ... - def upper(self) -> str: ... - def zfill(self, __width: int) -> str: ... - def __add__(self, s: AnyStr) -> AnyStr: ... - # Incompatible with Sequence.__contains__ - def __contains__(self, o: str | Text) -> bool: ... # type: ignore[override] - def __eq__(self, x: object) -> bool: ... - def __ge__(self, x: Text) -> bool: ... - def __getitem__(self, i: int | slice) -> str: ... - def __gt__(self, x: Text) -> bool: ... - def __hash__(self) -> int: ... - def __iter__(self) -> Iterator[str]: ... - def __le__(self, x: Text) -> bool: ... - def __len__(self) -> int: ... - def __lt__(self, x: Text) -> bool: ... - def __mod__(self, x: Any) -> str: ... - def __mul__(self, n: int) -> str: ... - def __ne__(self, x: object) -> bool: ... - def __rmul__(self, n: int) -> str: ... - def __getnewargs__(self) -> tuple[str]: ... - def __getslice__(self, start: int, stop: int) -> str: ... - def __float__(self) -> float: ... - def __int__(self) -> int: ... - -bytes = str - -class bytearray(MutableSequence[int], ByteString): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, ints: Iterable[int]) -> None: ... - @overload - def __init__(self, string: str) -> None: ... - @overload - def __init__(self, string: Text, encoding: Text, errors: Text = ...) -> None: ... - @overload - def __init__(self, length: int) -> None: ... - def capitalize(self) -> bytearray: ... - def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... - def count(self, __sub: str) -> int: ... - def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... - def endswith(self, __suffix: bytes | tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def extend(self, iterable: str | Iterable[int]) -> None: ... - def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... - def index(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... - def insert(self, __index: int, __item: int) -> None: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, __iterable: Iterable[str]) -> bytearray: ... - def ljust(self, __width: int, __fillchar: str = ...) -> bytearray: ... - def lower(self) -> bytearray: ... - def lstrip(self, __bytes: bytes | None = ...) -> bytearray: ... - def partition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ... - def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... - def rfind(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... - def rindex(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... - def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... - def rpartition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> list[bytearray]: ... - def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... - def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> list[bytearray]: ... - def splitlines(self, keepends: bool = ...) -> list[bytearray]: ... - def startswith(self, __prefix: bytes | tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def strip(self, __bytes: bytes | None = ...) -> bytearray: ... - def swapcase(self) -> bytearray: ... - def title(self) -> bytearray: ... - def translate(self, __table: str) -> bytearray: ... - def upper(self) -> bytearray: ... - def zfill(self, __width: int) -> bytearray: ... - @classmethod - def fromhex(cls, __string: str) -> bytearray: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - __hash__: ClassVar[None] # type: ignore[assignment] - @overload - def __getitem__(self, i: int) -> int: ... - @overload - def __getitem__(self, s: slice) -> bytearray: ... - @overload - def __setitem__(self, i: int, x: int) -> None: ... - @overload - def __setitem__(self, s: slice, x: Iterable[int] | bytes) -> None: ... - def __delitem__(self, i: int | slice) -> None: ... - def __getslice__(self, start: int, stop: int) -> bytearray: ... - def __setslice__(self, start: int, stop: int, x: Sequence[int] | str) -> None: ... - def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, s: bytes) -> bytearray: ... - def __mul__(self, n: int) -> bytearray: ... - # Incompatible with Sequence.__contains__ - def __contains__(self, o: int | bytes) -> bool: ... # type: ignore[override] - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: bytes) -> bool: ... - def __le__(self, x: bytes) -> bool: ... - def __gt__(self, x: bytes) -> bool: ... - def __ge__(self, x: bytes) -> bool: ... - -class memoryview(Sized, Container[str]): - format: str - itemsize: int - shape: tuple[int, ...] | None - strides: tuple[int, ...] | None - suboffsets: tuple[int, ...] | None - readonly: bool - ndim: int - def __init__(self, obj: ReadableBuffer) -> None: ... - @overload - def __getitem__(self, i: int) -> str: ... - @overload - def __getitem__(self, s: slice) -> memoryview: ... - def __contains__(self, x: object) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - @overload - def __setitem__(self, s: slice, o: bytes) -> None: ... - @overload - def __setitem__(self, i: int, o: int) -> None: ... - def tobytes(self) -> bytes: ... - def tolist(self) -> list[int]: ... - -@final -class bool(int): - def __new__(cls: type[Self], __o: object = ...) -> Self: ... - @overload - def __and__(self, x: bool) -> bool: ... - @overload - def __and__(self, x: int) -> int: ... - @overload - def __or__(self, x: bool) -> bool: ... - @overload - def __or__(self, x: int) -> int: ... - @overload - def __xor__(self, x: bool) -> bool: ... - @overload - def __xor__(self, x: int) -> int: ... - @overload - def __rand__(self, x: bool) -> bool: ... - @overload - def __rand__(self, x: int) -> int: ... - @overload - def __ror__(self, x: bool) -> bool: ... - @overload - def __ror__(self, x: int) -> int: ... - @overload - def __rxor__(self, x: bool) -> bool: ... - @overload - def __rxor__(self, x: int) -> int: ... - def __getnewargs__(self) -> tuple[int]: ... - -class slice(object): - start: Any - step: Any - stop: Any - @overload - def __init__(self, stop: Any) -> None: ... - @overload - def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ... - __hash__: ClassVar[None] # type: ignore[assignment] - def indices(self, len: int) -> tuple[int, int, int]: ... - -class tuple(Sequence[_T_co], Generic[_T_co]): - def __new__(cls: type[Self], iterable: Iterable[_T_co] = ...) -> Self: ... - def __len__(self) -> int: ... - def __contains__(self, x: object) -> bool: ... - @overload - def __getitem__(self, x: int) -> _T_co: ... - @overload - def __getitem__(self, x: slice) -> tuple[_T_co, ...]: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __lt__(self, x: tuple[_T_co, ...]) -> bool: ... - def __le__(self, x: tuple[_T_co, ...]) -> bool: ... - def __gt__(self, x: tuple[_T_co, ...]) -> bool: ... - def __ge__(self, x: tuple[_T_co, ...]) -> bool: ... - @overload - def __add__(self, x: tuple[_T_co, ...]) -> tuple[_T_co, ...]: ... - @overload - def __add__(self, x: tuple[Any, ...]) -> tuple[Any, ...]: ... - def __mul__(self, n: int) -> tuple[_T_co, ...]: ... - def __rmul__(self, n: int) -> tuple[_T_co, ...]: ... - def count(self, __value: Any) -> int: ... - def index(self, __value: Any) -> int: ... - -class function: - # TODO not defined in builtins! - __name__: str - __module__: str - __code__: CodeType - -class list(MutableSequence[_T], Generic[_T]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, iterable: Iterable[_T]) -> None: ... - def append(self, __object: _T) -> None: ... - def extend(self, __iterable: Iterable[_T]) -> None: ... - def pop(self, __index: int = ...) -> _T: ... - def index(self, __value: _T, __start: int = ..., __stop: int = ...) -> int: ... - def count(self, __value: _T) -> int: ... - def insert(self, __index: int, __object: _T) -> None: ... - def remove(self, __value: _T) -> None: ... - def reverse(self) -> None: ... - def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_T]: ... - __hash__: ClassVar[None] # type: ignore[assignment] - @overload - def __getitem__(self, i: int) -> _T: ... - @overload - def __getitem__(self, s: slice) -> list[_T]: ... - @overload - def __setitem__(self, i: int, o: _T) -> None: ... - @overload - def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: int | slice) -> None: ... - def __getslice__(self, start: int, stop: int) -> list[_T]: ... - def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... - def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, x: list[_T]) -> list[_T]: ... - def __iadd__(self: Self, x: Iterable[_T]) -> Self: ... - def __mul__(self, n: int) -> list[_T]: ... - def __rmul__(self, n: int) -> list[_T]: ... - def __contains__(self, o: object) -> bool: ... - def __reversed__(self) -> Iterator[_T]: ... - def __gt__(self, x: list[_T]) -> bool: ... - def __ge__(self, x: list[_T]) -> bool: ... - def __lt__(self, x: list[_T]) -> bool: ... - def __le__(self, x: list[_T]) -> bool: ... - -class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): - # NOTE: Keyword arguments are special. If they are used, _KT must include - # str, but we have no way of enforcing it here. - @overload - def __init__(self, **kwargs: _VT) -> None: ... - @overload - def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ... - def has_key(self, k: _KT) -> bool: ... - def clear(self) -> None: ... - def copy(self) -> dict[_KT, _VT]: ... - def popitem(self) -> tuple[_KT, _VT]: ... - def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ... - @overload - def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - @overload - def update(self, **kwargs: _VT) -> None: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT]: ... - def iteritems(self) -> Iterator[tuple[_KT, _VT]]: ... - def viewkeys(self) -> KeysView[_KT]: ... - def viewvalues(self) -> ValuesView[_VT]: ... - def viewitems(self) -> ItemsView[_KT, _VT]: ... - @classmethod - @overload - def fromkeys(cls, __iterable: Iterable[_T]) -> dict[_T, Any]: ... - @classmethod - @overload - def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> dict[_T, _S]: ... - def __len__(self) -> int: ... - def __getitem__(self, k: _KT) -> _VT: ... - def __setitem__(self, k: _KT, v: _VT) -> None: ... - def __delitem__(self, v: _KT) -> None: ... - def __iter__(self) -> Iterator[_KT]: ... - __hash__: ClassVar[None] # type: ignore[assignment] - -class set(MutableSet[_T], Generic[_T]): - def __init__(self, iterable: Iterable[_T] = ...) -> None: ... - def add(self, element: _T) -> None: ... - def clear(self) -> None: ... - def copy(self) -> set[_T]: ... - def difference(self, *s: Iterable[Any]) -> set[_T]: ... - def difference_update(self, *s: Iterable[Any]) -> None: ... - def discard(self, element: _T) -> None: ... - def intersection(self, *s: Iterable[Any]) -> set[_T]: ... - def intersection_update(self, *s: Iterable[Any]) -> None: ... - def isdisjoint(self, s: Iterable[Any]) -> bool: ... - def issubset(self, s: Iterable[Any]) -> bool: ... - def issuperset(self, s: Iterable[Any]) -> bool: ... - def pop(self) -> _T: ... - def remove(self, element: _T) -> None: ... - def symmetric_difference(self, s: Iterable[_T]) -> set[_T]: ... - def symmetric_difference_update(self, s: Iterable[_T]) -> None: ... - def union(self, *s: Iterable[_T]) -> set[_T]: ... - def update(self, *s: Iterable[_T]) -> None: ... - def __len__(self) -> int: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_T]: ... - def __and__(self, s: AbstractSet[object]) -> set[_T]: ... - def __iand__(self: Self, s: AbstractSet[object]) -> Self: ... - def __or__(self, s: AbstractSet[_S]) -> set[_T | _S]: ... - def __ior__(self: Self, s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - @overload - def __sub__(self: set[str], s: AbstractSet[Text | None]) -> set[_T]: ... - @overload - def __sub__(self, s: AbstractSet[_T | None]) -> set[_T]: ... - @overload # type: ignore - def __isub__(self: set[str], s: AbstractSet[Text | None]) -> set[_T]: ... - @overload - def __isub__(self, s: AbstractSet[_T | None]) -> set[_T]: ... - def __xor__(self, s: AbstractSet[_S]) -> set[_T | _S]: ... - def __ixor__(self: Self, s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - def __le__(self, s: AbstractSet[object]) -> bool: ... - def __lt__(self, s: AbstractSet[object]) -> bool: ... - def __ge__(self, s: AbstractSet[object]) -> bool: ... - def __gt__(self, s: AbstractSet[object]) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] - -class frozenset(AbstractSet[_T_co], Generic[_T_co]): - def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ... - def copy(self) -> frozenset[_T_co]: ... - def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ... - def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ... - def isdisjoint(self, s: Iterable[_T_co]) -> bool: ... - def issubset(self, s: Iterable[object]) -> bool: ... - def issuperset(self, s: Iterable[object]) -> bool: ... - def symmetric_difference(self, s: Iterable[_T_co]) -> frozenset[_T_co]: ... - def union(self, *s: Iterable[_T_co]) -> frozenset[_T_co]: ... - def __len__(self) -> int: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __and__(self, s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... - def __or__(self, s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ... - def __sub__(self, s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... - def __xor__(self, s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ... - def __le__(self, s: AbstractSet[object]) -> bool: ... - def __lt__(self, s: AbstractSet[object]) -> bool: ... - def __ge__(self, s: AbstractSet[object]) -> bool: ... - def __gt__(self, s: AbstractSet[object]) -> bool: ... - -class enumerate(Iterator[tuple[int, _T]], Generic[_T]): - def __init__(self, iterable: Iterable[_T], start: int = ...) -> None: ... - def __iter__(self: Self) -> Self: ... - def next(self) -> tuple[int, _T]: ... - -class xrange(Sized, Iterable[int], Reversible[int]): - @overload - def __init__(self, stop: int) -> None: ... - @overload - def __init__(self, start: int, stop: int, step: int = ...) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - def __getitem__(self, i: _SupportsIndex) -> int: ... - def __reversed__(self) -> Iterator[int]: ... - -class property(object): - def __init__( - self, - fget: Callable[[Any], Any] | None = ..., - fset: Callable[[Any, Any], None] | None = ..., - fdel: Callable[[Any], None] | None = ..., - doc: str | None = ..., - ) -> None: ... - def getter(self, fget: Callable[[Any], Any]) -> property: ... - def setter(self, fset: Callable[[Any, Any], None]) -> property: ... - def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: type | None = ...) -> Any: ... - def __set__(self, obj: Any, value: Any) -> None: ... - def __delete__(self, obj: Any) -> None: ... - def fget(self) -> Any: ... - def fset(self, value: Any) -> None: ... - def fdel(self) -> None: ... - -long = int - -class _NotImplementedType(Any): # type: ignore[misc] - # A little weird, but typing the __call__ as NotImplemented makes the error message - # for NotImplemented() much better - __call__: NotImplemented # type: ignore[valid-type] - -NotImplemented: _NotImplementedType - -def abs(__x: SupportsAbs[_T]) -> _T: ... -def all(__iterable: Iterable[object]) -> bool: ... -def any(__iterable: Iterable[object]) -> bool: ... -def apply(__func: Callable[..., _T], __args: Sequence[Any] | None = ..., __kwds: Mapping[str, Any] | None = ...) -> _T: ... -def bin(__number: int | _SupportsIndex) -> str: ... -def callable(__obj: object) -> bool: ... -def chr(__i: int) -> str: ... -def cmp(__x: Any, __y: Any) -> int: ... - -_N1 = TypeVar("_N1", bool, int, float, complex) - -def coerce(__x: _N1, __y: _N1) -> tuple[_N1, _N1]: ... -def compile(source: Text | mod, filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... -def delattr(__obj: Any, __name: Text) -> None: ... -def dir(__o: object = ...) -> list[str]: ... - -_N2 = TypeVar("_N2", int, float) - -def divmod(__x: _N2, __y: _N2) -> tuple[_N2, _N2]: ... -def eval( - __source: Text | bytes | CodeType, __globals: dict[str, Any] | None = ..., __locals: Mapping[str, Any] | None = ... -) -> Any: ... -def execfile(__filename: str, __globals: dict[str, Any] | None = ..., __locals: dict[str, Any] | None = ...) -> None: ... -def exit(code: object = ...) -> NoReturn: ... -@overload -def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore -@overload -def filter(__function: None, __iterable: tuple[_T | None, ...]) -> tuple[_T, ...]: ... # type: ignore -@overload -def filter(__function: Callable[[_T], Any], __iterable: tuple[_T, ...]) -> tuple[_T, ...]: ... # type: ignore -@overload -def filter(__function: None, __iterable: Iterable[_T | None]) -> list[_T]: ... -@overload -def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> list[_T]: ... -def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode -@overload -def getattr(__o: Any, name: Text) -> Any: ... - -# While technically covered by the last overload, spelling out the types for None, bool -# and basic containers help mypy out in some tricky situations involving type context -# (aka bidirectional inference) -@overload -def getattr(__o: Any, name: Text, __default: None) -> Any | None: ... -@overload -def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... -@overload -def getattr(__o: object, name: str, __default: list[Any]) -> Any | list[Any]: ... -@overload -def getattr(__o: object, name: str, __default: dict[Any, Any]) -> Any | dict[Any, Any]: ... -@overload -def getattr(__o: Any, name: Text, __default: _T) -> Any | _T: ... -def globals() -> dict[str, Any]: ... -def hasattr(__obj: Any, __name: Text) -> bool: ... -def hash(__obj: object) -> int: ... -def hex(__number: int | _SupportsIndex) -> str: ... -def id(__obj: object) -> int: ... -def input(__prompt: Any = ...) -> Any: ... -def intern(__string: str) -> str: ... -@overload -def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... -@overload -def iter(__function: Callable[[], _T | None], __sentinel: None) -> Iterator[_T]: ... -@overload -def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... -def isinstance(__obj: object, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... -def issubclass(__cls: type, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... -def len(__obj: Sized) -> int: ... -def locals() -> dict[str, Any]: ... -@overload -def map(__func: None, __iter1: Iterable[_T1]) -> list[_T1]: ... -@overload -def map(__func: None, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> list[tuple[_T1, _T2]]: ... -@overload -def map(__func: None, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> list[tuple[_T1, _T2, _T3]]: ... -@overload -def map( - __func: None, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4] -) -> list[tuple[_T1, _T2, _T3, _T4]]: ... -@overload -def map( - __func: None, - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - __iter5: Iterable[_T5], -) -> list[tuple[_T1, _T2, _T3, _T4, _T5]]: ... -@overload -def map( - __func: None, - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], -) -> list[tuple[Any, ...]]: ... -@overload -def map(__func: Callable[[_T1], _S], __iter1: Iterable[_T1]) -> list[_S]: ... -@overload -def map(__func: Callable[[_T1, _T2], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> list[_S]: ... -@overload -def map( - __func: Callable[[_T1, _T2, _T3], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3] -) -> list[_S]: ... -@overload -def map( - __func: Callable[[_T1, _T2, _T3, _T4], _S], - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], -) -> list[_S]: ... -@overload -def map( - __func: Callable[[_T1, _T2, _T3, _T4, _T5], _S], - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - __iter5: Iterable[_T5], -) -> list[_S]: ... -@overload -def map( - __func: Callable[..., _S], - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], -) -> list[_S]: ... -@overload -def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def max(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def min(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def next(__i: Iterator[_T]) -> _T: ... -@overload -def next(__i: Iterator[_T], __default: _VT) -> _T | _VT: ... -def oct(__number: int | _SupportsIndex) -> str: ... -def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... -def ord(__c: Text | bytes) -> int: ... - -# This is only available after from __future__ import print_function. -def print(*values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ...) -> None: ... - -_E = TypeVar("_E", contravariant=True) -_M = TypeVar("_M", contravariant=True) - -class _SupportsPow2(Protocol[_E, _T_co]): - def __pow__(self, __other: _E) -> _T_co: ... - -class _SupportsPow3(Protocol[_E, _M, _T_co]): - def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ... - -@overload -def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative -@overload -def pow(__base: int, __exp: int, __mod: int) -> int: ... -@overload -def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... -@overload -def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... -@overload -def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ... -def quit(code: object = ...) -> NoReturn: ... -def range(__x: int, __y: int = ..., __step: int = ...) -> list[int]: ... -def raw_input(__prompt: Any = ...) -> str: ... -@overload -def reduce(__function: Callable[[_T, _S], _T], __iterable: Iterable[_S], __initializer: _T) -> _T: ... -@overload -def reduce(__function: Callable[[_T, _T], _T], __iterable: Iterable[_T]) -> _T: ... -def reload(__module: Any) -> Any: ... -@overload -def reversed(__sequence: Sequence[_T]) -> Iterator[_T]: ... -@overload -def reversed(__sequence: Reversible[_T]) -> Iterator[_T]: ... -def repr(__obj: object) -> str: ... -@overload -def round(number: float) -> float: ... -@overload -def round(number: float, ndigits: int) -> float: ... -@overload -def round(number: SupportsFloat) -> float: ... -@overload -def round(number: SupportsFloat, ndigits: int) -> float: ... -def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... -def sorted( - __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Callable[[_T], Any] | None = ..., reverse: bool = ... -) -> list[_T]: ... -@overload -def sum(__iterable: Iterable[_T]) -> _T | int: ... -@overload -def sum(__iterable: Iterable[_T], __start: _S) -> _T | _S: ... -def unichr(__i: int) -> unicode: ... -def vars(__object: Any = ...) -> dict[str, Any]: ... -@overload -def zip(__iter1: Iterable[_T1]) -> list[tuple[_T1]]: ... -@overload -def zip(__iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> list[tuple[_T1, _T2]]: ... -@overload -def zip(__iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> list[tuple[_T1, _T2, _T3]]: ... -@overload -def zip( - __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4] -) -> list[tuple[_T1, _T2, _T3, _T4]]: ... -@overload -def zip( - __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4], __iter5: Iterable[_T5] -) -> list[tuple[_T1, _T2, _T3, _T4, _T5]]: ... -@overload -def zip( - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], -) -> list[tuple[Any, ...]]: ... -def __import__( - name: Text, - globals: Mapping[str, Any] | None = ..., - locals: Mapping[str, Any] | None = ..., - fromlist: Sequence[str] = ..., - level: int = ..., -) -> Any: ... - -# Actually the type of Ellipsis is , but since it's -# not exposed anywhere under that name, we make it private here. -class ellipsis: ... - -Ellipsis: ellipsis - -# TODO: buffer support is incomplete; e.g. some_string.startswith(some_buffer) doesn't type check. -_AnyBuffer = TypeVar("_AnyBuffer", str, unicode, bytearray, buffer) - -class buffer(Sized): - def __init__(self, object: _AnyBuffer, offset: int = ..., size: int = ...) -> None: ... - def __add__(self, other: _AnyBuffer) -> str: ... - def __cmp__(self, other: _AnyBuffer) -> bool: ... - def __getitem__(self, key: int | slice) -> str: ... - def __getslice__(self, i: int, j: int) -> str: ... - def __len__(self) -> int: ... - def __mul__(self, x: int) -> str: ... - -class BaseException(object): - args: tuple[Any, ...] - message: Any - def __init__(self, *args: object) -> None: ... - def __getitem__(self, i: int) -> Any: ... - def __getslice__(self, start: int, stop: int) -> tuple[Any, ...]: ... - -class GeneratorExit(BaseException): ... -class KeyboardInterrupt(BaseException): ... - -class SystemExit(BaseException): - code: int - -class Exception(BaseException): ... -class StopIteration(Exception): ... -class StandardError(Exception): ... - -_StandardError = StandardError - -class EnvironmentError(StandardError): - errno: int - strerror: str - # TODO can this be unicode? - filename: str - -class OSError(EnvironmentError): ... -class IOError(EnvironmentError): ... -class ArithmeticError(_StandardError): ... -class AssertionError(_StandardError): ... -class AttributeError(_StandardError): ... -class BufferError(_StandardError): ... -class EOFError(_StandardError): ... -class ImportError(_StandardError): ... -class LookupError(_StandardError): ... -class MemoryError(_StandardError): ... -class NameError(_StandardError): ... -class ReferenceError(_StandardError): ... -class RuntimeError(_StandardError): ... - -class SyntaxError(_StandardError): - msg: str - lineno: int | None - offset: int | None - text: str | None - filename: str | None - -class SystemError(_StandardError): ... -class TypeError(_StandardError): ... -class ValueError(_StandardError): ... -class FloatingPointError(ArithmeticError): ... -class OverflowError(ArithmeticError): ... -class ZeroDivisionError(ArithmeticError): ... -class IndexError(LookupError): ... -class KeyError(LookupError): ... -class UnboundLocalError(NameError): ... - -class WindowsError(OSError): - winerror: int - -class NotImplementedError(RuntimeError): ... -class IndentationError(SyntaxError): ... -class TabError(IndentationError): ... -class UnicodeError(ValueError): ... - -class UnicodeDecodeError(UnicodeError): - encoding: str - object: bytes - start: int - end: int - reason: str - def __init__(self, __encoding: str, __object: bytes, __start: int, __end: int, __reason: str) -> None: ... - -class UnicodeEncodeError(UnicodeError): - encoding: str - object: Text - start: int - end: int - reason: str - def __init__(self, __encoding: str, __object: Text, __start: int, __end: int, __reason: str) -> None: ... - -class UnicodeTranslateError(UnicodeError): ... -class Warning(Exception): ... -class UserWarning(Warning): ... -class DeprecationWarning(Warning): ... -class SyntaxWarning(Warning): ... -class RuntimeWarning(Warning): ... -class FutureWarning(Warning): ... -class PendingDeprecationWarning(Warning): ... -class ImportWarning(Warning): ... -class UnicodeWarning(Warning): ... -class BytesWarning(Warning): ... - -class file(BinaryIO): - @overload - def __init__(self, file: str, mode: str = ..., buffering: int = ...) -> None: ... - @overload - def __init__(self, file: unicode, mode: str = ..., buffering: int = ...) -> None: ... - @overload - def __init__(self, file: int, mode: str = ..., buffering: int = ...) -> None: ... - def __iter__(self) -> Iterator[str]: ... - def next(self) -> str: ... - def read(self, n: int = ...) -> str: ... - def __enter__(self) -> BinaryIO: ... - def __exit__(self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ...) -> bool | None: ... - def flush(self) -> None: ... - def fileno(self) -> int: ... - def isatty(self) -> bool: ... - def close(self) -> None: ... - def readable(self) -> bool: ... - def writable(self) -> bool: ... - def seekable(self) -> bool: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def tell(self) -> int: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> list[str]: ... - def write(self, data: str) -> int: ... - def writelines(self, data: Iterable[str]) -> None: ... - def truncate(self, pos: int | None = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/__future__.pyi b/mypy/typeshed/stdlib/@python2/__future__.pyi deleted file mode 100644 index df05b0d7c2de..000000000000 --- a/mypy/typeshed/stdlib/@python2/__future__.pyi +++ /dev/null @@ -1,16 +0,0 @@ -import sys - -class _Feature: - def __init__(self, optionalRelease: sys._version_info, mandatoryRelease: sys._version_info, compiler_flag: int) -> None: ... - def getOptionalRelease(self) -> sys._version_info: ... - def getMandatoryRelease(self) -> sys._version_info: ... - compiler_flag: int - -absolute_import: _Feature -division: _Feature -generators: _Feature -nested_scopes: _Feature -print_function: _Feature -unicode_literals: _Feature -with_statement: _Feature -all_feature_names: list[str] # undocumented diff --git a/mypy/typeshed/stdlib/@python2/__main__.pyi b/mypy/typeshed/stdlib/@python2/__main__.pyi deleted file mode 100644 index e27843e53382..000000000000 --- a/mypy/typeshed/stdlib/@python2/__main__.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from typing import Any - -def __getattr__(name: str) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/_ast.pyi b/mypy/typeshed/stdlib/@python2/_ast.pyi deleted file mode 100644 index c81dc09abb57..000000000000 --- a/mypy/typeshed/stdlib/@python2/_ast.pyi +++ /dev/null @@ -1,300 +0,0 @@ -__version__: str -PyCF_ONLY_AST: int -_identifier = str - -class AST: - _attributes: tuple[str, ...] - _fields: tuple[str, ...] - def __init__(self, *args, **kwargs) -> None: ... - -class mod(AST): ... - -class Module(mod): - body: list[stmt] - -class Interactive(mod): - body: list[stmt] - -class Expression(mod): - body: expr - -class Suite(mod): - body: list[stmt] - -class stmt(AST): - lineno: int - col_offset: int - -class FunctionDef(stmt): - name: _identifier - args: arguments - body: list[stmt] - decorator_list: list[expr] - -class ClassDef(stmt): - name: _identifier - bases: list[expr] - body: list[stmt] - decorator_list: list[expr] - -class Return(stmt): - value: expr | None - -class Delete(stmt): - targets: list[expr] - -class Assign(stmt): - targets: list[expr] - value: expr - -class AugAssign(stmt): - target: expr - op: operator - value: expr - -class Print(stmt): - dest: expr | None - values: list[expr] - nl: bool - -class For(stmt): - target: expr - iter: expr - body: list[stmt] - orelse: list[stmt] - -class While(stmt): - test: expr - body: list[stmt] - orelse: list[stmt] - -class If(stmt): - test: expr - body: list[stmt] - orelse: list[stmt] - -class With(stmt): - context_expr: expr - optional_vars: expr | None - body: list[stmt] - -class Raise(stmt): - type: expr | None - inst: expr | None - tback: expr | None - -class TryExcept(stmt): - body: list[stmt] - handlers: list[ExceptHandler] - orelse: list[stmt] - -class TryFinally(stmt): - body: list[stmt] - finalbody: list[stmt] - -class Assert(stmt): - test: expr - msg: expr | None - -class Import(stmt): - names: list[alias] - -class ImportFrom(stmt): - module: _identifier | None - names: list[alias] - level: int | None - -class Exec(stmt): - body: expr - globals: expr | None - locals: expr | None - -class Global(stmt): - names: list[_identifier] - -class Expr(stmt): - value: expr - -class Pass(stmt): ... -class Break(stmt): ... -class Continue(stmt): ... -class slice(AST): ... - -_slice = slice # this lets us type the variable named 'slice' below - -class Slice(slice): - lower: expr | None - upper: expr | None - step: expr | None - -class ExtSlice(slice): - dims: list[slice] - -class Index(slice): - value: expr - -class Ellipsis(slice): ... - -class expr(AST): - lineno: int - col_offset: int - -class BoolOp(expr): - op: boolop - values: list[expr] - -class BinOp(expr): - left: expr - op: operator - right: expr - -class UnaryOp(expr): - op: unaryop - operand: expr - -class Lambda(expr): - args: arguments - body: expr - -class IfExp(expr): - test: expr - body: expr - orelse: expr - -class Dict(expr): - keys: list[expr] - values: list[expr] - -class Set(expr): - elts: list[expr] - -class ListComp(expr): - elt: expr - generators: list[comprehension] - -class SetComp(expr): - elt: expr - generators: list[comprehension] - -class DictComp(expr): - key: expr - value: expr - generators: list[comprehension] - -class GeneratorExp(expr): - elt: expr - generators: list[comprehension] - -class Yield(expr): - value: expr | None - -class Compare(expr): - left: expr - ops: list[cmpop] - comparators: list[expr] - -class Call(expr): - func: expr - args: list[expr] - keywords: list[keyword] - starargs: expr | None - kwargs: expr | None - -class Repr(expr): - value: expr - -class Num(expr): - n: float - -class Str(expr): - s: str - -class Attribute(expr): - value: expr - attr: _identifier - ctx: expr_context - -class Subscript(expr): - value: expr - slice: _slice - ctx: expr_context - -class Name(expr): - id: _identifier - ctx: expr_context - -class List(expr): - elts: list[expr] - ctx: expr_context - -class Tuple(expr): - elts: list[expr] - ctx: expr_context - -class expr_context(AST): ... -class AugLoad(expr_context): ... -class AugStore(expr_context): ... -class Del(expr_context): ... -class Load(expr_context): ... -class Param(expr_context): ... -class Store(expr_context): ... -class boolop(AST): ... -class And(boolop): ... -class Or(boolop): ... -class operator(AST): ... -class Add(operator): ... -class BitAnd(operator): ... -class BitOr(operator): ... -class BitXor(operator): ... -class Div(operator): ... -class FloorDiv(operator): ... -class LShift(operator): ... -class Mod(operator): ... -class Mult(operator): ... -class Pow(operator): ... -class RShift(operator): ... -class Sub(operator): ... -class unaryop(AST): ... -class Invert(unaryop): ... -class Not(unaryop): ... -class UAdd(unaryop): ... -class USub(unaryop): ... -class cmpop(AST): ... -class Eq(cmpop): ... -class Gt(cmpop): ... -class GtE(cmpop): ... -class In(cmpop): ... -class Is(cmpop): ... -class IsNot(cmpop): ... -class Lt(cmpop): ... -class LtE(cmpop): ... -class NotEq(cmpop): ... -class NotIn(cmpop): ... - -class comprehension(AST): - target: expr - iter: expr - ifs: list[expr] - -class excepthandler(AST): ... - -class ExceptHandler(excepthandler): - type: expr | None - name: expr | None - body: list[stmt] - lineno: int - col_offset: int - -class arguments(AST): - args: list[expr] - vararg: _identifier | None - kwarg: _identifier | None - defaults: list[expr] - -class keyword(AST): - arg: _identifier - value: expr - -class alias(AST): - name: _identifier - asname: _identifier | None diff --git a/mypy/typeshed/stdlib/@python2/_bisect.pyi b/mypy/typeshed/stdlib/@python2/_bisect.pyi deleted file mode 100644 index e3327a0af4e6..000000000000 --- a/mypy/typeshed/stdlib/@python2/_bisect.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import MutableSequence, Sequence, TypeVar - -_T = TypeVar("_T") - -def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ... -def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ... -def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ... -def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_codecs.pyi b/mypy/typeshed/stdlib/@python2/_codecs.pyi deleted file mode 100644 index 1028cfec1aef..000000000000 --- a/mypy/typeshed/stdlib/@python2/_codecs.pyi +++ /dev/null @@ -1,66 +0,0 @@ -import codecs -import sys -from typing import Any, Callable, Text - -# For convenience: -_Handler = Callable[[Exception], tuple[Text, int]] -_String = bytes | str -_Errors = str | Text | None -_Decodable = bytes | Text -_Encodable = bytes | Text - -# This type is not exposed; it is defined in unicodeobject.c -class _EncodingMap(object): - def size(self) -> int: ... - -_MapT = dict[int, int] | _EncodingMap - -def register(__search_function: Callable[[str], Any]) -> None: ... -def register_error(__errors: str | Text, __handler: _Handler) -> None: ... -def lookup(__encoding: str | Text) -> codecs.CodecInfo: ... -def lookup_error(__name: str | Text) -> _Handler: ... -def decode(obj: Any, encoding: str | Text = ..., errors: _Errors = ...) -> Any: ... -def encode(obj: Any, encoding: str | Text = ..., errors: _Errors = ...) -> Any: ... -def charmap_build(__map: Text) -> _MapT: ... -def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> tuple[Text, int]: ... -def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: _MapT | None = ...) -> tuple[Text, int]: ... -def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: _MapT | None = ...) -> tuple[bytes, int]: ... -def escape_decode(__data: _String, __errors: _Errors = ...) -> tuple[str, int]: ... -def escape_encode(__data: bytes, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def latin_1_decode(__data: _Decodable, __errors: _Errors = ...) -> tuple[Text, int]: ... -def latin_1_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def raw_unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> tuple[Text, int]: ... -def raw_unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> tuple[Text, int]: ... -def unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def unicode_internal_decode(__obj: _String, __errors: _Errors = ...) -> tuple[Text, int]: ... -def unicode_internal_encode(__obj: _String, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def utf_16_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_16_be_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def utf_16_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_16_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> tuple[bytes, int]: ... -def utf_16_ex_decode( - __data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ... -) -> tuple[Text, int, int]: ... -def utf_16_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_16_le_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def utf_32_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_32_be_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def utf_32_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_32_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> tuple[bytes, int]: ... -def utf_32_ex_decode( - __data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ... -) -> tuple[Text, int, int]: ... -def utf_32_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_32_le_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def utf_7_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_7_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... -def utf_8_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... -def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... - -if sys.platform == "win32": - def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> tuple[Text, int]: ... - def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> tuple[bytes, int]: ... diff --git a/mypy/typeshed/stdlib/@python2/_collections.pyi b/mypy/typeshed/stdlib/@python2/_collections.pyi deleted file mode 100644 index 6f0ee3f8740b..000000000000 --- a/mypy/typeshed/stdlib/@python2/_collections.pyi +++ /dev/null @@ -1,36 +0,0 @@ -from _typeshed import Self -from typing import Any, Callable, Generic, Iterator, TypeVar - -_K = TypeVar("_K") -_V = TypeVar("_V") -_T = TypeVar("_T") - -class defaultdict(dict[_K, _V]): - default_factory: None - def __init__(self, __default_factory: Callable[[], _V] = ..., init: Any = ...) -> None: ... - def __missing__(self, key: _K) -> _V: ... - def __copy__(self: Self) -> Self: ... - def copy(self: Self) -> Self: ... - -class deque(Generic[_T]): - maxlen: int | None - def __init__(self, iterable: Iterator[_T] = ..., maxlen: int = ...) -> None: ... - def append(self, x: _T) -> None: ... - def appendleft(self, x: _T) -> None: ... - def clear(self) -> None: ... - def count(self, x: Any) -> int: ... - def extend(self, iterable: Iterator[_T]) -> None: ... - def extendleft(self, iterable: Iterator[_T]) -> None: ... - def pop(self) -> _T: ... - def popleft(self) -> _T: ... - def remove(self, value: _T) -> None: ... - def reverse(self) -> None: ... - def rotate(self, n: int = ...) -> None: ... - def __contains__(self, o: Any) -> bool: ... - def __copy__(self) -> deque[_T]: ... - def __getitem__(self, i: int) -> _T: ... - def __iadd__(self: Self, other: deque[_T]) -> Self: ... - def __iter__(self) -> Iterator[_T]: ... - def __len__(self) -> int: ... - def __reversed__(self) -> Iterator[_T]: ... - def __setitem__(self, i: int, x: _T) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_csv.pyi b/mypy/typeshed/stdlib/@python2/_csv.pyi deleted file mode 100644 index e01ccc19cb19..000000000000 --- a/mypy/typeshed/stdlib/@python2/_csv.pyi +++ /dev/null @@ -1,42 +0,0 @@ -from typing import Any, Iterable, Iterator, Protocol, Sequence, Text, Union - -QUOTE_ALL: int -QUOTE_MINIMAL: int -QUOTE_NONE: int -QUOTE_NONNUMERIC: int - -class Error(Exception): ... - -class Dialect: - delimiter: str - quotechar: str | None - escapechar: str | None - doublequote: bool - skipinitialspace: bool - lineterminator: str - quoting: int - strict: int - def __init__(self) -> None: ... - -_DialectLike = Union[str, Dialect, type[Dialect]] - -class _reader(Iterator[list[str]]): - dialect: Dialect - line_num: int - def next(self) -> list[str]: ... - -class _writer: - dialect: Dialect - def writerow(self, row: Sequence[Any]) -> Any: ... - def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... - -class _Writer(Protocol): - def write(self, s: str) -> Any: ... - -def writer(csvfile: _Writer, dialect: _DialectLike = ..., **fmtparams: Any) -> _writer: ... -def reader(csvfile: Iterable[Text], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ... -def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ... -def unregister_dialect(name: str) -> None: ... -def get_dialect(name: str) -> Dialect: ... -def list_dialects() -> list[str]: ... -def field_size_limit(new_limit: int = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/_curses.pyi b/mypy/typeshed/stdlib/@python2/_curses.pyi deleted file mode 100644 index 81de0ea96e3f..000000000000 --- a/mypy/typeshed/stdlib/@python2/_curses.pyi +++ /dev/null @@ -1,511 +0,0 @@ -from typing import IO, Any, BinaryIO, overload - -_chtype = str | bytes | int - -# ACS codes are only initialized after initscr is called -ACS_BBSS: int -ACS_BLOCK: int -ACS_BOARD: int -ACS_BSBS: int -ACS_BSSB: int -ACS_BSSS: int -ACS_BTEE: int -ACS_BULLET: int -ACS_CKBOARD: int -ACS_DARROW: int -ACS_DEGREE: int -ACS_DIAMOND: int -ACS_GEQUAL: int -ACS_HLINE: int -ACS_LANTERN: int -ACS_LARROW: int -ACS_LEQUAL: int -ACS_LLCORNER: int -ACS_LRCORNER: int -ACS_LTEE: int -ACS_NEQUAL: int -ACS_PI: int -ACS_PLMINUS: int -ACS_PLUS: int -ACS_RARROW: int -ACS_RTEE: int -ACS_S1: int -ACS_S3: int -ACS_S7: int -ACS_S9: int -ACS_SBBS: int -ACS_SBSB: int -ACS_SBSS: int -ACS_SSBB: int -ACS_SSBS: int -ACS_SSSB: int -ACS_SSSS: int -ACS_STERLING: int -ACS_TTEE: int -ACS_UARROW: int -ACS_ULCORNER: int -ACS_URCORNER: int -ACS_VLINE: int -ALL_MOUSE_EVENTS: int -A_ALTCHARSET: int -A_ATTRIBUTES: int -A_BLINK: int -A_BOLD: int -A_CHARTEXT: int -A_COLOR: int -A_DIM: int -A_HORIZONTAL: int -A_INVIS: int -A_LEFT: int -A_LOW: int -A_NORMAL: int -A_PROTECT: int -A_REVERSE: int -A_RIGHT: int -A_STANDOUT: int -A_TOP: int -A_UNDERLINE: int -A_VERTICAL: int -BUTTON1_CLICKED: int -BUTTON1_DOUBLE_CLICKED: int -BUTTON1_PRESSED: int -BUTTON1_RELEASED: int -BUTTON1_TRIPLE_CLICKED: int -BUTTON2_CLICKED: int -BUTTON2_DOUBLE_CLICKED: int -BUTTON2_PRESSED: int -BUTTON2_RELEASED: int -BUTTON2_TRIPLE_CLICKED: int -BUTTON3_CLICKED: int -BUTTON3_DOUBLE_CLICKED: int -BUTTON3_PRESSED: int -BUTTON3_RELEASED: int -BUTTON3_TRIPLE_CLICKED: int -BUTTON4_CLICKED: int -BUTTON4_DOUBLE_CLICKED: int -BUTTON4_PRESSED: int -BUTTON4_RELEASED: int -BUTTON4_TRIPLE_CLICKED: int -BUTTON_ALT: int -BUTTON_CTRL: int -BUTTON_SHIFT: int -COLOR_BLACK: int -COLOR_BLUE: int -COLOR_CYAN: int -COLOR_GREEN: int -COLOR_MAGENTA: int -COLOR_RED: int -COLOR_WHITE: int -COLOR_YELLOW: int -ERR: int -KEY_A1: int -KEY_A3: int -KEY_B2: int -KEY_BACKSPACE: int -KEY_BEG: int -KEY_BREAK: int -KEY_BTAB: int -KEY_C1: int -KEY_C3: int -KEY_CANCEL: int -KEY_CATAB: int -KEY_CLEAR: int -KEY_CLOSE: int -KEY_COMMAND: int -KEY_COPY: int -KEY_CREATE: int -KEY_CTAB: int -KEY_DC: int -KEY_DL: int -KEY_DOWN: int -KEY_EIC: int -KEY_END: int -KEY_ENTER: int -KEY_EOL: int -KEY_EOS: int -KEY_EXIT: int -KEY_F0: int -KEY_F1: int -KEY_F10: int -KEY_F11: int -KEY_F12: int -KEY_F13: int -KEY_F14: int -KEY_F15: int -KEY_F16: int -KEY_F17: int -KEY_F18: int -KEY_F19: int -KEY_F2: int -KEY_F20: int -KEY_F21: int -KEY_F22: int -KEY_F23: int -KEY_F24: int -KEY_F25: int -KEY_F26: int -KEY_F27: int -KEY_F28: int -KEY_F29: int -KEY_F3: int -KEY_F30: int -KEY_F31: int -KEY_F32: int -KEY_F33: int -KEY_F34: int -KEY_F35: int -KEY_F36: int -KEY_F37: int -KEY_F38: int -KEY_F39: int -KEY_F4: int -KEY_F40: int -KEY_F41: int -KEY_F42: int -KEY_F43: int -KEY_F44: int -KEY_F45: int -KEY_F46: int -KEY_F47: int -KEY_F48: int -KEY_F49: int -KEY_F5: int -KEY_F50: int -KEY_F51: int -KEY_F52: int -KEY_F53: int -KEY_F54: int -KEY_F55: int -KEY_F56: int -KEY_F57: int -KEY_F58: int -KEY_F59: int -KEY_F6: int -KEY_F60: int -KEY_F61: int -KEY_F62: int -KEY_F63: int -KEY_F7: int -KEY_F8: int -KEY_F9: int -KEY_FIND: int -KEY_HELP: int -KEY_HOME: int -KEY_IC: int -KEY_IL: int -KEY_LEFT: int -KEY_LL: int -KEY_MARK: int -KEY_MAX: int -KEY_MESSAGE: int -KEY_MIN: int -KEY_MOUSE: int -KEY_MOVE: int -KEY_NEXT: int -KEY_NPAGE: int -KEY_OPEN: int -KEY_OPTIONS: int -KEY_PPAGE: int -KEY_PREVIOUS: int -KEY_PRINT: int -KEY_REDO: int -KEY_REFERENCE: int -KEY_REFRESH: int -KEY_REPLACE: int -KEY_RESET: int -KEY_RESIZE: int -KEY_RESTART: int -KEY_RESUME: int -KEY_RIGHT: int -KEY_SAVE: int -KEY_SBEG: int -KEY_SCANCEL: int -KEY_SCOMMAND: int -KEY_SCOPY: int -KEY_SCREATE: int -KEY_SDC: int -KEY_SDL: int -KEY_SELECT: int -KEY_SEND: int -KEY_SEOL: int -KEY_SEXIT: int -KEY_SF: int -KEY_SFIND: int -KEY_SHELP: int -KEY_SHOME: int -KEY_SIC: int -KEY_SLEFT: int -KEY_SMESSAGE: int -KEY_SMOVE: int -KEY_SNEXT: int -KEY_SOPTIONS: int -KEY_SPREVIOUS: int -KEY_SPRINT: int -KEY_SR: int -KEY_SREDO: int -KEY_SREPLACE: int -KEY_SRESET: int -KEY_SRIGHT: int -KEY_SRSUME: int -KEY_SSAVE: int -KEY_SSUSPEND: int -KEY_STAB: int -KEY_SUNDO: int -KEY_SUSPEND: int -KEY_UNDO: int -KEY_UP: int -OK: int -REPORT_MOUSE_POSITION: int -_C_API: Any -version: bytes - -def baudrate() -> int: ... -def beep() -> None: ... -def can_change_color() -> bool: ... -def cbreak(__flag: bool = ...) -> None: ... -def color_content(__color_number: int) -> tuple[int, int, int]: ... - -# Changed in Python 3.8.8 and 3.9.2 -def color_pair(__color_number: int) -> int: ... -def curs_set(__visibility: int) -> int: ... -def def_prog_mode() -> None: ... -def def_shell_mode() -> None: ... -def delay_output(__ms: int) -> None: ... -def doupdate() -> None: ... -def echo(__flag: bool = ...) -> None: ... -def endwin() -> None: ... -def erasechar() -> bytes: ... -def filter() -> None: ... -def flash() -> None: ... -def flushinp() -> None: ... -def getmouse() -> tuple[int, int, int, int, int]: ... -def getsyx() -> tuple[int, int]: ... -def getwin(__file: BinaryIO) -> _CursesWindow: ... -def halfdelay(__tenths: int) -> None: ... -def has_colors() -> bool: ... -def has_ic() -> bool: ... -def has_il() -> bool: ... -def has_key(__key: int) -> bool: ... -def init_color(__color_number: int, __r: int, __g: int, __b: int) -> None: ... -def init_pair(__pair_number: int, __fg: int, __bg: int) -> None: ... -def initscr() -> _CursesWindow: ... -def intrflush(__flag: bool) -> None: ... -def is_term_resized(__nlines: int, __ncols: int) -> bool: ... -def isendwin() -> bool: ... -def keyname(__key: int) -> bytes: ... -def killchar() -> bytes: ... -def longname() -> bytes: ... -def meta(__yes: bool) -> None: ... -def mouseinterval(__interval: int) -> None: ... -def mousemask(__newmask: int) -> tuple[int, int]: ... -def napms(__ms: int) -> int: ... -def newpad(__nlines: int, __ncols: int) -> _CursesWindow: ... -def newwin(__nlines: int, __ncols: int, __begin_y: int = ..., __begin_x: int = ...) -> _CursesWindow: ... -def nl(__flag: bool = ...) -> None: ... -def nocbreak() -> None: ... -def noecho() -> None: ... -def nonl() -> None: ... -def noqiflush() -> None: ... -def noraw() -> None: ... -def pair_content(__pair_number: int) -> tuple[int, int]: ... -def pair_number(__attr: int) -> int: ... -def putp(__string: bytes) -> None: ... -def qiflush(__flag: bool = ...) -> None: ... -def raw(__flag: bool = ...) -> None: ... -def reset_prog_mode() -> None: ... -def reset_shell_mode() -> None: ... -def resetty() -> None: ... -def resize_term(__nlines: int, __ncols: int) -> None: ... -def resizeterm(__nlines: int, __ncols: int) -> None: ... -def savetty() -> None: ... -def setsyx(__y: int, __x: int) -> None: ... -def setupterm(term: str | None = ..., fd: int = ...) -> None: ... -def start_color() -> None: ... -def termattrs() -> int: ... -def termname() -> bytes: ... -def tigetflag(__capname: str) -> int: ... -def tigetnum(__capname: str) -> int: ... -def tigetstr(__capname: str) -> bytes: ... -def tparm( - __str: bytes, - __i1: int = ..., - __i2: int = ..., - __i3: int = ..., - __i4: int = ..., - __i5: int = ..., - __i6: int = ..., - __i7: int = ..., - __i8: int = ..., - __i9: int = ..., -) -> bytes: ... -def typeahead(__fd: int) -> None: ... -def unctrl(__ch: _chtype) -> bytes: ... -def ungetch(__ch: _chtype) -> None: ... -def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ... -def use_default_colors() -> None: ... -def use_env(__flag: bool) -> None: ... - -class error(Exception): ... - -class _CursesWindow: - @overload - def addch(self, ch: _chtype, attr: int = ...) -> None: ... - @overload - def addch(self, y: int, x: int, ch: _chtype, attr: int = ...) -> None: ... - @overload - def addnstr(self, str: str, n: int, attr: int = ...) -> None: ... - @overload - def addnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ... - @overload - def addstr(self, str: str, attr: int = ...) -> None: ... - @overload - def addstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ... - def attroff(self, __attr: int) -> None: ... - def attron(self, __attr: int) -> None: ... - def attrset(self, __attr: int) -> None: ... - def bkgd(self, __ch: _chtype, __attr: int = ...) -> None: ... - def bkgdset(self, __ch: _chtype, __attr: int = ...) -> None: ... - def border( - self, - ls: _chtype = ..., - rs: _chtype = ..., - ts: _chtype = ..., - bs: _chtype = ..., - tl: _chtype = ..., - tr: _chtype = ..., - bl: _chtype = ..., - br: _chtype = ..., - ) -> None: ... - @overload - def box(self) -> None: ... - @overload - def box(self, vertch: _chtype = ..., horch: _chtype = ...) -> None: ... - @overload - def chgat(self, attr: int) -> None: ... - @overload - def chgat(self, num: int, attr: int) -> None: ... - @overload - def chgat(self, y: int, x: int, attr: int) -> None: ... - @overload - def chgat(self, y: int, x: int, num: int, attr: int) -> None: ... - def clear(self) -> None: ... - def clearok(self, yes: int) -> None: ... - def clrtobot(self) -> None: ... - def clrtoeol(self) -> None: ... - def cursyncup(self) -> None: ... - @overload - def delch(self) -> None: ... - @overload - def delch(self, y: int, x: int) -> None: ... - def deleteln(self) -> None: ... - @overload - def derwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ... - @overload - def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ... - def echochar(self, __ch: _chtype, __attr: int = ...) -> None: ... - def enclose(self, __y: int, __x: int) -> bool: ... - def erase(self) -> None: ... - def getbegyx(self) -> tuple[int, int]: ... - def getbkgd(self) -> tuple[int, int]: ... - @overload - def getch(self) -> int: ... - @overload - def getch(self, y: int, x: int) -> int: ... - @overload - def getkey(self) -> str: ... - @overload - def getkey(self, y: int, x: int) -> str: ... - def getmaxyx(self) -> tuple[int, int]: ... - def getparyx(self) -> tuple[int, int]: ... - @overload - def getstr(self) -> _chtype: ... - @overload - def getstr(self, n: int) -> _chtype: ... - @overload - def getstr(self, y: int, x: int) -> _chtype: ... - @overload - def getstr(self, y: int, x: int, n: int) -> _chtype: ... - def getyx(self) -> tuple[int, int]: ... - @overload - def hline(self, ch: _chtype, n: int) -> None: ... - @overload - def hline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... - def idcok(self, flag: bool) -> None: ... - def idlok(self, yes: bool) -> None: ... - def immedok(self, flag: bool) -> None: ... - @overload - def inch(self) -> _chtype: ... - @overload - def inch(self, y: int, x: int) -> _chtype: ... - @overload - def insch(self, ch: _chtype, attr: int = ...) -> None: ... - @overload - def insch(self, y: int, x: int, ch: _chtype, attr: int = ...) -> None: ... - def insdelln(self, nlines: int) -> None: ... - def insertln(self) -> None: ... - @overload - def insnstr(self, str: str, n: int, attr: int = ...) -> None: ... - @overload - def insnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ... - @overload - def insstr(self, str: str, attr: int = ...) -> None: ... - @overload - def insstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ... - @overload - def instr(self, n: int = ...) -> _chtype: ... - @overload - def instr(self, y: int, x: int, n: int = ...) -> _chtype: ... - def is_linetouched(self, __line: int) -> bool: ... - def is_wintouched(self) -> bool: ... - def keypad(self, yes: bool) -> None: ... - def leaveok(self, yes: bool) -> None: ... - def move(self, new_y: int, new_x: int) -> None: ... - def mvderwin(self, y: int, x: int) -> None: ... - def mvwin(self, new_y: int, new_x: int) -> None: ... - def nodelay(self, yes: bool) -> None: ... - def notimeout(self, yes: bool) -> None: ... - def noutrefresh(self) -> None: ... - @overload - def overlay(self, destwin: _CursesWindow) -> None: ... - @overload - def overlay( - self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int - ) -> None: ... - @overload - def overwrite(self, destwin: _CursesWindow) -> None: ... - @overload - def overwrite( - self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int - ) -> None: ... - def putwin(self, __file: IO[Any]) -> None: ... - def redrawln(self, __beg: int, __num: int) -> None: ... - def redrawwin(self) -> None: ... - @overload - def refresh(self) -> None: ... - @overload - def refresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ... - def resize(self, nlines: int, ncols: int) -> None: ... - def scroll(self, lines: int = ...) -> None: ... - def scrollok(self, flag: bool) -> None: ... - def setscrreg(self, __top: int, __bottom: int) -> None: ... - def standend(self) -> None: ... - def standout(self) -> None: ... - @overload - def subpad(self, begin_y: int, begin_x: int) -> _CursesWindow: ... - @overload - def subpad(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ... - @overload - def subwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ... - @overload - def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ... - def syncdown(self) -> None: ... - def syncok(self, flag: bool) -> None: ... - def syncup(self) -> None: ... - def timeout(self, delay: int) -> None: ... - def touchline(self, start: int, count: int, changed: bool = ...) -> None: ... - def touchwin(self) -> None: ... - def untouchwin(self) -> None: ... - @overload - def vline(self, ch: _chtype, n: int) -> None: ... - @overload - def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_dummy_threading.pyi b/mypy/typeshed/stdlib/@python2/_dummy_threading.pyi deleted file mode 100644 index e7b0a9e4b363..000000000000 --- a/mypy/typeshed/stdlib/@python2/_dummy_threading.pyi +++ /dev/null @@ -1,126 +0,0 @@ -from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, Mapping, Text - -# TODO recursive type -_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] - -_PF = Callable[[FrameType, str, Any], None] - -__all__ = [ - "activeCount", - "active_count", - "Condition", - "currentThread", - "current_thread", - "enumerate", - "Event", - "Lock", - "RLock", - "Semaphore", - "BoundedSemaphore", - "Thread", - "Timer", - "setprofile", - "settrace", - "local", - "stack_size", -] - -def active_count() -> int: ... -def activeCount() -> int: ... -def current_thread() -> Thread: ... -def currentThread() -> Thread: ... -def enumerate() -> list[Thread]: ... -def settrace(func: _TF) -> None: ... -def setprofile(func: _PF | None) -> None: ... -def stack_size(size: int = ...) -> int: ... - -class ThreadError(Exception): ... - -class local(object): - def __getattribute__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __delattr__(self, name: str) -> None: ... - -class Thread: - name: str - ident: int | None - daemon: bool - def __init__( - self, - group: None = ..., - target: Callable[..., Any] | None = ..., - name: Text | None = ..., - args: Iterable[Any] = ..., - kwargs: Mapping[Text, Any] | None = ..., - ) -> None: ... - def start(self) -> None: ... - def run(self) -> None: ... - def join(self, timeout: float | None = ...) -> None: ... - def getName(self) -> str: ... - def setName(self, name: Text) -> None: ... - def is_alive(self) -> bool: ... - def isAlive(self) -> bool: ... - def isDaemon(self) -> bool: ... - def setDaemon(self, daemonic: bool) -> None: ... - -class _DummyThread(Thread): ... - -class Lock: - def __init__(self) -> None: ... - def __enter__(self) -> bool: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - def locked(self) -> bool: ... - -class _RLock: - def __init__(self) -> None: ... - def __enter__(self) -> bool: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - -RLock = _RLock - -class Condition: - def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... - def __enter__(self) -> bool: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - def wait(self, timeout: float | None = ...) -> bool: ... - def notify(self, n: int = ...) -> None: ... - def notify_all(self) -> None: ... - def notifyAll(self) -> None: ... - -class Semaphore: - def __init__(self, value: int = ...) -> None: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - -class BoundedSemaphore(Semaphore): ... - -class Event: - def __init__(self) -> None: ... - def is_set(self) -> bool: ... - def isSet(self) -> bool: ... - def set(self) -> None: ... - def clear(self) -> None: ... - def wait(self, timeout: float | None = ...) -> bool: ... - -class Timer(Thread): - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... - def cancel(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_functools.pyi b/mypy/typeshed/stdlib/@python2/_functools.pyi deleted file mode 100644 index d695e76994c9..000000000000 --- a/mypy/typeshed/stdlib/@python2/_functools.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Any, Callable, Iterable, TypeVar, overload - -_T = TypeVar("_T") -_S = TypeVar("_S") - -@overload -def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ... -@overload -def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ... - -class partial(object): - func: Callable[..., Any] - args: tuple[Any, ...] - keywords: dict[str, Any] - def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/_heapq.pyi b/mypy/typeshed/stdlib/@python2/_heapq.pyi deleted file mode 100644 index a2a38dc9c3ed..000000000000 --- a/mypy/typeshed/stdlib/@python2/_heapq.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Any, Callable, Iterable, TypeVar - -_T = TypeVar("_T") - -def heapify(__heap: list[Any]) -> None: ... -def heappop(__heap: list[_T]) -> _T: ... -def heappush(__heap: list[_T], __item: _T) -> None: ... -def heappushpop(__heap: list[_T], __item: _T) -> _T: ... -def heapreplace(__heap: list[_T], __item: _T) -> _T: ... -def nlargest(__n: int, __iterable: Iterable[_T], __key: Callable[[_T], Any] | None = ...) -> list[_T]: ... -def nsmallest(__n: int, __iterable: Iterable[_T], __key: Callable[[_T], Any] | None = ...) -> list[_T]: ... diff --git a/mypy/typeshed/stdlib/@python2/_hotshot.pyi b/mypy/typeshed/stdlib/@python2/_hotshot.pyi deleted file mode 100644 index aa188a2b4fae..000000000000 --- a/mypy/typeshed/stdlib/@python2/_hotshot.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Any - -def coverage(a: str) -> Any: ... -def logreader(a: str) -> LogReaderType: ... -def profiler(a: str, *args, **kwargs) -> Any: ... -def resolution() -> tuple[Any, ...]: ... - -class LogReaderType(object): - def close(self) -> None: ... - def fileno(self) -> int: ... - -class ProfilerType(object): - def addinfo(self, a: str, b: str) -> None: ... - def close(self) -> None: ... - def fileno(self) -> int: ... - def runcall(self, *args, **kwargs) -> Any: ... - def runcode(self, a, b, *args, **kwargs) -> Any: ... - def start(self) -> None: ... - def stop(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_io.pyi b/mypy/typeshed/stdlib/@python2/_io.pyi deleted file mode 100644 index 65c59ccf7715..000000000000 --- a/mypy/typeshed/stdlib/@python2/_io.pyi +++ /dev/null @@ -1,178 +0,0 @@ -from _typeshed import Self -from mmap import mmap -from typing import IO, Any, BinaryIO, Iterable, Text, TextIO - -_bytearray_like = bytearray | mmap - -DEFAULT_BUFFER_SIZE: int - -class BlockingIOError(IOError): - characters_written: int - -class UnsupportedOperation(ValueError, IOError): ... - -class _IOBase(BinaryIO): - @property - def closed(self) -> bool: ... - def _checkClosed(self, msg: str | None = ...) -> None: ... # undocumented - def _checkReadable(self) -> None: ... - def _checkSeekable(self) -> None: ... - def _checkWritable(self) -> None: ... - # All these methods are concrete here (you can instantiate this) - def close(self) -> None: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def readable(self) -> bool: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: int | None = ...) -> int: ... - def writable(self) -> bool: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, t: type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ... - def __iter__(self: Self) -> Self: ... - # The parameter type of writelines[s]() is determined by that of write(): - def writelines(self, lines: Iterable[bytes]) -> None: ... - # The return type of readline[s]() and next() is determined by that of read(): - def readline(self, limit: int | None = ...) -> bytes: ... - def readlines(self, hint: int = ...) -> list[bytes]: ... - def next(self) -> bytes: ... - # These don't actually exist but we need to pretend that it does - # so that this class is concrete. - def write(self, s: bytes) -> int: ... - def read(self, n: int = ...) -> bytes: ... - -class _BufferedIOBase(_IOBase): - def read1(self, n: int) -> bytes: ... - def read(self, size: int = ...) -> bytes: ... - def readinto(self, buffer: _bytearray_like) -> int: ... - def write(self, s: bytes) -> int: ... - def detach(self) -> _IOBase: ... - -class BufferedRWPair(_BufferedIOBase): - def __init__(self, reader: _RawIOBase, writer: _RawIOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ... - def peek(self, n: int = ...) -> bytes: ... - def __enter__(self: Self) -> Self: ... - -class BufferedRandom(_BufferedIOBase): - mode: str - name: str - raw: _IOBase - def __init__(self, raw: _IOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ... - def peek(self, n: int = ...) -> bytes: ... - -class BufferedReader(_BufferedIOBase): - mode: str - name: str - raw: _IOBase - def __init__(self, raw: _IOBase, buffer_size: int = ...) -> None: ... - def peek(self, n: int = ...) -> bytes: ... - -class BufferedWriter(_BufferedIOBase): - name: str - raw: _IOBase - mode: str - def __init__(self, raw: _IOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ... - -class BytesIO(_BufferedIOBase): - def __init__(self, initial_bytes: bytes = ...) -> None: ... - def __setstate__(self, state: tuple[Any, ...]) -> None: ... - def __getstate__(self) -> tuple[Any, ...]: ... - # BytesIO does not contain a "name" field. This workaround is necessary - # to allow BytesIO sub-classes to add this field, as it is defined - # as a read-only property on IO[]. - name: Any - def getvalue(self) -> bytes: ... - def write(self, s: bytes) -> int: ... - def writelines(self, lines: Iterable[bytes]) -> None: ... - def read1(self, size: int) -> bytes: ... - def next(self) -> bytes: ... - -class _RawIOBase(_IOBase): - def readall(self) -> str: ... - def read(self, n: int = ...) -> str: ... - -class FileIO(_RawIOBase, BytesIO): - mode: str - closefd: bool - def __init__(self, file: str | int, mode: str = ..., closefd: bool = ...) -> None: ... - def readinto(self, buffer: _bytearray_like) -> int: ... - def write(self, pbuf: str) -> int: ... - -class IncrementalNewlineDecoder(object): - newlines: str | unicode - def __init__(self, decoder, translate, z=...) -> None: ... - def decode(self, input, final) -> Any: ... - def getstate(self) -> tuple[Any, int]: ... - def setstate(self, state: tuple[Any, int]) -> None: ... - def reset(self) -> None: ... - -# Note: In the actual _io.py, _TextIOBase inherits from _IOBase. -class _TextIOBase(TextIO): - errors: str | None - # TODO: On _TextIOBase, this is always None. But it's unicode/bytes in subclasses. - newlines: None | unicode | bytes - encoding: str - @property - def closed(self) -> bool: ... - def _checkClosed(self) -> None: ... - def _checkReadable(self) -> None: ... - def _checkSeekable(self) -> None: ... - def _checkWritable(self) -> None: ... - def close(self) -> None: ... - def detach(self) -> IO[Any]: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def next(self) -> unicode: ... - def read(self, size: int = ...) -> unicode: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> unicode: ... - def readlines(self, hint: int = ...) -> list[unicode]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: int | None = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, pbuf: unicode) -> int: ... - def writelines(self, lines: Iterable[unicode]) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, t: type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ... - def __iter__(self: Self) -> Self: ... - -class StringIO(_TextIOBase): - line_buffering: bool - def __init__(self, initial_value: unicode | None = ..., newline: unicode | None = ...) -> None: ... - def __setstate__(self, state: tuple[Any, ...]) -> None: ... - def __getstate__(self) -> tuple[Any, ...]: ... - # StringIO does not contain a "name" field. This workaround is necessary - # to allow StringIO sub-classes to add this field, as it is defined - # as a read-only property on IO[]. - name: Any - def getvalue(self) -> unicode: ... - -class TextIOWrapper(_TextIOBase): - name: str - line_buffering: bool - buffer: BinaryIO - _CHUNK_SIZE: int - def __init__( - self, - buffer: IO[Any], - encoding: Text | None = ..., - errors: Text | None = ..., - newline: Text | None = ..., - line_buffering: bool = ..., - write_through: bool = ..., - ) -> None: ... - -def open( - file: str | unicode | int, - mode: Text = ..., - buffering: int = ..., - encoding: Text | None = ..., - errors: Text | None = ..., - newline: Text | None = ..., - closefd: bool = ..., -) -> IO[Any]: ... diff --git a/mypy/typeshed/stdlib/@python2/_json.pyi b/mypy/typeshed/stdlib/@python2/_json.pyi deleted file mode 100644 index 57c70e80564e..000000000000 --- a/mypy/typeshed/stdlib/@python2/_json.pyi +++ /dev/null @@ -1,7 +0,0 @@ -from typing import Any - -def encode_basestring_ascii(*args, **kwargs) -> str: ... -def scanstring(a, b, *args, **kwargs) -> tuple[Any, ...]: ... - -class Encoder(object): ... -class Scanner(object): ... diff --git a/mypy/typeshed/stdlib/@python2/_markupbase.pyi b/mypy/typeshed/stdlib/@python2/_markupbase.pyi deleted file mode 100644 index 368d32bd5b4c..000000000000 --- a/mypy/typeshed/stdlib/@python2/_markupbase.pyi +++ /dev/null @@ -1,6 +0,0 @@ -class ParserBase: - def __init__(self) -> None: ... - def error(self, message: str) -> None: ... - def reset(self) -> None: ... - def getpos(self) -> tuple[int, int]: ... - def unknown_decl(self, data: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_md5.pyi b/mypy/typeshed/stdlib/@python2/_md5.pyi deleted file mode 100644 index 96111b70af9b..000000000000 --- a/mypy/typeshed/stdlib/@python2/_md5.pyi +++ /dev/null @@ -1,13 +0,0 @@ -blocksize: int -digest_size: int - -class MD5Type(object): - name: str - block_size: int - digest_size: int - def copy(self) -> MD5Type: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def update(self, arg: str) -> None: ... - -def new(arg: str = ...) -> MD5Type: ... diff --git a/mypy/typeshed/stdlib/@python2/_msi.pyi b/mypy/typeshed/stdlib/@python2/_msi.pyi deleted file mode 100644 index b7e852f38ae9..000000000000 --- a/mypy/typeshed/stdlib/@python2/_msi.pyi +++ /dev/null @@ -1,48 +0,0 @@ -import sys - -if sys.platform == "win32": - - # Actual typename View, not exposed by the implementation - class _View: - def Execute(self, params: _Record | None = ...) -> None: ... - def GetColumnInfo(self, kind: int) -> _Record: ... - def Fetch(self) -> _Record: ... - def Modify(self, mode: int, record: _Record) -> None: ... - def Close(self) -> None: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - # Actual typename Summary, not exposed by the implementation - class _Summary: - def GetProperty(self, propid: int) -> str | bytes | None: ... - def GetPropertyCount(self) -> int: ... - def SetProperty(self, propid: int, value: str | bytes) -> None: ... - def Persist(self) -> None: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - # Actual typename Database, not exposed by the implementation - class _Database: - def OpenView(self, sql: str) -> _View: ... - def Commit(self) -> None: ... - def GetSummaryInformation(self, updateCount: int) -> _Summary: ... - def Close(self) -> None: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - # Actual typename Record, not exposed by the implementation - class _Record: - def GetFieldCount(self) -> int: ... - def GetInteger(self, field: int) -> int: ... - def GetString(self, field: int) -> str: ... - def SetString(self, field: int, str: str) -> None: ... - def SetStream(self, field: int, stream: str) -> None: ... - def SetInteger(self, field: int, int: int) -> None: ... - def ClearData(self) -> None: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - def UuidCreate() -> str: ... - def FCICreate(cabname: str, files: list[str]) -> None: ... - def OpenDatabase(name: str, flags: int) -> _Database: ... - def CreateRecord(count: int) -> _Record: ... diff --git a/mypy/typeshed/stdlib/@python2/_osx_support.pyi b/mypy/typeshed/stdlib/@python2/_osx_support.pyi deleted file mode 100644 index 27a4a019de58..000000000000 --- a/mypy/typeshed/stdlib/@python2/_osx_support.pyi +++ /dev/null @@ -1,33 +0,0 @@ -from typing import Iterable, Sequence, TypeVar - -_T = TypeVar("_T") -_K = TypeVar("_K") -_V = TypeVar("_V") - -__all__ = ["compiler_fixup", "customize_config_vars", "customize_compiler", "get_platform_osx"] - -_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented -_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented -_INITPRE: str # undocumented - -def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented -def _read_output(commandstring: str) -> str | None: ... # undocumented -def _find_build_tool(toolname: str) -> str: ... # undocumented - -_SYSTEM_VERSION: str | None # undocumented - -def _get_system_version() -> str: ... # undocumented -def _remove_original_values(_config_vars: dict[str, str]) -> None: ... # undocumented -def _save_modified_value(_config_vars: dict[str, str], cv: str, newvalue: str) -> None: ... # undocumented -def _supports_universal_builds() -> bool: ... # undocumented -def _find_appropriate_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented -def _remove_universal_flags(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented -def _remove_unsupported_archs(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented -def _override_all_archs(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented -def _check_for_unavailable_sdk(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented -def compiler_fixup(compiler_so: Iterable[str], cc_args: Sequence[str]) -> list[str]: ... -def customize_config_vars(_config_vars: dict[str, str]) -> dict[str, str]: ... -def customize_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ... -def get_platform_osx( - _config_vars: dict[str, str], osname: _T, release: _K, machine: _V -) -> tuple[str | _T, str | _K, str | _V]: ... diff --git a/mypy/typeshed/stdlib/@python2/_random.pyi b/mypy/typeshed/stdlib/@python2/_random.pyi deleted file mode 100644 index 8bd1afad48cb..000000000000 --- a/mypy/typeshed/stdlib/@python2/_random.pyi +++ /dev/null @@ -1,11 +0,0 @@ -# Actually Tuple[(int,) * 625] -_State = tuple[int, ...] - -class Random(object): - def __init__(self, seed: object = ...) -> None: ... - def seed(self, __n: object = ...) -> None: ... - def getstate(self) -> _State: ... - def setstate(self, __state: _State) -> None: ... - def random(self) -> float: ... - def getrandbits(self, __k: int) -> int: ... - def jumpahead(self, i: int) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_sha.pyi b/mypy/typeshed/stdlib/@python2/_sha.pyi deleted file mode 100644 index 7c472562fc17..000000000000 --- a/mypy/typeshed/stdlib/@python2/_sha.pyi +++ /dev/null @@ -1,15 +0,0 @@ -blocksize: int -block_size: int -digest_size: int - -class sha(object): # not actually exposed - name: str - block_size: int - digest_size: int - digestsize: int - def copy(self) -> sha: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def update(self, arg: str) -> None: ... - -def new(arg: str = ...) -> sha: ... diff --git a/mypy/typeshed/stdlib/@python2/_sha256.pyi b/mypy/typeshed/stdlib/@python2/_sha256.pyi deleted file mode 100644 index 746432094bf2..000000000000 --- a/mypy/typeshed/stdlib/@python2/_sha256.pyi +++ /dev/null @@ -1,21 +0,0 @@ -class sha224(object): - name: str - block_size: int - digest_size: int - digestsize: int - def __init__(self, init: str | None) -> None: ... - def copy(self) -> sha224: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def update(self, arg: str) -> None: ... - -class sha256(object): - name: str - block_size: int - digest_size: int - digestsize: int - def __init__(self, init: str | None) -> None: ... - def copy(self) -> sha256: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def update(self, arg: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_sha512.pyi b/mypy/typeshed/stdlib/@python2/_sha512.pyi deleted file mode 100644 index 90e2aee1542f..000000000000 --- a/mypy/typeshed/stdlib/@python2/_sha512.pyi +++ /dev/null @@ -1,21 +0,0 @@ -class sha384(object): - name: str - block_size: int - digest_size: int - digestsize: int - def __init__(self, init: str | None) -> None: ... - def copy(self) -> sha384: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def update(self, arg: str) -> None: ... - -class sha512(object): - name: str - block_size: int - digest_size: int - digestsize: int - def __init__(self, init: str | None) -> None: ... - def copy(self) -> sha512: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def update(self, arg: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_socket.pyi b/mypy/typeshed/stdlib/@python2/_socket.pyi deleted file mode 100644 index d081494be68f..000000000000 --- a/mypy/typeshed/stdlib/@python2/_socket.pyi +++ /dev/null @@ -1,281 +0,0 @@ -from typing import IO, Any, overload - -AF_APPLETALK: int -AF_ASH: int -AF_ATMPVC: int -AF_ATMSVC: int -AF_AX25: int -AF_BLUETOOTH: int -AF_BRIDGE: int -AF_DECnet: int -AF_ECONET: int -AF_INET: int -AF_INET6: int -AF_IPX: int -AF_IRDA: int -AF_KEY: int -AF_LLC: int -AF_NETBEUI: int -AF_NETLINK: int -AF_NETROM: int -AF_PACKET: int -AF_PPPOX: int -AF_ROSE: int -AF_ROUTE: int -AF_SECURITY: int -AF_SNA: int -AF_TIPC: int -AF_UNIX: int -AF_UNSPEC: int -AF_WANPIPE: int -AF_X25: int -AI_ADDRCONFIG: int -AI_ALL: int -AI_CANONNAME: int -AI_NUMERICHOST: int -AI_NUMERICSERV: int -AI_PASSIVE: int -AI_V4MAPPED: int -BDADDR_ANY: str -BDADDR_LOCAL: str -BTPROTO_HCI: int -BTPROTO_L2CAP: int -BTPROTO_RFCOMM: int -BTPROTO_SCO: int -EAI_ADDRFAMILY: int -EAI_AGAIN: int -EAI_BADFLAGS: int -EAI_FAIL: int -EAI_FAMILY: int -EAI_MEMORY: int -EAI_NODATA: int -EAI_NONAME: int -EAI_OVERFLOW: int -EAI_SERVICE: int -EAI_SOCKTYPE: int -EAI_SYSTEM: int -EBADF: int -EINTR: int -HCI_DATA_DIR: int -HCI_FILTER: int -HCI_TIME_STAMP: int -INADDR_ALLHOSTS_GROUP: int -INADDR_ANY: int -INADDR_BROADCAST: int -INADDR_LOOPBACK: int -INADDR_MAX_LOCAL_GROUP: int -INADDR_NONE: int -INADDR_UNSPEC_GROUP: int -IPPORT_RESERVED: int -IPPORT_USERRESERVED: int -IPPROTO_AH: int -IPPROTO_DSTOPTS: int -IPPROTO_EGP: int -IPPROTO_ESP: int -IPPROTO_FRAGMENT: int -IPPROTO_GRE: int -IPPROTO_HOPOPTS: int -IPPROTO_ICMP: int -IPPROTO_ICMPV6: int -IPPROTO_IDP: int -IPPROTO_IGMP: int -IPPROTO_IP: int -IPPROTO_IPIP: int -IPPROTO_IPV6: int -IPPROTO_NONE: int -IPPROTO_PIM: int -IPPROTO_PUP: int -IPPROTO_RAW: int -IPPROTO_ROUTING: int -IPPROTO_RSVP: int -IPPROTO_TCP: int -IPPROTO_TP: int -IPPROTO_UDP: int -IPV6_CHECKSUM: int -IPV6_DSTOPTS: int -IPV6_HOPLIMIT: int -IPV6_HOPOPTS: int -IPV6_JOIN_GROUP: int -IPV6_LEAVE_GROUP: int -IPV6_MULTICAST_HOPS: int -IPV6_MULTICAST_IF: int -IPV6_MULTICAST_LOOP: int -IPV6_NEXTHOP: int -IPV6_PKTINFO: int -IPV6_RECVDSTOPTS: int -IPV6_RECVHOPLIMIT: int -IPV6_RECVHOPOPTS: int -IPV6_RECVPKTINFO: int -IPV6_RECVRTHDR: int -IPV6_RECVTCLASS: int -IPV6_RTHDR: int -IPV6_RTHDRDSTOPTS: int -IPV6_RTHDR_TYPE_0: int -IPV6_TCLASS: int -IPV6_UNICAST_HOPS: int -IPV6_V6ONLY: int -IP_ADD_MEMBERSHIP: int -IP_DEFAULT_MULTICAST_LOOP: int -IP_DEFAULT_MULTICAST_TTL: int -IP_DROP_MEMBERSHIP: int -IP_HDRINCL: int -IP_MAX_MEMBERSHIPS: int -IP_MULTICAST_IF: int -IP_MULTICAST_LOOP: int -IP_MULTICAST_TTL: int -IP_OPTIONS: int -IP_RECVOPTS: int -IP_RECVRETOPTS: int -IP_RETOPTS: int -IP_TOS: int -IP_TTL: int -MSG_CTRUNC: int -MSG_DONTROUTE: int -MSG_DONTWAIT: int -MSG_EOR: int -MSG_OOB: int -MSG_PEEK: int -MSG_TRUNC: int -MSG_WAITALL: int -MethodType: type -NETLINK_DNRTMSG: int -NETLINK_FIREWALL: int -NETLINK_IP6_FW: int -NETLINK_NFLOG: int -NETLINK_ROUTE: int -NETLINK_USERSOCK: int -NETLINK_XFRM: int -NI_DGRAM: int -NI_MAXHOST: int -NI_MAXSERV: int -NI_NAMEREQD: int -NI_NOFQDN: int -NI_NUMERICHOST: int -NI_NUMERICSERV: int -PACKET_BROADCAST: int -PACKET_FASTROUTE: int -PACKET_HOST: int -PACKET_LOOPBACK: int -PACKET_MULTICAST: int -PACKET_OTHERHOST: int -PACKET_OUTGOING: int -PF_PACKET: int -SHUT_RD: int -SHUT_RDWR: int -SHUT_WR: int -SOCK_DGRAM: int -SOCK_RAW: int -SOCK_RDM: int -SOCK_SEQPACKET: int -SOCK_STREAM: int -SOL_HCI: int -SOL_IP: int -SOL_SOCKET: int -SOL_TCP: int -SOL_TIPC: int -SOL_UDP: int -SOMAXCONN: int -SO_ACCEPTCONN: int -SO_BROADCAST: int -SO_DEBUG: int -SO_DONTROUTE: int -SO_ERROR: int -SO_KEEPALIVE: int -SO_LINGER: int -SO_OOBINLINE: int -SO_RCVBUF: int -SO_RCVLOWAT: int -SO_RCVTIMEO: int -SO_REUSEADDR: int -SO_REUSEPORT: int -SO_SNDBUF: int -SO_SNDLOWAT: int -SO_SNDTIMEO: int -SO_TYPE: int -SSL_ERROR_EOF: int -SSL_ERROR_INVALID_ERROR_CODE: int -SSL_ERROR_SSL: int -SSL_ERROR_SYSCALL: int -SSL_ERROR_WANT_CONNECT: int -SSL_ERROR_WANT_READ: int -SSL_ERROR_WANT_WRITE: int -SSL_ERROR_WANT_X509_LOOKUP: int -SSL_ERROR_ZERO_RETURN: int -TCP_CORK: int -TCP_DEFER_ACCEPT: int -TCP_INFO: int -TCP_KEEPCNT: int -TCP_KEEPIDLE: int -TCP_KEEPINTVL: int -TCP_LINGER2: int -TCP_MAXSEG: int -TCP_NODELAY: int -TCP_QUICKACK: int -TCP_SYNCNT: int -TCP_WINDOW_CLAMP: int -TIPC_ADDR_ID: int -TIPC_ADDR_NAME: int -TIPC_ADDR_NAMESEQ: int -TIPC_CFG_SRV: int -TIPC_CLUSTER_SCOPE: int -TIPC_CONN_TIMEOUT: int -TIPC_CRITICAL_IMPORTANCE: int -TIPC_DEST_DROPPABLE: int -TIPC_HIGH_IMPORTANCE: int -TIPC_IMPORTANCE: int -TIPC_LOW_IMPORTANCE: int -TIPC_MEDIUM_IMPORTANCE: int -TIPC_NODE_SCOPE: int -TIPC_PUBLISHED: int -TIPC_SRC_DROPPABLE: int -TIPC_SUBSCR_TIMEOUT: int -TIPC_SUB_CANCEL: int -TIPC_SUB_PORTS: int -TIPC_SUB_SERVICE: int -TIPC_TOP_SRV: int -TIPC_WAIT_FOREVER: int -TIPC_WITHDRAWN: int -TIPC_ZONE_SCOPE: int - -# PyCapsule -CAPI: Any - -has_ipv6: bool - -class error(IOError): ... -class gaierror(error): ... -class timeout(error): ... - -class SocketType(object): - family: int - type: int - proto: int - timeout: float - def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... - def accept(self) -> tuple[SocketType, tuple[Any, ...]]: ... - def bind(self, address: tuple[Any, ...]) -> None: ... - def close(self) -> None: ... - def connect(self, address: tuple[Any, ...]) -> None: ... - def connect_ex(self, address: tuple[Any, ...]) -> int: ... - def dup(self) -> SocketType: ... - def fileno(self) -> int: ... - def getpeername(self) -> tuple[Any, ...]: ... - def getsockname(self) -> tuple[Any, ...]: ... - def getsockopt(self, level: int, option: int, buffersize: int = ...) -> str: ... - def gettimeout(self) -> float: ... - def listen(self, backlog: int) -> None: ... - def makefile(self, mode: str = ..., buffersize: int = ...) -> IO[Any]: ... - def recv(self, buffersize: int, flags: int = ...) -> str: ... - def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ... - def recvfrom(self, buffersize: int, flags: int = ...) -> tuple[Any, ...]: ... - def recvfrom_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ... - def send(self, data: str, flags: int = ...) -> int: ... - def sendall(self, data: str, flags: int = ...) -> None: ... - @overload - def sendto(self, data: str, address: tuple[Any, ...]) -> int: ... - @overload - def sendto(self, data: str, flags: int, address: tuple[Any, ...]) -> int: ... - def setblocking(self, flag: bool) -> None: ... - def setsockopt(self, level: int, option: int, value: int | str) -> None: ... - def settimeout(self, value: float | None) -> None: ... - def shutdown(self, flag: int) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_sre.pyi b/mypy/typeshed/stdlib/@python2/_sre.pyi deleted file mode 100644 index ba61c56344ac..000000000000 --- a/mypy/typeshed/stdlib/@python2/_sre.pyi +++ /dev/null @@ -1,51 +0,0 @@ -from typing import Any, Iterable, Mapping, Sequence, overload - -CODESIZE: int -MAGIC: int -MAXREPEAT: long -copyright: str - -class SRE_Match(object): - def start(self, group: int = ...) -> int: ... - def end(self, group: int = ...) -> int: ... - def expand(self, s: str) -> Any: ... - @overload - def group(self) -> str: ... - @overload - def group(self, group: int = ...) -> str | None: ... - def groupdict(self) -> dict[int, str | None]: ... - def groups(self) -> tuple[str | None, ...]: ... - def span(self) -> tuple[int, int]: ... - @property - def regs(self) -> tuple[tuple[int, int], ...]: ... # undocumented - -class SRE_Scanner(object): - pattern: str - def match(self) -> SRE_Match: ... - def search(self) -> SRE_Match: ... - -class SRE_Pattern(object): - pattern: str - flags: int - groups: int - groupindex: Mapping[str, int] - indexgroup: Sequence[int] - def findall(self, source: str, pos: int = ..., endpos: int = ...) -> list[tuple[Any, ...] | str]: ... - def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[tuple[Any, ...] | str]: ... - def match(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ... - def scanner(self, s: str, start: int = ..., end: int = ...) -> SRE_Scanner: ... - def search(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ... - def split(self, source: str, maxsplit: int = ...) -> list[str | None]: ... - def sub(self, repl: str, string: str, count: int = ...) -> tuple[Any, ...]: ... - def subn(self, repl: str, string: str, count: int = ...) -> tuple[Any, ...]: ... - -def compile( - pattern: str, - flags: int, - code: list[int], - groups: int = ..., - groupindex: Mapping[str, int] = ..., - indexgroup: Sequence[int] = ..., -) -> SRE_Pattern: ... -def getcodesize() -> int: ... -def getlower(a: int, b: int) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/_struct.pyi b/mypy/typeshed/stdlib/@python2/_struct.pyi deleted file mode 100644 index 89357ab0bbc8..000000000000 --- a/mypy/typeshed/stdlib/@python2/_struct.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Any, AnyStr - -class error(Exception): ... - -class Struct(object): - size: int - format: str - def __init__(self, fmt: str) -> None: ... - def pack_into(self, buffer: bytearray, offset: int, obj: Any) -> None: ... - def pack(self, *args) -> str: ... - def unpack(self, s: str) -> tuple[Any, ...]: ... - def unpack_from(self, buffer: bytearray, offset: int = ...) -> tuple[Any, ...]: ... - -def _clearcache() -> None: ... -def calcsize(fmt: str) -> int: ... -def pack(fmt: AnyStr, obj: Any) -> str: ... -def pack_into(fmt: AnyStr, buffer: bytearray, offset: int, obj: Any) -> None: ... -def unpack(fmt: AnyStr, data: str) -> tuple[Any, ...]: ... -def unpack_from(fmt: AnyStr, buffer: bytearray, offset: int = ...) -> tuple[Any, ...]: ... diff --git a/mypy/typeshed/stdlib/@python2/_symtable.pyi b/mypy/typeshed/stdlib/@python2/_symtable.pyi deleted file mode 100644 index ca21f8d5e521..000000000000 --- a/mypy/typeshed/stdlib/@python2/_symtable.pyi +++ /dev/null @@ -1,35 +0,0 @@ -CELL: int -DEF_BOUND: int -DEF_FREE: int -DEF_FREE_CLASS: int -DEF_GLOBAL: int -DEF_IMPORT: int -DEF_LOCAL: int -DEF_PARAM: int -FREE: int -GLOBAL_EXPLICIT: int -GLOBAL_IMPLICIT: int -LOCAL: int -OPT_BARE_EXEC: int -OPT_EXEC: int -OPT_IMPORT_STAR: int -SCOPE_MASK: int -SCOPE_OFF: int -TYPE_CLASS: int -TYPE_FUNCTION: int -TYPE_MODULE: int -USE: int - -class _symtable_entry(object): ... - -class symtable(object): - children: list[_symtable_entry] - id: int - lineno: int - name: str - nested: int - optimized: int - symbols: dict[str, int] - type: int - varnames: list[str] - def __init__(self, src: str, filename: str, startstr: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_thread.pyi b/mypy/typeshed/stdlib/@python2/_thread.pyi deleted file mode 100644 index 0470ebd4830f..000000000000 --- a/mypy/typeshed/stdlib/@python2/_thread.pyi +++ /dev/null @@ -1,26 +0,0 @@ -from types import TracebackType -from typing import Any, Callable, NoReturn - -error = RuntimeError - -def _count() -> int: ... - -_dangling: Any - -class LockType: - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - def release(self) -> None: ... - def locked(self) -> bool: ... - def __enter__(self) -> bool: ... - def __exit__( - self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> None: ... - -def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ... -def interrupt_main() -> None: ... -def exit() -> NoReturn: ... -def allocate_lock() -> LockType: ... -def get_ident() -> int: ... -def stack_size(size: int = ...) -> int: ... - -TIMEOUT_MAX: float diff --git a/mypy/typeshed/stdlib/@python2/_threading_local.pyi b/mypy/typeshed/stdlib/@python2/_threading_local.pyi deleted file mode 100644 index 481d304578dd..000000000000 --- a/mypy/typeshed/stdlib/@python2/_threading_local.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Any - -class _localbase(object): ... - -class local(_localbase): - def __getattribute__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __delattr__(self, name: str) -> None: ... - def __del__(self) -> None: ... - -def _patch(self: local) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_tkinter.pyi b/mypy/typeshed/stdlib/@python2/_tkinter.pyi deleted file mode 100644 index 378b04202c4f..000000000000 --- a/mypy/typeshed/stdlib/@python2/_tkinter.pyi +++ /dev/null @@ -1,95 +0,0 @@ -from typing import Any -from typing_extensions import Literal - -# _tkinter is meant to be only used internally by tkinter, but some tkinter -# functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl -# object that hasn't been converted to a string. -# -# There are not many ways to get Tcl_Objs from tkinter, and I'm not sure if the -# only existing ways are supposed to return Tcl_Objs as opposed to returning -# strings. Here's one of these things that return Tcl_Objs: -# -# >>> import tkinter -# >>> text = tkinter.Text() -# >>> text.tag_add('foo', '1.0', 'end') -# >>> text.tag_ranges('foo') -# (, ) -class Tcl_Obj: - string: str # str(tclobj) returns this - typename: str - -class TclError(Exception): ... - -# This class allows running Tcl code. Tkinter uses it internally a lot, and -# it's often handy to drop a piece of Tcl code into a tkinter program. Example: -# -# >>> import tkinter, _tkinter -# >>> tkapp = tkinter.Tk().tk -# >>> isinstance(tkapp, _tkinter.TkappType) -# True -# >>> tkapp.call('set', 'foo', (1,2,3)) -# (1, 2, 3) -# >>> tkapp.eval('return $foo') -# '1 2 3' -# >>> -# -# call args can be pretty much anything. Also, call(some_tuple) is same as call(*some_tuple). -# -# eval always returns str because _tkinter_tkapp_eval_impl in _tkinter.c calls -# Tkapp_UnicodeResult, and it returns a string when it succeeds. -class TkappType: - # Please keep in sync with tkinter.Tk - def call(self, __command: Any, *args: Any) -> Any: ... - def eval(self, __script: str) -> str: ... - adderrorinfo: Any - createcommand: Any - createfilehandler: Any - createtimerhandler: Any - deletecommand: Any - deletefilehandler: Any - dooneevent: Any - evalfile: Any - exprboolean: Any - exprdouble: Any - exprlong: Any - exprstring: Any - getboolean: Any - getdouble: Any - getint: Any - getvar: Any - globalgetvar: Any - globalsetvar: Any - globalunsetvar: Any - interpaddr: Any - loadtk: Any - mainloop: Any - quit: Any - record: Any - setvar: Any - split: Any - splitlist: Any - unsetvar: Any - wantobjects: Any - willdispatch: Any - -# These should be kept in sync with tkinter.tix constants, except ALL_EVENTS which doesn't match TCL_ALL_EVENTS -ALL_EVENTS: Literal[-3] -FILE_EVENTS: Literal[8] -IDLE_EVENTS: Literal[32] -TIMER_EVENTS: Literal[16] -WINDOW_EVENTS: Literal[4] - -DONT_WAIT: Literal[2] -EXCEPTION: Literal[8] -READABLE: Literal[2] -WRITABLE: Literal[4] - -TCL_VERSION: str -TK_VERSION: str - -# TODO: figure out what these are (with e.g. help()) and get rid of Any -TkttType: Any -_flatten: Any -create: Any -getbusywaitinterval: Any -setbusywaitinterval: Any diff --git a/mypy/typeshed/stdlib/@python2/_typeshed/__init__.pyi b/mypy/typeshed/stdlib/@python2/_typeshed/__init__.pyi deleted file mode 100644 index 657164f81f6d..000000000000 --- a/mypy/typeshed/stdlib/@python2/_typeshed/__init__.pyi +++ /dev/null @@ -1,162 +0,0 @@ -# Utility types for typeshed - -# This module contains various common types to be used by typeshed. The -# module and its types do not exist at runtime. You can use this module -# outside of typeshed, but no API stability guarantees are made. To use -# it in implementation (.py) files, the following construct must be used: -# -# from typing import TYPE_CHECKING -# if TYPE_CHECKING: -# from _typeshed import ... -# -# If on Python versions < 3.10 and "from __future__ import annotations" -# is not used, types from this module must be quoted. - -import array -import mmap -from typing import Any, Container, Iterable, Protocol, Text, TypeVar -from typing_extensions import Literal, final - -_KT = TypeVar("_KT") -_KT_co = TypeVar("_KT_co", covariant=True) -_KT_contra = TypeVar("_KT_contra", contravariant=True) -_VT = TypeVar("_VT") -_VT_co = TypeVar("_VT_co", covariant=True) -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_T_contra = TypeVar("_T_contra", contravariant=True) - -# Use for "self" annotations: -# def __enter__(self: Self) -> Self: ... -Self = TypeVar("Self") # noqa: Y001 - -class IdentityFunction(Protocol): - def __call__(self, __x: _T) -> _T: ... - -class SupportsLessThan(Protocol): - def __lt__(self, __other: Any) -> bool: ... - -SupportsLessThanT = TypeVar("SupportsLessThanT", bound=SupportsLessThan) # noqa: Y001 - -class SupportsDivMod(Protocol[_T_contra, _T_co]): - def __divmod__(self, __other: _T_contra) -> _T_co: ... - -class SupportsRDivMod(Protocol[_T_contra, _T_co]): - def __rdivmod__(self, __other: _T_contra) -> _T_co: ... - -# Mapping-like protocols - -class SupportsItems(Protocol[_KT_co, _VT_co]): - # We want dictionaries to support this on Python 2. - def items(self) -> Iterable[tuple[_KT_co, _VT_co]]: ... - -class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]): - def keys(self) -> Iterable[_KT]: ... - def __getitem__(self, __k: _KT) -> _VT_co: ... - -class SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]): - def __getitem__(self, __k: _KT_contra) -> _VT_co: ... - -class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]): - def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ... - def __delitem__(self, __v: _KT_contra) -> None: ... - -# These aliases can be used in places where a PathLike object can be used -# instead of a string in Python 3. -StrPath = Text -BytesPath = str -StrOrBytesPath = Text -AnyPath = StrOrBytesPath # obsolete, will be removed soon - -OpenTextModeUpdating = Literal[ - "r+", - "+r", - "rt+", - "r+t", - "+rt", - "tr+", - "t+r", - "+tr", - "w+", - "+w", - "wt+", - "w+t", - "+wt", - "tw+", - "t+w", - "+tw", - "a+", - "+a", - "at+", - "a+t", - "+at", - "ta+", - "t+a", - "+ta", - "x+", - "+x", - "xt+", - "x+t", - "+xt", - "tx+", - "t+x", - "+tx", -] -OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"] -OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"] -OpenTextMode = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading -OpenBinaryModeUpdating = Literal[ - "rb+", - "r+b", - "+rb", - "br+", - "b+r", - "+br", - "wb+", - "w+b", - "+wb", - "bw+", - "b+w", - "+bw", - "ab+", - "a+b", - "+ab", - "ba+", - "b+a", - "+ba", - "xb+", - "x+b", - "+xb", - "bx+", - "b+x", - "+bx", -] -OpenBinaryModeWriting = Literal["wb", "bw", "ab", "ba", "xb", "bx"] -OpenBinaryModeReading = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"] -OpenBinaryMode = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting - -class HasFileno(Protocol): - def fileno(self) -> int: ... - -FileDescriptor = int -FileDescriptorLike = int | HasFileno - -class SupportsRead(Protocol[_T_co]): - def read(self, __length: int = ...) -> _T_co: ... - -class SupportsReadline(Protocol[_T_co]): - def readline(self, __length: int = ...) -> _T_co: ... - -class SupportsNoArgReadline(Protocol[_T_co]): - def readline(self) -> _T_co: ... - -class SupportsWrite(Protocol[_T_contra]): - def write(self, __s: _T_contra) -> Any: ... - -ReadableBuffer = bytes | bytearray | memoryview | array.array[Any] | mmap.mmap | buffer -WriteableBuffer = bytearray | memoryview | array.array[Any] | mmap.mmap | buffer - -# Used by type checkers for checks involving None (does not exist at runtime) -@final -class NoneType: - def __bool__(self) -> Literal[False]: ... diff --git a/mypy/typeshed/stdlib/@python2/_typeshed/wsgi.pyi b/mypy/typeshed/stdlib/@python2/_typeshed/wsgi.pyi deleted file mode 100644 index 4380949c9c1c..000000000000 --- a/mypy/typeshed/stdlib/@python2/_typeshed/wsgi.pyi +++ /dev/null @@ -1,35 +0,0 @@ -# Types to support PEP 3333 (WSGI) -# -# This module doesn't exist at runtime and neither do the types defined in this -# file. They are provided for type checking purposes. - -from sys import _OptExcInfo -from typing import Any, Callable, Iterable, Protocol, Text - -class StartResponse(Protocol): - def __call__( - self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ... - ) -> Callable[[bytes], Any]: ... - -WSGIEnvironment = dict[Text, Any] -WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] - -# WSGI input streams per PEP 3333 -class InputStream(Protocol): - def read(self, size: int = ...) -> bytes: ... - def readline(self, size: int = ...) -> bytes: ... - def readlines(self, hint: int = ...) -> list[bytes]: ... - def __iter__(self) -> Iterable[bytes]: ... - -# WSGI error streams per PEP 3333 -class ErrorStream(Protocol): - def flush(self) -> None: ... - def write(self, s: str) -> None: ... - def writelines(self, seq: list[str]) -> None: ... - -class _Readable(Protocol): - def read(self, size: int = ...) -> bytes: ... - -# Optional file wrapper in wsgi.file_wrapper -class FileWrapper(Protocol): - def __call__(self, file: _Readable, block_size: int = ...) -> Iterable[bytes]: ... diff --git a/mypy/typeshed/stdlib/@python2/_typeshed/xml.pyi b/mypy/typeshed/stdlib/@python2/_typeshed/xml.pyi deleted file mode 100644 index eaff9a641db4..000000000000 --- a/mypy/typeshed/stdlib/@python2/_typeshed/xml.pyi +++ /dev/null @@ -1,9 +0,0 @@ -# Stub-only types. This module does not exist at runtime. - -from typing import Any, Protocol - -# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects -class DOMImplementation(Protocol): - def hasFeature(self, feature: str, version: str | None) -> bool: ... - def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Any | None) -> Any: ... - def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/_warnings.pyi b/mypy/typeshed/stdlib/@python2/_warnings.pyi deleted file mode 100644 index 8f531c47af55..000000000000 --- a/mypy/typeshed/stdlib/@python2/_warnings.pyi +++ /dev/null @@ -1,31 +0,0 @@ -from typing import Any, overload - -default_action: str -once_registry: dict[Any, Any] - -filters: list[tuple[Any, ...]] - -@overload -def warn(message: str, category: type[Warning] | None = ..., stacklevel: int = ...) -> None: ... -@overload -def warn(message: Warning, category: Any = ..., stacklevel: int = ...) -> None: ... -@overload -def warn_explicit( - message: str, - category: type[Warning], - filename: str, - lineno: int, - module: str | None = ..., - registry: dict[str | tuple[str, type[Warning], int], int] | None = ..., - module_globals: dict[str, Any] | None = ..., -) -> None: ... -@overload -def warn_explicit( - message: Warning, - category: Any, - filename: str, - lineno: int, - module: str | None = ..., - registry: dict[str | tuple[str, type[Warning], int], int] | None = ..., - module_globals: dict[str, Any] | None = ..., -) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/_weakref.pyi b/mypy/typeshed/stdlib/@python2/_weakref.pyi deleted file mode 100644 index 9a37de3174b6..000000000000 --- a/mypy/typeshed/stdlib/@python2/_weakref.pyi +++ /dev/null @@ -1,26 +0,0 @@ -from typing import Any, Callable, Generic, TypeVar, overload - -_C = TypeVar("_C", bound=Callable[..., Any]) -_T = TypeVar("_T") - -class CallableProxyType(Generic[_C]): # "weakcallableproxy" - def __getattr__(self, attr: str) -> Any: ... - -class ProxyType(Generic[_T]): # "weakproxy" - def __getattr__(self, attr: str) -> Any: ... - -class ReferenceType(Generic[_T]): - def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> None: ... - def __call__(self) -> _T | None: ... - def __hash__(self) -> int: ... - -ref = ReferenceType - -def getweakrefcount(__object: Any) -> int: ... -def getweakrefs(object: Any) -> list[Any]: ... -@overload -def proxy(object: _C, callback: Callable[[_C], Any] | None = ...) -> CallableProxyType[_C]: ... - -# Return CallableProxyType if object is callable, ProxyType otherwise -@overload -def proxy(object: _T, callback: Callable[[_T], Any] | None = ...) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/_weakrefset.pyi b/mypy/typeshed/stdlib/@python2/_weakrefset.pyi deleted file mode 100644 index 0d2c7fc42f22..000000000000 --- a/mypy/typeshed/stdlib/@python2/_weakrefset.pyi +++ /dev/null @@ -1,41 +0,0 @@ -from _typeshed import Self -from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar - -_S = TypeVar("_S") -_T = TypeVar("_T") - -class WeakSet(MutableSet[_T], Generic[_T]): - def __init__(self, data: Iterable[_T] | None = ...) -> None: ... - def add(self, item: _T) -> None: ... - def clear(self) -> None: ... - def discard(self, item: _T) -> None: ... - def copy(self: Self) -> Self: ... - def pop(self) -> _T: ... - def remove(self, item: _T) -> None: ... - def update(self, other: Iterable[_T]) -> None: ... - def __contains__(self, item: object) -> bool: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_T]: ... - def __ior__(self: Self, other: Iterable[_T]) -> Self: ... # type: ignore[override,misc] - def difference(self: Self, other: Iterable[_T]) -> Self: ... - def __sub__(self: Self, other: Iterable[Any]) -> Self: ... - def difference_update(self, other: Iterable[Any]) -> None: ... - def __isub__(self: Self, other: Iterable[Any]) -> Self: ... - def intersection(self: Self, other: Iterable[_T]) -> Self: ... - def __and__(self: Self, other: Iterable[Any]) -> Self: ... - def intersection_update(self, other: Iterable[Any]) -> None: ... - def __iand__(self: Self, other: Iterable[Any]) -> Self: ... - def issubset(self, other: Iterable[_T]) -> bool: ... - def __le__(self, other: Iterable[_T]) -> bool: ... - def __lt__(self, other: Iterable[_T]) -> bool: ... - def issuperset(self, other: Iterable[_T]) -> bool: ... - def __ge__(self, other: Iterable[_T]) -> bool: ... - def __gt__(self, other: Iterable[_T]) -> bool: ... - def __eq__(self, other: object) -> bool: ... - def symmetric_difference(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... - def __xor__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... - def symmetric_difference_update(self, other: Iterable[_T]) -> None: ... - def __ixor__(self: Self, other: Iterable[_T]) -> Self: ... # type: ignore[override,misc] - def union(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... - def __or__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... - def isdisjoint(self, other: Iterable[_T]) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/_winreg.pyi b/mypy/typeshed/stdlib/@python2/_winreg.pyi deleted file mode 100644 index 395024fcc2fd..000000000000 --- a/mypy/typeshed/stdlib/@python2/_winreg.pyi +++ /dev/null @@ -1,97 +0,0 @@ -import sys -from _typeshed import Self -from types import TracebackType -from typing import Any - -if sys.platform == "win32": - _KeyType = HKEYType | int - def CloseKey(__hkey: _KeyType) -> None: ... - def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ... - def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ... - def CreateKeyEx(key: _KeyType, sub_key: str | None, reserved: int = ..., access: int = ...) -> HKEYType: ... - def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ... - def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ... - def DeleteValue(__key: _KeyType, __value: str) -> None: ... - def EnumKey(__key: _KeyType, __index: int) -> str: ... - def EnumValue(__key: _KeyType, __index: int) -> tuple[str, Any, int]: ... - def ExpandEnvironmentStrings(__str: str) -> str: ... - def FlushKey(__key: _KeyType) -> None: ... - def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ... - def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ... - def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ... - def QueryInfoKey(__key: _KeyType) -> tuple[int, int, int]: ... - def QueryValue(__key: _KeyType, __sub_key: str | None) -> str: ... - def QueryValueEx(__key: _KeyType, __name: str) -> tuple[Any, int]: ... - def SaveKey(__key: _KeyType, __file_name: str) -> None: ... - def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ... - def SetValueEx( - __key: _KeyType, __value_name: str | None, __reserved: Any, __type: int, __value: str | int - ) -> None: ... # reserved is ignored - def DisableReflectionKey(__key: _KeyType) -> None: ... - def EnableReflectionKey(__key: _KeyType) -> None: ... - def QueryReflectionKey(__key: _KeyType) -> bool: ... - HKEY_CLASSES_ROOT: int - HKEY_CURRENT_USER: int - HKEY_LOCAL_MACHINE: int - HKEY_USERS: int - HKEY_PERFORMANCE_DATA: int - HKEY_CURRENT_CONFIG: int - HKEY_DYN_DATA: int - - KEY_ALL_ACCESS: int - KEY_WRITE: int - KEY_READ: int - KEY_EXECUTE: int - KEY_QUERY_VALUE: int - KEY_SET_VALUE: int - KEY_CREATE_SUB_KEY: int - KEY_ENUMERATE_SUB_KEYS: int - KEY_NOTIFY: int - KEY_CREATE_LINK: int - - KEY_WOW64_64KEY: int - KEY_WOW64_32KEY: int - - REG_BINARY: int - REG_DWORD: int - REG_DWORD_LITTLE_ENDIAN: int - REG_DWORD_BIG_ENDIAN: int - REG_EXPAND_SZ: int - REG_LINK: int - REG_MULTI_SZ: int - REG_NONE: int - REG_RESOURCE_LIST: int - REG_FULL_RESOURCE_DESCRIPTOR: int - REG_RESOURCE_REQUIREMENTS_LIST: int - REG_SZ: int - - REG_CREATED_NEW_KEY: int # undocumented - REG_LEGAL_CHANGE_FILTER: int # undocumented - REG_LEGAL_OPTION: int # undocumented - REG_NOTIFY_CHANGE_ATTRIBUTES: int # undocumented - REG_NOTIFY_CHANGE_LAST_SET: int # undocumented - REG_NOTIFY_CHANGE_NAME: int # undocumented - REG_NOTIFY_CHANGE_SECURITY: int # undocumented - REG_NO_LAZY_FLUSH: int # undocumented - REG_OPENED_EXISTING_KEY: int # undocumented - REG_OPTION_BACKUP_RESTORE: int # undocumented - REG_OPTION_CREATE_LINK: int # undocumented - REG_OPTION_NON_VOLATILE: int # undocumented - REG_OPTION_OPEN_LINK: int # undocumented - REG_OPTION_RESERVED: int # undocumented - REG_OPTION_VOLATILE: int # undocumented - REG_REFRESH_HIVE: int # undocumented - REG_WHOLE_HIVE_VOLATILE: int # undocumented - - error = OSError - - # Though this class has a __name__ of PyHKEY, it's exposed as HKEYType for some reason - class HKEYType: - def __bool__(self) -> bool: ... - def __int__(self) -> int: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def Close(self) -> None: ... - def Detach(self) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/abc.pyi b/mypy/typeshed/stdlib/@python2/abc.pyi deleted file mode 100644 index 49ec775f91e8..000000000000 --- a/mypy/typeshed/stdlib/@python2/abc.pyi +++ /dev/null @@ -1,31 +0,0 @@ -import _weakrefset -from _typeshed import SupportsWrite -from typing import Any, Callable, TypeVar - -_FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) - -# NOTE: mypy has special processing for ABCMeta and abstractmethod. - -def abstractmethod(funcobj: _FuncT) -> _FuncT: ... - -class ABCMeta(type): - __abstractmethods__: frozenset[str] - _abc_cache: _weakrefset.WeakSet[Any] - _abc_invalidation_counter: int - _abc_negative_cache: _weakrefset.WeakSet[Any] - _abc_negative_cache_version: int - _abc_registry: _weakrefset.WeakSet[Any] - def __init__(self, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> None: ... - def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... - def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... - def _dump_registry(cls: ABCMeta, file: SupportsWrite[Any] | None = ...) -> None: ... - def register(cls: ABCMeta, subclass: type[Any]) -> None: ... - -# TODO: The real abc.abstractproperty inherits from "property". -class abstractproperty(object): - def __new__(cls, func: Any) -> Any: ... - __isabstractmethod__: bool - doc: Any - fdel: Any - fget: Any - fset: Any diff --git a/mypy/typeshed/stdlib/@python2/aifc.pyi b/mypy/typeshed/stdlib/@python2/aifc.pyi deleted file mode 100644 index 766ccde956f9..000000000000 --- a/mypy/typeshed/stdlib/@python2/aifc.pyi +++ /dev/null @@ -1,74 +0,0 @@ -from typing import IO, Any, NamedTuple, Text, overload -from typing_extensions import Literal - -class Error(Exception): ... - -class _aifc_params(NamedTuple): - nchannels: int - sampwidth: int - framerate: int - nframes: int - comptype: bytes - compname: bytes - -_File = Text | IO[bytes] -_Marker = tuple[int, int, bytes] - -class Aifc_read: - def __init__(self, f: _File) -> None: ... - def initfp(self, file: IO[bytes]) -> None: ... - def getfp(self) -> IO[bytes]: ... - def rewind(self) -> None: ... - def close(self) -> None: ... - def tell(self) -> int: ... - def getnchannels(self) -> int: ... - def getnframes(self) -> int: ... - def getsampwidth(self) -> int: ... - def getframerate(self) -> int: ... - def getcomptype(self) -> bytes: ... - def getcompname(self) -> bytes: ... - def getparams(self) -> _aifc_params: ... - def getmarkers(self) -> list[_Marker] | None: ... - def getmark(self, id: int) -> _Marker: ... - def setpos(self, pos: int) -> None: ... - def readframes(self, nframes: int) -> bytes: ... - -class Aifc_write: - def __init__(self, f: _File) -> None: ... - def __del__(self) -> None: ... - def initfp(self, file: IO[bytes]) -> None: ... - def aiff(self) -> None: ... - def aifc(self) -> None: ... - def setnchannels(self, nchannels: int) -> None: ... - def getnchannels(self) -> int: ... - def setsampwidth(self, sampwidth: int) -> None: ... - def getsampwidth(self) -> int: ... - def setframerate(self, framerate: int) -> None: ... - def getframerate(self) -> int: ... - def setnframes(self, nframes: int) -> None: ... - def getnframes(self) -> int: ... - def setcomptype(self, comptype: bytes, compname: bytes) -> None: ... - def getcomptype(self) -> bytes: ... - def getcompname(self) -> bytes: ... - def setparams(self, params: tuple[int, int, int, int, bytes, bytes]) -> None: ... - def getparams(self) -> _aifc_params: ... - def setmark(self, id: int, pos: int, name: bytes) -> None: ... - def getmark(self, id: int) -> _Marker: ... - def getmarkers(self) -> list[_Marker] | None: ... - def tell(self) -> int: ... - def writeframesraw(self, data: Any) -> None: ... # Actual type for data is Buffer Protocol - def writeframes(self, data: Any) -> None: ... - def close(self) -> None: ... - -@overload -def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ... -@overload -def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... -@overload -def open(f: _File, mode: str | None = ...) -> Any: ... -@overload -def openfp(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ... -@overload -def openfp(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... -@overload -def openfp(f: _File, mode: str | None = ...) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/antigravity.pyi b/mypy/typeshed/stdlib/@python2/antigravity.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/argparse.pyi b/mypy/typeshed/stdlib/@python2/argparse.pyi deleted file mode 100644 index a9a57ea0ea55..000000000000 --- a/mypy/typeshed/stdlib/@python2/argparse.pyi +++ /dev/null @@ -1,353 +0,0 @@ -from typing import IO, Any, Callable, Generator, Iterable, NoReturn, Pattern, Protocol, Sequence, Text, TypeVar, overload - -_T = TypeVar("_T") -_ActionT = TypeVar("_ActionT", bound=Action) -_N = TypeVar("_N") - -_Text = str | unicode - -ONE_OR_MORE: str -OPTIONAL: str -PARSER: str -REMAINDER: str -SUPPRESS: str -ZERO_OR_MORE: str -_UNRECOGNIZED_ARGS_ATTR: str # undocumented - -class ArgumentError(Exception): - argument_name: str | None - message: str - def __init__(self, argument: Action | None, message: str) -> None: ... - -# undocumented -class _AttributeHolder: - def _get_kwargs(self) -> list[tuple[str, Any]]: ... - def _get_args(self) -> list[Any]: ... - -# undocumented -class _ActionsContainer: - description: _Text | None - prefix_chars: _Text - argument_default: Any - conflict_handler: _Text - - _registries: dict[_Text, dict[Any, Any]] - _actions: list[Action] - _option_string_actions: dict[_Text, Action] - _action_groups: list[_ArgumentGroup] - _mutually_exclusive_groups: list[_MutuallyExclusiveGroup] - _defaults: dict[str, Any] - _negative_number_matcher: Pattern[str] - _has_negative_number_optionals: list[bool] - def __init__(self, description: Text | None, prefix_chars: Text, argument_default: Any, conflict_handler: Text) -> None: ... - def register(self, registry_name: Text, value: Any, object: Any) -> None: ... - def _registry_get(self, registry_name: Text, value: Any, default: Any = ...) -> Any: ... - def set_defaults(self, **kwargs: Any) -> None: ... - def get_default(self, dest: Text) -> Any: ... - def add_argument( - self, - *name_or_flags: Text, - action: Text | type[Action] = ..., - nargs: int | Text = ..., - const: Any = ..., - default: Any = ..., - type: Callable[[Text], _T] | Callable[[str], _T] | FileType = ..., - choices: Iterable[_T] = ..., - required: bool = ..., - help: Text | None = ..., - metavar: Text | tuple[Text, ...] | None = ..., - dest: Text | None = ..., - version: Text = ..., - **kwargs: Any, - ) -> Action: ... - def add_argument_group(self, *args: Any, **kwargs: Any) -> _ArgumentGroup: ... - def add_mutually_exclusive_group(self, **kwargs: Any) -> _MutuallyExclusiveGroup: ... - def _add_action(self, action: _ActionT) -> _ActionT: ... - def _remove_action(self, action: Action) -> None: ... - def _add_container_actions(self, container: _ActionsContainer) -> None: ... - def _get_positional_kwargs(self, dest: Text, **kwargs: Any) -> dict[str, Any]: ... - def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ... - def _pop_action_class(self, kwargs: Any, default: type[Action] | None = ...) -> type[Action]: ... - def _get_handler(self) -> Callable[[Action, Iterable[tuple[Text, Action]]], Any]: ... - def _check_conflict(self, action: Action) -> None: ... - def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[Text, Action]]) -> NoReturn: ... - def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[Text, Action]]) -> None: ... - -class _FormatterClass(Protocol): - def __call__(self, prog: str) -> HelpFormatter: ... - -class ArgumentParser(_AttributeHolder, _ActionsContainer): - prog: _Text - usage: _Text | None - epilog: _Text | None - formatter_class: _FormatterClass - fromfile_prefix_chars: _Text | None - add_help: bool - - # undocumented - _positionals: _ArgumentGroup - _optionals: _ArgumentGroup - _subparsers: _ArgumentGroup | None - def __init__( - self, - prog: Text | None = ..., - usage: Text | None = ..., - description: Text | None = ..., - epilog: Text | None = ..., - parents: Sequence[ArgumentParser] = ..., - formatter_class: _FormatterClass = ..., - prefix_chars: Text = ..., - fromfile_prefix_chars: Text | None = ..., - argument_default: Any = ..., - conflict_handler: Text = ..., - add_help: bool = ..., - ) -> None: ... - # The type-ignores in these overloads should be temporary. See: - # https://github.com/python/typeshed/pull/2643#issuecomment-442280277 - @overload - def parse_args(self, args: Sequence[Text] | None = ...) -> Namespace: ... - @overload - def parse_args(self, args: Sequence[Text] | None, namespace: None) -> Namespace: ... # type: ignore[misc] - @overload - def parse_args(self, args: Sequence[Text] | None, namespace: _N) -> _N: ... - @overload - def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore[misc] - @overload - def parse_args(self, *, namespace: _N) -> _N: ... - def add_subparsers( - self, - *, - title: Text = ..., - description: Text | None = ..., - prog: Text = ..., - parser_class: type[ArgumentParser] = ..., - action: type[Action] = ..., - option_string: Text = ..., - dest: Text | None = ..., - help: Text | None = ..., - metavar: Text | None = ..., - ) -> _SubParsersAction: ... - def print_usage(self, file: IO[str] | None = ...) -> None: ... - def print_help(self, file: IO[str] | None = ...) -> None: ... - def format_usage(self) -> str: ... - def format_help(self) -> str: ... - def parse_known_args( - self, args: Sequence[Text] | None = ..., namespace: Namespace | None = ... - ) -> tuple[Namespace, list[str]]: ... - def convert_arg_line_to_args(self, arg_line: Text) -> list[str]: ... - def exit(self, status: int = ..., message: Text | None = ...) -> NoReturn: ... - def error(self, message: Text) -> NoReturn: ... - # undocumented - def _get_optional_actions(self) -> list[Action]: ... - def _get_positional_actions(self) -> list[Action]: ... - def _parse_known_args(self, arg_strings: list[Text], namespace: Namespace) -> tuple[Namespace, list[str]]: ... - def _read_args_from_files(self, arg_strings: list[Text]) -> list[Text]: ... - def _match_argument(self, action: Action, arg_strings_pattern: Text) -> int: ... - def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: Text) -> list[int]: ... - def _parse_optional(self, arg_string: Text) -> tuple[Action | None, Text, Text | None] | None: ... - def _get_option_tuples(self, option_string: Text) -> list[tuple[Action, Text, Text | None]]: ... - def _get_nargs_pattern(self, action: Action) -> _Text: ... - def _get_values(self, action: Action, arg_strings: list[Text]) -> Any: ... - def _get_value(self, action: Action, arg_string: Text) -> Any: ... - def _check_value(self, action: Action, value: Any) -> None: ... - def _get_formatter(self) -> HelpFormatter: ... - def _print_message(self, message: str, file: IO[str] | None = ...) -> None: ... - -class HelpFormatter: - # undocumented - _prog: _Text - _indent_increment: int - _max_help_position: int - _width: int - _current_indent: int - _level: int - _action_max_length: int - _root_section: Any - _current_section: Any - _whitespace_matcher: Pattern[str] - _long_break_matcher: Pattern[str] - _Section: type[Any] # Nested class - def __init__( - self, prog: Text, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ... - ) -> None: ... - def _indent(self) -> None: ... - def _dedent(self) -> None: ... - def _add_item(self, func: Callable[..., _Text], args: Iterable[Any]) -> None: ... - def start_section(self, heading: Text | None) -> None: ... - def end_section(self) -> None: ... - def add_text(self, text: Text | None) -> None: ... - def add_usage( - self, usage: Text | None, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Text | None = ... - ) -> None: ... - def add_argument(self, action: Action) -> None: ... - def add_arguments(self, actions: Iterable[Action]) -> None: ... - def format_help(self) -> _Text: ... - def _join_parts(self, part_strings: Iterable[Text]) -> _Text: ... - def _format_usage( - self, usage: Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Text | None - ) -> _Text: ... - def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_ArgumentGroup]) -> _Text: ... - def _format_text(self, text: Text) -> _Text: ... - def _format_action(self, action: Action) -> _Text: ... - def _format_action_invocation(self, action: Action) -> _Text: ... - def _metavar_formatter(self, action: Action, default_metavar: Text) -> Callable[[int], tuple[_Text, ...]]: ... - def _format_args(self, action: Action, default_metavar: Text) -> _Text: ... - def _expand_help(self, action: Action) -> _Text: ... - def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ... - def _split_lines(self, text: Text, width: int) -> list[_Text]: ... - def _fill_text(self, text: Text, width: int, indent: Text) -> _Text: ... - def _get_help_string(self, action: Action) -> _Text | None: ... - def _get_default_metavar_for_optional(self, action: Action) -> _Text: ... - def _get_default_metavar_for_positional(self, action: Action) -> _Text: ... - -class RawDescriptionHelpFormatter(HelpFormatter): ... -class RawTextHelpFormatter(RawDescriptionHelpFormatter): ... -class ArgumentDefaultsHelpFormatter(HelpFormatter): ... - -class Action(_AttributeHolder): - option_strings: Sequence[_Text] - dest: _Text - nargs: int | _Text | None - const: Any - default: Any - type: Callable[[str], Any] | FileType | None - choices: Iterable[Any] | None - required: bool - help: _Text | None - metavar: _Text | tuple[_Text, ...] | None - def __init__( - self, - option_strings: Sequence[Text], - dest: Text, - nargs: int | Text | None = ..., - const: _T | None = ..., - default: _T | str | None = ..., - type: Callable[[Text], _T] | Callable[[str], _T] | FileType | None = ..., - choices: Iterable[_T] | None = ..., - required: bool = ..., - help: Text | None = ..., - metavar: Text | tuple[Text, ...] | None = ..., - ) -> None: ... - def __call__( - self, parser: ArgumentParser, namespace: Namespace, values: Text | Sequence[Any] | None, option_string: Text | None = ... - ) -> None: ... - -class Namespace(_AttributeHolder): - def __init__(self, **kwargs: Any) -> None: ... - def __getattr__(self, name: Text) -> Any: ... - def __setattr__(self, name: Text, value: Any) -> None: ... - def __contains__(self, key: str) -> bool: ... - -class FileType: - # undocumented - _mode: _Text - _bufsize: int - def __init__(self, mode: Text = ..., bufsize: int | None = ...) -> None: ... - def __call__(self, string: Text) -> IO[Any]: ... - -# undocumented -class _ArgumentGroup(_ActionsContainer): - title: _Text | None - _group_actions: list[Action] - def __init__( - self, container: _ActionsContainer, title: Text | None = ..., description: Text | None = ..., **kwargs: Any - ) -> None: ... - -# undocumented -class _MutuallyExclusiveGroup(_ArgumentGroup): - required: bool - _container: _ActionsContainer - def __init__(self, container: _ActionsContainer, required: bool = ...) -> None: ... - -# undocumented -class _StoreAction(Action): ... - -# undocumented -class _StoreConstAction(Action): - def __init__( - self, - option_strings: Sequence[Text], - dest: Text, - const: Any, - default: Any = ..., - required: bool = ..., - help: Text | None = ..., - metavar: Text | tuple[Text, ...] | None = ..., - ) -> None: ... - -# undocumented -class _StoreTrueAction(_StoreConstAction): - def __init__( - self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Text | None = ... - ) -> None: ... - -# undocumented -class _StoreFalseAction(_StoreConstAction): - def __init__( - self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Text | None = ... - ) -> None: ... - -# undocumented -class _AppendAction(Action): ... - -# undocumented -class _AppendConstAction(Action): - def __init__( - self, - option_strings: Sequence[Text], - dest: Text, - const: Any, - default: Any = ..., - required: bool = ..., - help: Text | None = ..., - metavar: Text | tuple[Text, ...] | None = ..., - ) -> None: ... - -# undocumented -class _CountAction(Action): - def __init__( - self, option_strings: Sequence[Text], dest: Text, default: Any = ..., required: bool = ..., help: Text | None = ... - ) -> None: ... - -# undocumented -class _HelpAction(Action): - def __init__( - self, option_strings: Sequence[Text], dest: Text = ..., default: Text = ..., help: Text | None = ... - ) -> None: ... - -# undocumented -class _VersionAction(Action): - version: _Text | None - def __init__( - self, option_strings: Sequence[Text], version: Text | None = ..., dest: Text = ..., default: Text = ..., help: Text = ... - ) -> None: ... - -# undocumented -class _SubParsersAction(Action): - _ChoicesPseudoAction: type[Any] # nested class - _prog_prefix: _Text - _parser_class: type[ArgumentParser] - _name_parser_map: dict[_Text, ArgumentParser] - choices: dict[_Text, ArgumentParser] - _choices_actions: list[Action] - def __init__( - self, - option_strings: Sequence[Text], - prog: Text, - parser_class: type[ArgumentParser], - dest: Text = ..., - help: Text | None = ..., - metavar: Text | tuple[Text, ...] | None = ..., - ) -> None: ... - # TODO: Type keyword args properly. - def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... - def _get_subactions(self) -> list[Action]: ... - -# undocumented -class ArgumentTypeError(Exception): ... - -# undocumented -def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ... - -# undocumented -def _get_action_name(argument: Action | None) -> str | None: ... diff --git a/mypy/typeshed/stdlib/@python2/array.pyi b/mypy/typeshed/stdlib/@python2/array.pyi deleted file mode 100644 index a47b845d1933..000000000000 --- a/mypy/typeshed/stdlib/@python2/array.pyi +++ /dev/null @@ -1,66 +0,0 @@ -from _typeshed import Self -from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, Text, TypeVar, overload -from typing_extensions import Literal - -_IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] -_FloatTypeCode = Literal["f", "d"] -_UnicodeTypeCode = Literal["u"] -_TypeCode = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode - -_T = TypeVar("_T", int, float, Text) - -class array(MutableSequence[_T], Generic[_T]): - typecode: _TypeCode - itemsize: int - @overload - def __init__(self: array[int], typecode: _IntTypeCode, __initializer: bytes | Iterable[_T] = ...) -> None: ... - @overload - def __init__(self: array[float], typecode: _FloatTypeCode, __initializer: bytes | Iterable[_T] = ...) -> None: ... - @overload - def __init__(self: array[Text], typecode: _UnicodeTypeCode, __initializer: bytes | Iterable[_T] = ...) -> None: ... - @overload - def __init__(self, typecode: str, __initializer: bytes | Iterable[_T] = ...) -> None: ... - def append(self, __v: _T) -> None: ... - def buffer_info(self) -> tuple[int, int]: ... - def byteswap(self) -> None: ... - def count(self, __v: Any) -> int: ... - def extend(self, __bb: Iterable[_T]) -> None: ... - def fromfile(self, __f: BinaryIO, __n: int) -> None: ... - def fromlist(self, __list: list[_T]) -> None: ... - def fromunicode(self, __ustr: str) -> None: ... - def index(self, __v: _T) -> int: ... # Overrides Sequence - def insert(self, __i: int, __v: _T) -> None: ... - def pop(self, __i: int = ...) -> _T: ... - def read(self, f: BinaryIO, n: int) -> None: ... - def remove(self, __v: Any) -> None: ... - def reverse(self) -> None: ... - def tofile(self, __f: BinaryIO) -> None: ... - def tolist(self) -> list[_T]: ... - def tounicode(self) -> str: ... - def write(self, f: BinaryIO) -> None: ... - def fromstring(self, __buffer: bytes) -> None: ... - def tostring(self) -> bytes: ... - def __len__(self) -> int: ... - @overload - def __getitem__(self, i: int) -> _T: ... - @overload - def __getitem__(self, s: slice) -> array[_T]: ... - @overload # type: ignore[override] - def __setitem__(self, i: int, o: _T) -> None: ... - @overload - def __setitem__(self, s: slice, o: array[_T]) -> None: ... - def __delitem__(self, i: int | slice) -> None: ... - def __add__(self, x: array[_T]) -> array[_T]: ... - def __ge__(self, other: array[_T]) -> bool: ... - def __gt__(self, other: array[_T]) -> bool: ... - def __iadd__(self: Self, x: array[_T]) -> Self: ... # type: ignore[override] - def __imul__(self: Self, n: int) -> Self: ... - def __le__(self, other: array[_T]) -> bool: ... - def __lt__(self, other: array[_T]) -> bool: ... - def __mul__(self, n: int) -> array[_T]: ... - def __rmul__(self, n: int) -> array[_T]: ... - def __delslice__(self, i: int, j: int) -> None: ... - def __getslice__(self, i: int, j: int) -> array[_T]: ... - def __setslice__(self, i: int, j: int, y: array[_T]) -> None: ... - -ArrayType = array diff --git a/mypy/typeshed/stdlib/@python2/ast.pyi b/mypy/typeshed/stdlib/@python2/ast.pyi deleted file mode 100644 index b86e38dce4c5..000000000000 --- a/mypy/typeshed/stdlib/@python2/ast.pyi +++ /dev/null @@ -1,27 +0,0 @@ -# Python 2.7 ast - -# Rename typing to _typing, as not to conflict with typing imported -# from _ast below when loaded in an unorthodox way by the Dropbox -# internal Bazel integration. -import typing as _typing -from _ast import * -from _ast import AST, Module -from typing import Any, Iterator - -def parse(source: str | unicode, filename: str | unicode = ..., mode: str | unicode = ...) -> Module: ... -def copy_location(new_node: AST, old_node: AST) -> AST: ... -def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... -def fix_missing_locations(node: AST) -> AST: ... -def get_docstring(node: AST, clean: bool = ...) -> str: ... -def increment_lineno(node: AST, n: int = ...) -> AST: ... -def iter_child_nodes(node: AST) -> Iterator[AST]: ... -def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: str | unicode | AST) -> Any: ... -def walk(node: AST) -> Iterator[AST]: ... - -class NodeVisitor: - def visit(self, node: AST) -> Any: ... - def generic_visit(self, node: AST) -> Any: ... - -class NodeTransformer(NodeVisitor): - def generic_visit(self, node: AST) -> AST | None: ... diff --git a/mypy/typeshed/stdlib/@python2/asynchat.pyi b/mypy/typeshed/stdlib/@python2/asynchat.pyi deleted file mode 100644 index e55dbf258a14..000000000000 --- a/mypy/typeshed/stdlib/@python2/asynchat.pyi +++ /dev/null @@ -1,37 +0,0 @@ -import asyncore -import socket -from abc import abstractmethod -from typing import Sequence - -class simple_producer: - def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... - def more(self) -> bytes: ... - -class async_chat(asyncore.dispatcher): - ac_in_buffer_size: int - ac_out_buffer_size: int - def __init__(self, sock: socket.socket | None = ..., map: asyncore._maptype | None = ...) -> None: ... - @abstractmethod - def collect_incoming_data(self, data: bytes) -> None: ... - @abstractmethod - def found_terminator(self) -> None: ... - def set_terminator(self, term: bytes | int | None) -> None: ... - def get_terminator(self) -> bytes | int | None: ... - def handle_read(self) -> None: ... - def handle_write(self) -> None: ... - def handle_close(self) -> None: ... - def push(self, data: bytes) -> None: ... - def push_with_producer(self, producer: simple_producer) -> None: ... - def readable(self) -> bool: ... - def writable(self) -> bool: ... - def close_when_done(self) -> None: ... - def initiate_send(self) -> None: ... - def discard_buffers(self) -> None: ... - -class fifo: - def __init__(self, list: Sequence[bytes | simple_producer] = ...) -> None: ... - def __len__(self) -> int: ... - def is_empty(self) -> bool: ... - def first(self) -> bytes: ... - def push(self, data: bytes | simple_producer) -> None: ... - def pop(self) -> tuple[int, bytes]: ... diff --git a/mypy/typeshed/stdlib/@python2/asyncore.pyi b/mypy/typeshed/stdlib/@python2/asyncore.pyi deleted file mode 100644 index a9f07613bb9c..000000000000 --- a/mypy/typeshed/stdlib/@python2/asyncore.pyi +++ /dev/null @@ -1,119 +0,0 @@ -import sys -from _typeshed import FileDescriptorLike -from socket import SocketType -from typing import Any, overload - -# cyclic dependence with asynchat -_maptype = dict[int, Any] - -socket_map: _maptype # undocumented - -class ExitNow(Exception): ... - -def read(obj: Any) -> None: ... -def write(obj: Any) -> None: ... -def readwrite(obj: Any, flags: int) -> None: ... -def poll(timeout: float = ..., map: _maptype | None = ...) -> None: ... -def poll2(timeout: float = ..., map: _maptype | None = ...) -> None: ... - -poll3 = poll2 - -def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype | None = ..., count: int | None = ...) -> None: ... - -# Not really subclass of socket.socket; it's only delegation. -# It is not covariant to it. -class dispatcher: - - debug: bool - connected: bool - accepting: bool - connecting: bool - closing: bool - ignore_log_types: frozenset[str] - socket: SocketType | None - def __init__(self, sock: SocketType | None = ..., map: _maptype | None = ...) -> None: ... - def add_channel(self, map: _maptype | None = ...) -> None: ... - def del_channel(self, map: _maptype | None = ...) -> None: ... - def create_socket(self, family: int = ..., type: int = ...) -> None: ... - def set_socket(self, sock: SocketType, map: _maptype | None = ...) -> None: ... - def set_reuse_addr(self) -> None: ... - def readable(self) -> bool: ... - def writable(self) -> bool: ... - def listen(self, num: int) -> None: ... - def bind(self, addr: tuple[Any, ...] | str) -> None: ... - def connect(self, address: tuple[Any, ...] | str) -> None: ... - def accept(self) -> tuple[SocketType, Any] | None: ... - def send(self, data: bytes) -> int: ... - def recv(self, buffer_size: int) -> bytes: ... - def close(self) -> None: ... - def log(self, message: Any) -> None: ... - def log_info(self, message: Any, type: str = ...) -> None: ... - def handle_read_event(self) -> None: ... - def handle_connect_event(self) -> None: ... - def handle_write_event(self) -> None: ... - def handle_expt_event(self) -> None: ... - def handle_error(self) -> None: ... - def handle_expt(self) -> None: ... - def handle_read(self) -> None: ... - def handle_write(self) -> None: ... - def handle_connect(self) -> None: ... - def handle_accept(self) -> None: ... - def handle_close(self) -> None: ... - # Historically, some methods were "imported" from `self.socket` by - # means of `__getattr__`. This was long deprecated, and as of Python - # 3.5 has been removed; simply call the relevant methods directly on - # self.socket if necessary. - def detach(self) -> int: ... - def fileno(self) -> int: ... - # return value is an address - def getpeername(self) -> Any: ... - def getsockname(self) -> Any: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... - def gettimeout(self) -> float: ... - def ioctl(self, control: object, option: tuple[int, int, int]) -> None: ... - # TODO the return value may be BinaryIO or TextIO, depending on mode - def makefile( - self, mode: str = ..., buffering: int = ..., encoding: str = ..., errors: str = ..., newline: str = ... - ) -> Any: ... - # return type is an address - def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ... - 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: tuple[str, int] | str, flags: int = ...) -> int: ... - def setblocking(self, flag: bool) -> None: ... - def settimeout(self, value: float | None) -> None: ... - def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ... - def shutdown(self, how: int) -> None: ... - -class dispatcher_with_send(dispatcher): - def __init__(self, sock: SocketType = ..., map: _maptype | None = ...) -> None: ... - def initiate_send(self) -> None: ... - def handle_write(self) -> None: ... - # incompatible signature: - # def send(self, data: bytes) -> Optional[int]: ... - -def compact_traceback() -> tuple[tuple[str, str, str], type, type, str]: ... -def close_all(map: _maptype | None = ..., ignore_all: bool = ...) -> None: ... - -if sys.platform != "win32": - class file_wrapper: - fd: int - def __init__(self, fd: int) -> None: ... - def recv(self, bufsize: int, flags: int = ...) -> bytes: ... - def send(self, data: bytes, flags: int = ...) -> int: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... - def read(self, bufsize: int, flags: int = ...) -> bytes: ... - def write(self, data: bytes, flags: int = ...) -> int: ... - def close(self) -> None: ... - def fileno(self) -> int: ... - - class file_dispatcher(dispatcher): - def __init__(self, fd: FileDescriptorLike, map: _maptype | None = ...) -> None: ... - def set_file(self, fd: int) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/atexit.pyi b/mypy/typeshed/stdlib/@python2/atexit.pyi deleted file mode 100644 index 2336bf91149e..000000000000 --- a/mypy/typeshed/stdlib/@python2/atexit.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from typing import Any, TypeVar - -_FT = TypeVar("_FT") - -def register(func: _FT, *args: Any, **kargs: Any) -> _FT: ... diff --git a/mypy/typeshed/stdlib/@python2/audioop.pyi b/mypy/typeshed/stdlib/@python2/audioop.pyi deleted file mode 100644 index b08731b85b0b..000000000000 --- a/mypy/typeshed/stdlib/@python2/audioop.pyi +++ /dev/null @@ -1,40 +0,0 @@ -AdpcmState = tuple[int, int] -RatecvState = tuple[int, tuple[tuple[int, int], ...]] - -class error(Exception): ... - -def add(__fragment1: bytes, __fragment2: bytes, __width: int) -> bytes: ... -def adpcm2lin(__fragment: bytes, __width: int, __state: AdpcmState | None) -> tuple[bytes, AdpcmState]: ... -def alaw2lin(__fragment: bytes, __width: int) -> bytes: ... -def avg(__fragment: bytes, __width: int) -> int: ... -def avgpp(__fragment: bytes, __width: int) -> int: ... -def bias(__fragment: bytes, __width: int, __bias: int) -> bytes: ... -def byteswap(__fragment: bytes, __width: int) -> bytes: ... -def cross(__fragment: bytes, __width: int) -> int: ... -def findfactor(__fragment: bytes, __reference: bytes) -> float: ... -def findfit(__fragment: bytes, __reference: bytes) -> tuple[int, float]: ... -def findmax(__fragment: bytes, __length: int) -> int: ... -def getsample(__fragment: bytes, __width: int, __index: int) -> int: ... -def lin2adpcm(__fragment: bytes, __width: int, __state: AdpcmState | None) -> tuple[bytes, AdpcmState]: ... -def lin2alaw(__fragment: bytes, __width: int) -> bytes: ... -def lin2lin(__fragment: bytes, __width: int, __newwidth: int) -> bytes: ... -def lin2ulaw(__fragment: bytes, __width: int) -> bytes: ... -def max(__fragment: bytes, __width: int) -> int: ... -def maxpp(__fragment: bytes, __width: int) -> int: ... -def minmax(__fragment: bytes, __width: int) -> tuple[int, int]: ... -def mul(__fragment: bytes, __width: int, __factor: float) -> bytes: ... -def ratecv( - __fragment: bytes, - __width: int, - __nchannels: int, - __inrate: int, - __outrate: int, - __state: RatecvState | None, - __weightA: int = ..., - __weightB: int = ..., -) -> tuple[bytes, RatecvState]: ... -def reverse(__fragment: bytes, __width: int) -> bytes: ... -def rms(__fragment: bytes, __width: int) -> int: ... -def tomono(__fragment: bytes, __width: int, __lfactor: float, __rfactor: float) -> bytes: ... -def tostereo(__fragment: bytes, __width: int, __lfactor: float, __rfactor: float) -> bytes: ... -def ulaw2lin(__fragment: bytes, __width: int) -> bytes: ... diff --git a/mypy/typeshed/stdlib/@python2/base64.pyi b/mypy/typeshed/stdlib/@python2/base64.pyi deleted file mode 100644 index 4a32006ea98b..000000000000 --- a/mypy/typeshed/stdlib/@python2/base64.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import IO - -_encodable = bytes | unicode -_decodable = bytes | unicode - -def b64encode(s: _encodable, altchars: bytes | None = ...) -> bytes: ... -def b64decode(s: _decodable, altchars: bytes | None = ..., validate: bool = ...) -> bytes: ... -def standard_b64encode(s: _encodable) -> bytes: ... -def standard_b64decode(s: _decodable) -> bytes: ... -def urlsafe_b64encode(s: _encodable) -> bytes: ... -def urlsafe_b64decode(s: _decodable) -> bytes: ... -def b32encode(s: _encodable) -> bytes: ... -def b32decode(s: _decodable, casefold: bool = ..., map01: bytes | None = ...) -> bytes: ... -def b16encode(s: _encodable) -> bytes: ... -def b16decode(s: _decodable, casefold: bool = ...) -> bytes: ... -def decode(input: IO[bytes], output: IO[bytes]) -> None: ... -def encode(input: IO[bytes], output: IO[bytes]) -> None: ... -def encodestring(s: bytes) -> bytes: ... -def decodestring(s: bytes) -> bytes: ... diff --git a/mypy/typeshed/stdlib/@python2/bdb.pyi b/mypy/typeshed/stdlib/@python2/bdb.pyi deleted file mode 100644 index ec2fe4956b6c..000000000000 --- a/mypy/typeshed/stdlib/@python2/bdb.pyi +++ /dev/null @@ -1,95 +0,0 @@ -from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, TypeVar -from typing_extensions import ParamSpec - -_T = TypeVar("_T") -_P = ParamSpec("_P") -_TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type -_ExcInfo = tuple[type[BaseException], BaseException, FrameType] - -GENERATOR_AND_COROUTINE_FLAGS: int - -class BdbQuit(Exception): ... - -class Bdb: - - skip: set[str] | None - breaks: dict[str, list[int]] - fncache: dict[str, str] - frame_returning: FrameType | None - botframe: FrameType | None - quitting: bool - stopframe: FrameType | None - returnframe: FrameType | None - stoplineno: int - def __init__(self, skip: Iterable[str] | None = ...) -> None: ... - def canonic(self, filename: str) -> str: ... - def reset(self) -> None: ... - def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ... - def dispatch_line(self, frame: FrameType) -> _TraceDispatch: ... - def dispatch_call(self, frame: FrameType, arg: None) -> _TraceDispatch: ... - def dispatch_return(self, frame: FrameType, arg: Any) -> _TraceDispatch: ... - def dispatch_exception(self, frame: FrameType, arg: _ExcInfo) -> _TraceDispatch: ... - def is_skipped_module(self, module_name: str) -> bool: ... - def stop_here(self, frame: FrameType) -> bool: ... - def break_here(self, frame: FrameType) -> bool: ... - def do_clear(self, arg: Any) -> bool | None: ... - def break_anywhere(self, frame: FrameType) -> bool: ... - def user_call(self, frame: FrameType, argument_list: None) -> None: ... - def user_line(self, frame: FrameType) -> None: ... - def user_return(self, frame: FrameType, return_value: Any) -> None: ... - def user_exception(self, frame: FrameType, exc_info: _ExcInfo) -> None: ... - def set_until(self, frame: FrameType, lineno: int | None = ...) -> None: ... - def set_step(self) -> None: ... - def set_next(self, frame: FrameType) -> None: ... - def set_return(self, frame: FrameType) -> None: ... - def set_trace(self, frame: FrameType | None = ...) -> None: ... - def set_continue(self) -> None: ... - def set_quit(self) -> None: ... - def set_break( - self, filename: str, lineno: int, temporary: bool = ..., cond: str | None = ..., funcname: str | None = ... - ) -> None: ... - def clear_break(self, filename: str, lineno: int) -> None: ... - def clear_bpbynumber(self, arg: SupportsInt) -> None: ... - def clear_all_file_breaks(self, filename: str) -> None: ... - def clear_all_breaks(self) -> None: ... - def get_bpbynumber(self, arg: SupportsInt) -> Breakpoint: ... - def get_break(self, filename: str, lineno: int) -> bool: ... - def get_breaks(self, filename: str, lineno: int) -> list[Breakpoint]: ... - def get_file_breaks(self, filename: str) -> list[Breakpoint]: ... - def get_all_breaks(self) -> list[Breakpoint]: ... - def get_stack(self, f: FrameType | None, t: TracebackType | None) -> tuple[list[tuple[FrameType, int]], int]: ... - def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ... - def run(self, cmd: str | CodeType, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... - def runeval(self, expr: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... - def runctx(self, cmd: str | CodeType, globals: dict[str, Any] | None, locals: Mapping[str, Any] | None) -> None: ... - def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> _T | None: ... - -class Breakpoint: - - next: int = ... - bplist: dict[tuple[str, int], list[Breakpoint]] = ... - bpbynumber: list[Breakpoint | None] = ... - - funcname: str | None - func_first_executable_line: int | None - file: str - line: int - temporary: bool - cond: str | None - enabled: bool - ignore: int - hits: int - number: int - def __init__( - self, file: str, line: int, temporary: bool = ..., cond: str | None = ..., funcname: str | None = ... - ) -> None: ... - def deleteMe(self) -> None: ... - def enable(self) -> None: ... - def disable(self) -> None: ... - def bpprint(self, out: IO[str] | None = ...) -> None: ... - def bpformat(self) -> str: ... - -def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ... -def effective(file: str, line: int, frame: FrameType) -> tuple[Breakpoint, bool] | tuple[None, None]: ... -def set_trace() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/binascii.pyi b/mypy/typeshed/stdlib/@python2/binascii.pyi deleted file mode 100644 index b8da269c95a8..000000000000 --- a/mypy/typeshed/stdlib/@python2/binascii.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from typing import Text - -# Python 2 accepts unicode ascii pretty much everywhere. -_Bytes = Text -_Ascii = Text - -def a2b_uu(__data: _Ascii) -> bytes: ... -def b2a_uu(__data: _Bytes) -> bytes: ... -def a2b_base64(__data: _Ascii) -> bytes: ... -def b2a_base64(__data: _Bytes) -> bytes: ... -def a2b_qp(data: _Ascii, header: bool = ...) -> bytes: ... -def b2a_qp(data: _Bytes, quotetabs: bool = ..., istext: bool = ..., header: bool = ...) -> bytes: ... -def a2b_hqx(__data: _Ascii) -> bytes: ... -def rledecode_hqx(__data: _Bytes) -> bytes: ... -def rlecode_hqx(__data: _Bytes) -> bytes: ... -def b2a_hqx(__data: _Bytes) -> bytes: ... -def crc_hqx(__data: _Bytes, __crc: int) -> int: ... -def crc32(__data: _Bytes, __crc: int = ...) -> int: ... -def b2a_hex(__data: _Bytes) -> bytes: ... -def hexlify(__data: _Bytes) -> bytes: ... -def a2b_hex(__hexstr: _Ascii) -> bytes: ... -def unhexlify(__hexstr: _Ascii) -> bytes: ... - -class Error(ValueError): ... -class Incomplete(Exception): ... diff --git a/mypy/typeshed/stdlib/@python2/binhex.pyi b/mypy/typeshed/stdlib/@python2/binhex.pyi deleted file mode 100644 index 10a5a3ee5633..000000000000 --- a/mypy/typeshed/stdlib/@python2/binhex.pyi +++ /dev/null @@ -1,42 +0,0 @@ -from typing import IO, Any - -class Error(Exception): ... - -REASONABLY_LARGE: int -LINELEN: int -RUNCHAR: bytes - -class FInfo: - def __init__(self) -> None: ... - Type: str - Creator: str - Flags: int - -_FileInfoTuple = tuple[str, FInfo, int, int] -_FileHandleUnion = str | IO[bytes] - -def getfileinfo(name: str) -> _FileInfoTuple: ... - -class openrsrc: - def __init__(self, *args: Any) -> None: ... - def read(self, *args: Any) -> bytes: ... - def write(self, *args: Any) -> None: ... - def close(self) -> None: ... - -class BinHex: - def __init__(self, name_finfo_dlen_rlen: _FileInfoTuple, ofp: _FileHandleUnion) -> None: ... - def write(self, data: bytes) -> None: ... - def close_data(self) -> None: ... - def write_rsrc(self, data: bytes) -> None: ... - def close(self) -> None: ... - -def binhex(inp: str, out: str) -> None: ... - -class HexBin: - def __init__(self, ifp: _FileHandleUnion) -> None: ... - def read(self, *n: int) -> bytes: ... - def close_data(self) -> None: ... - def read_rsrc(self, *n: int) -> bytes: ... - def close(self) -> None: ... - -def hexbin(inp: str, out: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/bisect.pyi b/mypy/typeshed/stdlib/@python2/bisect.pyi deleted file mode 100644 index 60dfc48d69bd..000000000000 --- a/mypy/typeshed/stdlib/@python2/bisect.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from _bisect import * - -bisect = bisect_right -insort = insort_right diff --git a/mypy/typeshed/stdlib/@python2/builtins.pyi b/mypy/typeshed/stdlib/@python2/builtins.pyi deleted file mode 100644 index 4ede9dc9d8bd..000000000000 --- a/mypy/typeshed/stdlib/@python2/builtins.pyi +++ /dev/null @@ -1,1165 +0,0 @@ -# True and False are deliberately omitted because they are keywords in -# Python 3, and stub files conform to Python 3 syntax. - -from _typeshed import ReadableBuffer, Self, SupportsKeysAndGetItem, SupportsWrite -from abc import ABCMeta -from ast import mod -from types import CodeType -from typing import ( - AbstractSet, - Any, - AnyStr, - BinaryIO, - ByteString, - Callable, - ClassVar, - Container, - Generic, - ItemsView, - Iterable, - Iterator, - KeysView, - Mapping, - MutableMapping, - MutableSequence, - MutableSet, - NoReturn, - Protocol, - Reversible, - Sequence, - Sized, - SupportsAbs, - SupportsComplex, - SupportsFloat, - SupportsInt, - Text, - TypeVar, - ValuesView, - overload, -) -from typing_extensions import Literal, final - -class _SupportsIndex(Protocol): - def __index__(self) -> int: ... - -class _SupportsTrunc(Protocol): - def __trunc__(self) -> int: ... - -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") -_S = TypeVar("_S") -_T1 = TypeVar("_T1") -_T2 = TypeVar("_T2") -_T3 = TypeVar("_T3") -_T4 = TypeVar("_T4") -_T5 = TypeVar("_T5") -_TT = TypeVar("_TT", bound=type) - -class object: - __doc__: str | None - __dict__: dict[str, Any] - __module__: str - @property - def __class__(self: _T) -> type[_T]: ... - @__class__.setter - def __class__(self, __type: type[object]) -> None: ... # noqa: F811 - def __init__(self) -> None: ... - def __new__(cls) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __eq__(self, o: object) -> bool: ... - def __ne__(self, o: object) -> bool: ... - def __str__(self) -> str: ... # noqa: Y029 - def __repr__(self) -> str: ... # noqa: Y029 - def __hash__(self) -> int: ... - def __format__(self, format_spec: str) -> str: ... - def __getattribute__(self, name: str) -> Any: ... - def __delattr__(self, name: str) -> None: ... - def __sizeof__(self) -> int: ... - def __reduce__(self) -> str | tuple[Any, ...]: ... - def __reduce_ex__(self, protocol: int) -> str | tuple[Any, ...]: ... - -class staticmethod(object): # Special, only valid as a decorator. - __func__: Callable[..., Any] - def __init__(self, f: Callable[..., Any]) -> None: ... - def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ... - def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ... - -class classmethod(object): # Special, only valid as a decorator. - __func__: Callable[..., Any] - def __init__(self, f: Callable[..., Any]) -> None: ... - def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ... - def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ... - -class type(object): - __base__: type - __bases__: tuple[type, ...] - __basicsize__: int - __dict__: dict[str, Any] - __dictoffset__: int - __flags__: int - __itemsize__: int - __module__: str - __mro__: tuple[type, ...] - __name__: str - __weakrefoffset__: int - @overload - def __init__(self, o: object) -> None: ... - @overload - def __init__(self, name: str, bases: tuple[type, ...], dict: dict[str, Any]) -> None: ... - @overload - def __new__(cls, o: object) -> type: ... - @overload - def __new__(cls, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> type: ... - def __call__(self, *args: Any, **kwds: Any) -> Any: ... - def __subclasses__(self: _TT) -> list[_TT]: ... - # Note: the documentation doesn't specify what the return type is, the standard - # implementation seems to be returning a list. - def mro(self) -> list[type]: ... - def __instancecheck__(self, instance: Any) -> bool: ... - def __subclasscheck__(self, subclass: type) -> bool: ... - -class super(object): - @overload - def __init__(self, t: Any, obj: Any) -> None: ... - @overload - def __init__(self, t: Any) -> None: ... - -class int: - @overload - def __new__(cls: type[Self], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> Self: ... - @overload - def __new__(cls: type[Self], x: Text | bytes | bytearray, base: int) -> Self: ... - @property - def real(self) -> int: ... - @property - def imag(self) -> int: ... - @property - def numerator(self) -> int: ... - @property - def denominator(self) -> int: ... - def conjugate(self) -> int: ... - def bit_length(self) -> int: ... - def __add__(self, x: int) -> int: ... - def __sub__(self, x: int) -> int: ... - def __mul__(self, x: int) -> int: ... - def __floordiv__(self, x: int) -> int: ... - def __div__(self, x: int) -> int: ... - def __truediv__(self, x: int) -> float: ... - def __mod__(self, x: int) -> int: ... - def __divmod__(self, x: int) -> tuple[int, int]: ... - def __radd__(self, x: int) -> int: ... - def __rsub__(self, x: int) -> int: ... - def __rmul__(self, x: int) -> int: ... - def __rfloordiv__(self, x: int) -> int: ... - def __rdiv__(self, x: int) -> int: ... - def __rtruediv__(self, x: int) -> float: ... - def __rmod__(self, x: int) -> int: ... - def __rdivmod__(self, x: int) -> tuple[int, int]: ... - @overload - def __pow__(self, __x: Literal[2], __modulo: int | None = ...) -> int: ... - @overload - def __pow__(self, __x: int, __modulo: int | None = ...) -> Any: ... # Return type can be int or float, depending on x. - def __rpow__(self, x: int, mod: int | None = ...) -> Any: ... - def __and__(self, n: int) -> int: ... - def __or__(self, n: int) -> int: ... - def __xor__(self, n: int) -> int: ... - def __lshift__(self, n: int) -> int: ... - def __rshift__(self, n: int) -> int: ... - def __rand__(self, n: int) -> int: ... - def __ror__(self, n: int) -> int: ... - def __rxor__(self, n: int) -> int: ... - def __rlshift__(self, n: int) -> int: ... - def __rrshift__(self, n: int) -> int: ... - def __neg__(self) -> int: ... - def __pos__(self) -> int: ... - def __invert__(self) -> int: ... - def __trunc__(self) -> int: ... - def __getnewargs__(self) -> tuple[int]: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: int) -> bool: ... - def __le__(self, x: int) -> bool: ... - def __gt__(self, x: int) -> bool: ... - def __ge__(self, x: int) -> bool: ... - def __float__(self) -> float: ... - def __int__(self) -> int: ... - def __abs__(self) -> int: ... - def __hash__(self) -> int: ... - def __nonzero__(self) -> bool: ... - def __index__(self) -> int: ... - -class float: - def __new__(cls: type[Self], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> Self: ... - def as_integer_ratio(self) -> tuple[int, int]: ... - def hex(self) -> str: ... - def is_integer(self) -> bool: ... - @classmethod - def fromhex(cls, __s: str) -> float: ... - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - def conjugate(self) -> float: ... - def __add__(self, x: float) -> float: ... - def __sub__(self, x: float) -> float: ... - def __mul__(self, x: float) -> float: ... - def __floordiv__(self, x: float) -> float: ... - def __div__(self, x: float) -> float: ... - def __truediv__(self, x: float) -> float: ... - def __mod__(self, x: float) -> float: ... - def __divmod__(self, x: float) -> tuple[float, float]: ... - def __pow__( - self, x: float, mod: None = ... - ) -> float: ... # In Python 3, returns complex if self is negative and x is not whole - def __radd__(self, x: float) -> float: ... - def __rsub__(self, x: float) -> float: ... - def __rmul__(self, x: float) -> float: ... - def __rfloordiv__(self, x: float) -> float: ... - def __rdiv__(self, x: float) -> float: ... - def __rtruediv__(self, x: float) -> float: ... - def __rmod__(self, x: float) -> float: ... - def __rdivmod__(self, x: float) -> tuple[float, float]: ... - def __rpow__(self, x: float, mod: None = ...) -> float: ... - def __getnewargs__(self) -> tuple[float]: ... - def __trunc__(self) -> int: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: float) -> bool: ... - def __le__(self, x: float) -> bool: ... - def __gt__(self, x: float) -> bool: ... - def __ge__(self, x: float) -> bool: ... - def __neg__(self) -> float: ... - def __pos__(self) -> float: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __abs__(self) -> float: ... - def __hash__(self) -> int: ... - def __nonzero__(self) -> bool: ... - -class complex: - @overload - def __new__(cls: type[Self], real: float = ..., imag: float = ...) -> Self: ... - @overload - def __new__(cls: type[Self], real: str | SupportsComplex | _SupportsIndex) -> Self: ... - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - def conjugate(self) -> complex: ... - def __add__(self, x: complex) -> complex: ... - def __sub__(self, x: complex) -> complex: ... - def __mul__(self, x: complex) -> complex: ... - def __pow__(self, x: complex, mod: None = ...) -> complex: ... - def __div__(self, x: complex) -> complex: ... - def __truediv__(self, x: complex) -> complex: ... - def __radd__(self, x: complex) -> complex: ... - def __rsub__(self, x: complex) -> complex: ... - def __rmul__(self, x: complex) -> complex: ... - def __rpow__(self, x: complex, mod: None = ...) -> complex: ... - def __rdiv__(self, x: complex) -> complex: ... - def __rtruediv__(self, x: complex) -> complex: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __neg__(self) -> complex: ... - def __pos__(self) -> complex: ... - def __complex__(self) -> complex: ... - def __abs__(self) -> float: ... - def __hash__(self) -> int: ... - def __nonzero__(self) -> bool: ... - -class basestring(metaclass=ABCMeta): ... - -class unicode(basestring, Sequence[unicode]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, o: object) -> None: ... - @overload - def __init__(self, o: str, encoding: unicode = ..., errors: unicode = ...) -> None: ... - def capitalize(self) -> unicode: ... - def center(self, width: int, fillchar: unicode = ...) -> unicode: ... - def count(self, x: unicode) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, __suffix: unicode | tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> unicode: ... - def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def format(self, *args: object, **kwargs: object) -> unicode: ... - def index(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdecimal(self) -> bool: ... - def isdigit(self) -> bool: ... - def isidentifier(self) -> bool: ... - def islower(self) -> bool: ... - def isnumeric(self) -> bool: ... - def isprintable(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, iterable: Iterable[unicode]) -> unicode: ... - def ljust(self, width: int, fillchar: unicode = ...) -> unicode: ... - def lower(self) -> unicode: ... - def lstrip(self, chars: unicode = ...) -> unicode: ... - def partition(self, sep: unicode) -> tuple[unicode, unicode, unicode]: ... - def replace(self, old: unicode, new: unicode, count: int = ...) -> unicode: ... - def rfind(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: unicode = ...) -> unicode: ... - def rpartition(self, sep: unicode) -> tuple[unicode, unicode, unicode]: ... - def rsplit(self, sep: unicode | None = ..., maxsplit: int = ...) -> list[unicode]: ... - def rstrip(self, chars: unicode = ...) -> unicode: ... - def split(self, sep: unicode | None = ..., maxsplit: int = ...) -> list[unicode]: ... - def splitlines(self, keepends: bool = ...) -> list[unicode]: ... - def startswith(self, __prefix: unicode | tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def strip(self, chars: unicode = ...) -> unicode: ... - def swapcase(self) -> unicode: ... - def title(self) -> unicode: ... - def translate(self, table: dict[int, Any] | unicode) -> unicode: ... - def upper(self) -> unicode: ... - def zfill(self, width: int) -> unicode: ... - @overload - def __getitem__(self, i: int) -> unicode: ... - @overload - def __getitem__(self, s: slice) -> unicode: ... - def __getslice__(self, start: int, stop: int) -> unicode: ... - def __add__(self, s: unicode) -> unicode: ... - def __mul__(self, n: int) -> unicode: ... - def __rmul__(self, n: int) -> unicode: ... - def __mod__(self, x: Any) -> unicode: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... - def __len__(self) -> int: ... - # The argument type is incompatible with Sequence - def __contains__(self, s: unicode | bytes) -> bool: ... # type: ignore[override] - def __iter__(self) -> Iterator[unicode]: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __hash__(self) -> int: ... - def __getnewargs__(self) -> tuple[unicode]: ... - -class _FormatMapMapping(Protocol): - def __getitem__(self, __key: str) -> Any: ... - -class str(Sequence[str], basestring): - def __init__(self, o: object = ...) -> None: ... - def capitalize(self) -> str: ... - def center(self, __width: int, __fillchar: str = ...) -> str: ... - def count(self, x: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... - def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... - def endswith(self, __suffix: Text | tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> str: ... - def find(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def format(self, *args: object, **kwargs: object) -> str: ... - def format_map(self, map: _FormatMapMapping) -> str: ... - def index(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, __iterable: Iterable[AnyStr]) -> AnyStr: ... - def ljust(self, __width: int, __fillchar: str = ...) -> str: ... - def lower(self) -> str: ... - @overload - def lstrip(self, __chars: str = ...) -> str: ... - @overload - def lstrip(self, __chars: unicode) -> unicode: ... - @overload - def partition(self, __sep: bytearray) -> tuple[str, bytearray, str]: ... - @overload - def partition(self, __sep: str) -> tuple[str, str, str]: ... - @overload - def partition(self, __sep: unicode) -> tuple[unicode, unicode, unicode]: ... - def replace(self, __old: AnyStr, __new: AnyStr, __count: int = ...) -> AnyStr: ... - def rfind(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def rindex(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... - def rjust(self, __width: int, __fillchar: str = ...) -> str: ... - @overload - def rpartition(self, __sep: bytearray) -> tuple[str, bytearray, str]: ... - @overload - def rpartition(self, __sep: str) -> tuple[str, str, str]: ... - @overload - def rpartition(self, __sep: unicode) -> tuple[unicode, unicode, unicode]: ... - @overload - def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... - @overload - def rsplit(self, sep: unicode, maxsplit: int = ...) -> list[unicode]: ... - @overload - def rstrip(self, __chars: str = ...) -> str: ... - @overload - def rstrip(self, __chars: unicode) -> unicode: ... - @overload - def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ... - @overload - def split(self, sep: unicode, maxsplit: int = ...) -> list[unicode]: ... - def splitlines(self, keepends: bool = ...) -> list[str]: ... - def startswith(self, __prefix: Text | tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - @overload - def strip(self, __chars: str = ...) -> str: ... - @overload - def strip(self, chars: unicode) -> unicode: ... - def swapcase(self) -> str: ... - def title(self) -> str: ... - def translate(self, __table: AnyStr | None, deletechars: AnyStr = ...) -> AnyStr: ... - def upper(self) -> str: ... - def zfill(self, __width: int) -> str: ... - def __add__(self, s: AnyStr) -> AnyStr: ... - # Incompatible with Sequence.__contains__ - def __contains__(self, o: str | Text) -> bool: ... # type: ignore[override] - def __eq__(self, x: object) -> bool: ... - def __ge__(self, x: Text) -> bool: ... - def __getitem__(self, i: int | slice) -> str: ... - def __gt__(self, x: Text) -> bool: ... - def __hash__(self) -> int: ... - def __iter__(self) -> Iterator[str]: ... - def __le__(self, x: Text) -> bool: ... - def __len__(self) -> int: ... - def __lt__(self, x: Text) -> bool: ... - def __mod__(self, x: Any) -> str: ... - def __mul__(self, n: int) -> str: ... - def __ne__(self, x: object) -> bool: ... - def __rmul__(self, n: int) -> str: ... - def __getnewargs__(self) -> tuple[str]: ... - def __getslice__(self, start: int, stop: int) -> str: ... - def __float__(self) -> float: ... - def __int__(self) -> int: ... - -bytes = str - -class bytearray(MutableSequence[int], ByteString): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, ints: Iterable[int]) -> None: ... - @overload - def __init__(self, string: str) -> None: ... - @overload - def __init__(self, string: Text, encoding: Text, errors: Text = ...) -> None: ... - @overload - def __init__(self, length: int) -> None: ... - def capitalize(self) -> bytearray: ... - def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... - def count(self, __sub: str) -> int: ... - def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... - def endswith(self, __suffix: bytes | tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def extend(self, iterable: str | Iterable[int]) -> None: ... - def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... - def index(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... - def insert(self, __index: int, __item: int) -> None: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, __iterable: Iterable[str]) -> bytearray: ... - def ljust(self, __width: int, __fillchar: str = ...) -> bytearray: ... - def lower(self) -> bytearray: ... - def lstrip(self, __bytes: bytes | None = ...) -> bytearray: ... - def partition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ... - def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... - def rfind(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... - def rindex(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... - def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... - def rpartition(self, __sep: bytes) -> tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> list[bytearray]: ... - def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... - def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> list[bytearray]: ... - def splitlines(self, keepends: bool = ...) -> list[bytearray]: ... - def startswith(self, __prefix: bytes | tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... - def strip(self, __bytes: bytes | None = ...) -> bytearray: ... - def swapcase(self) -> bytearray: ... - def title(self) -> bytearray: ... - def translate(self, __table: str) -> bytearray: ... - def upper(self) -> bytearray: ... - def zfill(self, __width: int) -> bytearray: ... - @classmethod - def fromhex(cls, __string: str) -> bytearray: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - __hash__: ClassVar[None] # type: ignore[assignment] - @overload - def __getitem__(self, i: int) -> int: ... - @overload - def __getitem__(self, s: slice) -> bytearray: ... - @overload - def __setitem__(self, i: int, x: int) -> None: ... - @overload - def __setitem__(self, s: slice, x: Iterable[int] | bytes) -> None: ... - def __delitem__(self, i: int | slice) -> None: ... - def __getslice__(self, start: int, stop: int) -> bytearray: ... - def __setslice__(self, start: int, stop: int, x: Sequence[int] | str) -> None: ... - def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, s: bytes) -> bytearray: ... - def __mul__(self, n: int) -> bytearray: ... - # Incompatible with Sequence.__contains__ - def __contains__(self, o: int | bytes) -> bool: ... # type: ignore[override] - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: bytes) -> bool: ... - def __le__(self, x: bytes) -> bool: ... - def __gt__(self, x: bytes) -> bool: ... - def __ge__(self, x: bytes) -> bool: ... - -class memoryview(Sized, Container[str]): - format: str - itemsize: int - shape: tuple[int, ...] | None - strides: tuple[int, ...] | None - suboffsets: tuple[int, ...] | None - readonly: bool - ndim: int - def __init__(self, obj: ReadableBuffer) -> None: ... - @overload - def __getitem__(self, i: int) -> str: ... - @overload - def __getitem__(self, s: slice) -> memoryview: ... - def __contains__(self, x: object) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - @overload - def __setitem__(self, s: slice, o: bytes) -> None: ... - @overload - def __setitem__(self, i: int, o: int) -> None: ... - def tobytes(self) -> bytes: ... - def tolist(self) -> list[int]: ... - -@final -class bool(int): - def __new__(cls: type[Self], __o: object = ...) -> Self: ... - @overload - def __and__(self, x: bool) -> bool: ... - @overload - def __and__(self, x: int) -> int: ... - @overload - def __or__(self, x: bool) -> bool: ... - @overload - def __or__(self, x: int) -> int: ... - @overload - def __xor__(self, x: bool) -> bool: ... - @overload - def __xor__(self, x: int) -> int: ... - @overload - def __rand__(self, x: bool) -> bool: ... - @overload - def __rand__(self, x: int) -> int: ... - @overload - def __ror__(self, x: bool) -> bool: ... - @overload - def __ror__(self, x: int) -> int: ... - @overload - def __rxor__(self, x: bool) -> bool: ... - @overload - def __rxor__(self, x: int) -> int: ... - def __getnewargs__(self) -> tuple[int]: ... - -class slice(object): - start: Any - step: Any - stop: Any - @overload - def __init__(self, stop: Any) -> None: ... - @overload - def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ... - __hash__: ClassVar[None] # type: ignore[assignment] - def indices(self, len: int) -> tuple[int, int, int]: ... - -class tuple(Sequence[_T_co], Generic[_T_co]): - def __new__(cls: type[Self], iterable: Iterable[_T_co] = ...) -> Self: ... - def __len__(self) -> int: ... - def __contains__(self, x: object) -> bool: ... - @overload - def __getitem__(self, x: int) -> _T_co: ... - @overload - def __getitem__(self, x: slice) -> tuple[_T_co, ...]: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __lt__(self, x: tuple[_T_co, ...]) -> bool: ... - def __le__(self, x: tuple[_T_co, ...]) -> bool: ... - def __gt__(self, x: tuple[_T_co, ...]) -> bool: ... - def __ge__(self, x: tuple[_T_co, ...]) -> bool: ... - @overload - def __add__(self, x: tuple[_T_co, ...]) -> tuple[_T_co, ...]: ... - @overload - def __add__(self, x: tuple[Any, ...]) -> tuple[Any, ...]: ... - def __mul__(self, n: int) -> tuple[_T_co, ...]: ... - def __rmul__(self, n: int) -> tuple[_T_co, ...]: ... - def count(self, __value: Any) -> int: ... - def index(self, __value: Any) -> int: ... - -class function: - # TODO not defined in builtins! - __name__: str - __module__: str - __code__: CodeType - -class list(MutableSequence[_T], Generic[_T]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, iterable: Iterable[_T]) -> None: ... - def append(self, __object: _T) -> None: ... - def extend(self, __iterable: Iterable[_T]) -> None: ... - def pop(self, __index: int = ...) -> _T: ... - def index(self, __value: _T, __start: int = ..., __stop: int = ...) -> int: ... - def count(self, __value: _T) -> int: ... - def insert(self, __index: int, __object: _T) -> None: ... - def remove(self, __value: _T) -> None: ... - def reverse(self) -> None: ... - def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_T]: ... - __hash__: ClassVar[None] # type: ignore[assignment] - @overload - def __getitem__(self, i: int) -> _T: ... - @overload - def __getitem__(self, s: slice) -> list[_T]: ... - @overload - def __setitem__(self, i: int, o: _T) -> None: ... - @overload - def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: int | slice) -> None: ... - def __getslice__(self, start: int, stop: int) -> list[_T]: ... - def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... - def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, x: list[_T]) -> list[_T]: ... - def __iadd__(self: Self, x: Iterable[_T]) -> Self: ... - def __mul__(self, n: int) -> list[_T]: ... - def __rmul__(self, n: int) -> list[_T]: ... - def __contains__(self, o: object) -> bool: ... - def __reversed__(self) -> Iterator[_T]: ... - def __gt__(self, x: list[_T]) -> bool: ... - def __ge__(self, x: list[_T]) -> bool: ... - def __lt__(self, x: list[_T]) -> bool: ... - def __le__(self, x: list[_T]) -> bool: ... - -class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): - # NOTE: Keyword arguments are special. If they are used, _KT must include - # str, but we have no way of enforcing it here. - @overload - def __init__(self, **kwargs: _VT) -> None: ... - @overload - def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ... - def has_key(self, k: _KT) -> bool: ... - def clear(self) -> None: ... - def copy(self) -> dict[_KT, _VT]: ... - def popitem(self) -> tuple[_KT, _VT]: ... - def setdefault(self, __key: _KT, __default: _VT = ...) -> _VT: ... - @overload - def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - @overload - def update(self, **kwargs: _VT) -> None: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT]: ... - def iteritems(self) -> Iterator[tuple[_KT, _VT]]: ... - def viewkeys(self) -> KeysView[_KT]: ... - def viewvalues(self) -> ValuesView[_VT]: ... - def viewitems(self) -> ItemsView[_KT, _VT]: ... - @classmethod - @overload - def fromkeys(cls, __iterable: Iterable[_T]) -> dict[_T, Any]: ... - @classmethod - @overload - def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> dict[_T, _S]: ... - def __len__(self) -> int: ... - def __getitem__(self, k: _KT) -> _VT: ... - def __setitem__(self, k: _KT, v: _VT) -> None: ... - def __delitem__(self, v: _KT) -> None: ... - def __iter__(self) -> Iterator[_KT]: ... - __hash__: ClassVar[None] # type: ignore[assignment] - -class set(MutableSet[_T], Generic[_T]): - def __init__(self, iterable: Iterable[_T] = ...) -> None: ... - def add(self, element: _T) -> None: ... - def clear(self) -> None: ... - def copy(self) -> set[_T]: ... - def difference(self, *s: Iterable[Any]) -> set[_T]: ... - def difference_update(self, *s: Iterable[Any]) -> None: ... - def discard(self, element: _T) -> None: ... - def intersection(self, *s: Iterable[Any]) -> set[_T]: ... - def intersection_update(self, *s: Iterable[Any]) -> None: ... - def isdisjoint(self, s: Iterable[Any]) -> bool: ... - def issubset(self, s: Iterable[Any]) -> bool: ... - def issuperset(self, s: Iterable[Any]) -> bool: ... - def pop(self) -> _T: ... - def remove(self, element: _T) -> None: ... - def symmetric_difference(self, s: Iterable[_T]) -> set[_T]: ... - def symmetric_difference_update(self, s: Iterable[_T]) -> None: ... - def union(self, *s: Iterable[_T]) -> set[_T]: ... - def update(self, *s: Iterable[_T]) -> None: ... - def __len__(self) -> int: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_T]: ... - def __and__(self, s: AbstractSet[object]) -> set[_T]: ... - def __iand__(self: Self, s: AbstractSet[object]) -> Self: ... - def __or__(self, s: AbstractSet[_S]) -> set[_T | _S]: ... - def __ior__(self: Self, s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - @overload - def __sub__(self: set[str], s: AbstractSet[Text | None]) -> set[_T]: ... - @overload - def __sub__(self, s: AbstractSet[_T | None]) -> set[_T]: ... - @overload # type: ignore - def __isub__(self: set[str], s: AbstractSet[Text | None]) -> set[_T]: ... - @overload - def __isub__(self, s: AbstractSet[_T | None]) -> set[_T]: ... - def __xor__(self, s: AbstractSet[_S]) -> set[_T | _S]: ... - def __ixor__(self: Self, s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - def __le__(self, s: AbstractSet[object]) -> bool: ... - def __lt__(self, s: AbstractSet[object]) -> bool: ... - def __ge__(self, s: AbstractSet[object]) -> bool: ... - def __gt__(self, s: AbstractSet[object]) -> bool: ... - __hash__: ClassVar[None] # type: ignore[assignment] - -class frozenset(AbstractSet[_T_co], Generic[_T_co]): - def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ... - def copy(self) -> frozenset[_T_co]: ... - def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ... - def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ... - def isdisjoint(self, s: Iterable[_T_co]) -> bool: ... - def issubset(self, s: Iterable[object]) -> bool: ... - def issuperset(self, s: Iterable[object]) -> bool: ... - def symmetric_difference(self, s: Iterable[_T_co]) -> frozenset[_T_co]: ... - def union(self, *s: Iterable[_T_co]) -> frozenset[_T_co]: ... - def __len__(self) -> int: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __and__(self, s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... - def __or__(self, s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ... - def __sub__(self, s: AbstractSet[_T_co]) -> frozenset[_T_co]: ... - def __xor__(self, s: AbstractSet[_S]) -> frozenset[_T_co | _S]: ... - def __le__(self, s: AbstractSet[object]) -> bool: ... - def __lt__(self, s: AbstractSet[object]) -> bool: ... - def __ge__(self, s: AbstractSet[object]) -> bool: ... - def __gt__(self, s: AbstractSet[object]) -> bool: ... - -class enumerate(Iterator[tuple[int, _T]], Generic[_T]): - def __init__(self, iterable: Iterable[_T], start: int = ...) -> None: ... - def __iter__(self: Self) -> Self: ... - def next(self) -> tuple[int, _T]: ... - -class xrange(Sized, Iterable[int], Reversible[int]): - @overload - def __init__(self, stop: int) -> None: ... - @overload - def __init__(self, start: int, stop: int, step: int = ...) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - def __getitem__(self, i: _SupportsIndex) -> int: ... - def __reversed__(self) -> Iterator[int]: ... - -class property(object): - def __init__( - self, - fget: Callable[[Any], Any] | None = ..., - fset: Callable[[Any, Any], None] | None = ..., - fdel: Callable[[Any], None] | None = ..., - doc: str | None = ..., - ) -> None: ... - def getter(self, fget: Callable[[Any], Any]) -> property: ... - def setter(self, fset: Callable[[Any, Any], None]) -> property: ... - def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: type | None = ...) -> Any: ... - def __set__(self, obj: Any, value: Any) -> None: ... - def __delete__(self, obj: Any) -> None: ... - def fget(self) -> Any: ... - def fset(self, value: Any) -> None: ... - def fdel(self) -> None: ... - -long = int - -class _NotImplementedType(Any): # type: ignore[misc] - # A little weird, but typing the __call__ as NotImplemented makes the error message - # for NotImplemented() much better - __call__: NotImplemented # type: ignore[valid-type] - -NotImplemented: _NotImplementedType - -def abs(__x: SupportsAbs[_T]) -> _T: ... -def all(__iterable: Iterable[object]) -> bool: ... -def any(__iterable: Iterable[object]) -> bool: ... -def apply(__func: Callable[..., _T], __args: Sequence[Any] | None = ..., __kwds: Mapping[str, Any] | None = ...) -> _T: ... -def bin(__number: int | _SupportsIndex) -> str: ... -def callable(__obj: object) -> bool: ... -def chr(__i: int) -> str: ... -def cmp(__x: Any, __y: Any) -> int: ... - -_N1 = TypeVar("_N1", bool, int, float, complex) - -def coerce(__x: _N1, __y: _N1) -> tuple[_N1, _N1]: ... -def compile(source: Text | mod, filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... -def delattr(__obj: Any, __name: Text) -> None: ... -def dir(__o: object = ...) -> list[str]: ... - -_N2 = TypeVar("_N2", int, float) - -def divmod(__x: _N2, __y: _N2) -> tuple[_N2, _N2]: ... -def eval( - __source: Text | bytes | CodeType, __globals: dict[str, Any] | None = ..., __locals: Mapping[str, Any] | None = ... -) -> Any: ... -def execfile(__filename: str, __globals: dict[str, Any] | None = ..., __locals: dict[str, Any] | None = ...) -> None: ... -def exit(code: object = ...) -> NoReturn: ... -@overload -def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore -@overload -def filter(__function: None, __iterable: tuple[_T | None, ...]) -> tuple[_T, ...]: ... # type: ignore -@overload -def filter(__function: Callable[[_T], Any], __iterable: tuple[_T, ...]) -> tuple[_T, ...]: ... # type: ignore -@overload -def filter(__function: None, __iterable: Iterable[_T | None]) -> list[_T]: ... -@overload -def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> list[_T]: ... -def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode -@overload -def getattr(__o: Any, name: Text) -> Any: ... - -# While technically covered by the last overload, spelling out the types for None, bool -# and basic containers help mypy out in some tricky situations involving type context -# (aka bidirectional inference) -@overload -def getattr(__o: Any, name: Text, __default: None) -> Any | None: ... -@overload -def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... -@overload -def getattr(__o: object, name: str, __default: list[Any]) -> Any | list[Any]: ... -@overload -def getattr(__o: object, name: str, __default: dict[Any, Any]) -> Any | dict[Any, Any]: ... -@overload -def getattr(__o: Any, name: Text, __default: _T) -> Any | _T: ... -def globals() -> dict[str, Any]: ... -def hasattr(__obj: Any, __name: Text) -> bool: ... -def hash(__obj: object) -> int: ... -def hex(__number: int | _SupportsIndex) -> str: ... -def id(__obj: object) -> int: ... -def input(__prompt: Any = ...) -> Any: ... -def intern(__string: str) -> str: ... -@overload -def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... -@overload -def iter(__function: Callable[[], _T | None], __sentinel: None) -> Iterator[_T]: ... -@overload -def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... -def isinstance(__obj: object, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... -def issubclass(__cls: type, __class_or_tuple: type | tuple[type | tuple[Any, ...], ...]) -> bool: ... -def len(__obj: Sized) -> int: ... -def locals() -> dict[str, Any]: ... -@overload -def map(__func: None, __iter1: Iterable[_T1]) -> list[_T1]: ... -@overload -def map(__func: None, __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> list[tuple[_T1, _T2]]: ... -@overload -def map(__func: None, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> list[tuple[_T1, _T2, _T3]]: ... -@overload -def map( - __func: None, __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4] -) -> list[tuple[_T1, _T2, _T3, _T4]]: ... -@overload -def map( - __func: None, - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - __iter5: Iterable[_T5], -) -> list[tuple[_T1, _T2, _T3, _T4, _T5]]: ... -@overload -def map( - __func: None, - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], -) -> list[tuple[Any, ...]]: ... -@overload -def map(__func: Callable[[_T1], _S], __iter1: Iterable[_T1]) -> list[_S]: ... -@overload -def map(__func: Callable[[_T1, _T2], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> list[_S]: ... -@overload -def map( - __func: Callable[[_T1, _T2, _T3], _S], __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3] -) -> list[_S]: ... -@overload -def map( - __func: Callable[[_T1, _T2, _T3, _T4], _S], - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], -) -> list[_S]: ... -@overload -def map( - __func: Callable[[_T1, _T2, _T3, _T4, _T5], _S], - __iter1: Iterable[_T1], - __iter2: Iterable[_T2], - __iter3: Iterable[_T3], - __iter4: Iterable[_T4], - __iter5: Iterable[_T5], -) -> list[_S]: ... -@overload -def map( - __func: Callable[..., _S], - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], -) -> list[_S]: ... -@overload -def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def max(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def min(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def next(__i: Iterator[_T]) -> _T: ... -@overload -def next(__i: Iterator[_T], __default: _VT) -> _T | _VT: ... -def oct(__number: int | _SupportsIndex) -> str: ... -def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... -def ord(__c: Text | bytes) -> int: ... - -# This is only available after from __future__ import print_function. -def print(*values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ...) -> None: ... - -_E = TypeVar("_E", contravariant=True) -_M = TypeVar("_M", contravariant=True) - -class _SupportsPow2(Protocol[_E, _T_co]): - def __pow__(self, __other: _E) -> _T_co: ... - -class _SupportsPow3(Protocol[_E, _M, _T_co]): - def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ... - -@overload -def pow(__base: int, __exp: int, __mod: None = ...) -> Any: ... # returns int or float depending on whether exp is non-negative -@overload -def pow(__base: int, __exp: int, __mod: int) -> int: ... -@overload -def pow(__base: float, __exp: float, __mod: None = ...) -> float: ... -@overload -def pow(__base: _SupportsPow2[_E, _T_co], __exp: _E) -> _T_co: ... -@overload -def pow(__base: _SupportsPow3[_E, _M, _T_co], __exp: _E, __mod: _M) -> _T_co: ... -def quit(code: object = ...) -> NoReturn: ... -def range(__x: int, __y: int = ..., __step: int = ...) -> list[int]: ... -def raw_input(__prompt: Any = ...) -> str: ... -@overload -def reduce(__function: Callable[[_T, _S], _T], __iterable: Iterable[_S], __initializer: _T) -> _T: ... -@overload -def reduce(__function: Callable[[_T, _T], _T], __iterable: Iterable[_T]) -> _T: ... -def reload(__module: Any) -> Any: ... -@overload -def reversed(__sequence: Sequence[_T]) -> Iterator[_T]: ... -@overload -def reversed(__sequence: Reversible[_T]) -> Iterator[_T]: ... -def repr(__obj: object) -> str: ... -@overload -def round(number: float) -> float: ... -@overload -def round(number: float, ndigits: int) -> float: ... -@overload -def round(number: SupportsFloat) -> float: ... -@overload -def round(number: SupportsFloat, ndigits: int) -> float: ... -def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... -def sorted( - __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Callable[[_T], Any] | None = ..., reverse: bool = ... -) -> list[_T]: ... -@overload -def sum(__iterable: Iterable[_T]) -> _T | int: ... -@overload -def sum(__iterable: Iterable[_T], __start: _S) -> _T | _S: ... -def unichr(__i: int) -> unicode: ... -def vars(__object: Any = ...) -> dict[str, Any]: ... -@overload -def zip(__iter1: Iterable[_T1]) -> list[tuple[_T1]]: ... -@overload -def zip(__iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> list[tuple[_T1, _T2]]: ... -@overload -def zip(__iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3]) -> list[tuple[_T1, _T2, _T3]]: ... -@overload -def zip( - __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4] -) -> list[tuple[_T1, _T2, _T3, _T4]]: ... -@overload -def zip( - __iter1: Iterable[_T1], __iter2: Iterable[_T2], __iter3: Iterable[_T3], __iter4: Iterable[_T4], __iter5: Iterable[_T5] -) -> list[tuple[_T1, _T2, _T3, _T4, _T5]]: ... -@overload -def zip( - __iter1: Iterable[Any], - __iter2: Iterable[Any], - __iter3: Iterable[Any], - __iter4: Iterable[Any], - __iter5: Iterable[Any], - __iter6: Iterable[Any], - *iterables: Iterable[Any], -) -> list[tuple[Any, ...]]: ... -def __import__( - name: Text, - globals: Mapping[str, Any] | None = ..., - locals: Mapping[str, Any] | None = ..., - fromlist: Sequence[str] = ..., - level: int = ..., -) -> Any: ... - -# Actually the type of Ellipsis is , but since it's -# not exposed anywhere under that name, we make it private here. -class ellipsis: ... - -Ellipsis: ellipsis - -# TODO: buffer support is incomplete; e.g. some_string.startswith(some_buffer) doesn't type check. -_AnyBuffer = TypeVar("_AnyBuffer", str, unicode, bytearray, buffer) - -class buffer(Sized): - def __init__(self, object: _AnyBuffer, offset: int = ..., size: int = ...) -> None: ... - def __add__(self, other: _AnyBuffer) -> str: ... - def __cmp__(self, other: _AnyBuffer) -> bool: ... - def __getitem__(self, key: int | slice) -> str: ... - def __getslice__(self, i: int, j: int) -> str: ... - def __len__(self) -> int: ... - def __mul__(self, x: int) -> str: ... - -class BaseException(object): - args: tuple[Any, ...] - message: Any - def __init__(self, *args: object) -> None: ... - def __getitem__(self, i: int) -> Any: ... - def __getslice__(self, start: int, stop: int) -> tuple[Any, ...]: ... - -class GeneratorExit(BaseException): ... -class KeyboardInterrupt(BaseException): ... - -class SystemExit(BaseException): - code: int - -class Exception(BaseException): ... -class StopIteration(Exception): ... -class StandardError(Exception): ... - -_StandardError = StandardError - -class EnvironmentError(StandardError): - errno: int - strerror: str - # TODO can this be unicode? - filename: str - -class OSError(EnvironmentError): ... -class IOError(EnvironmentError): ... -class ArithmeticError(_StandardError): ... -class AssertionError(_StandardError): ... -class AttributeError(_StandardError): ... -class BufferError(_StandardError): ... -class EOFError(_StandardError): ... -class ImportError(_StandardError): ... -class LookupError(_StandardError): ... -class MemoryError(_StandardError): ... -class NameError(_StandardError): ... -class ReferenceError(_StandardError): ... -class RuntimeError(_StandardError): ... - -class SyntaxError(_StandardError): - msg: str - lineno: int | None - offset: int | None - text: str | None - filename: str | None - -class SystemError(_StandardError): ... -class TypeError(_StandardError): ... -class ValueError(_StandardError): ... -class FloatingPointError(ArithmeticError): ... -class OverflowError(ArithmeticError): ... -class ZeroDivisionError(ArithmeticError): ... -class IndexError(LookupError): ... -class KeyError(LookupError): ... -class UnboundLocalError(NameError): ... - -class WindowsError(OSError): - winerror: int - -class NotImplementedError(RuntimeError): ... -class IndentationError(SyntaxError): ... -class TabError(IndentationError): ... -class UnicodeError(ValueError): ... - -class UnicodeDecodeError(UnicodeError): - encoding: str - object: bytes - start: int - end: int - reason: str - def __init__(self, __encoding: str, __object: bytes, __start: int, __end: int, __reason: str) -> None: ... - -class UnicodeEncodeError(UnicodeError): - encoding: str - object: Text - start: int - end: int - reason: str - def __init__(self, __encoding: str, __object: Text, __start: int, __end: int, __reason: str) -> None: ... - -class UnicodeTranslateError(UnicodeError): ... -class Warning(Exception): ... -class UserWarning(Warning): ... -class DeprecationWarning(Warning): ... -class SyntaxWarning(Warning): ... -class RuntimeWarning(Warning): ... -class FutureWarning(Warning): ... -class PendingDeprecationWarning(Warning): ... -class ImportWarning(Warning): ... -class UnicodeWarning(Warning): ... -class BytesWarning(Warning): ... - -class file(BinaryIO): - @overload - def __init__(self, file: str, mode: str = ..., buffering: int = ...) -> None: ... - @overload - def __init__(self, file: unicode, mode: str = ..., buffering: int = ...) -> None: ... - @overload - def __init__(self, file: int, mode: str = ..., buffering: int = ...) -> None: ... - def __iter__(self) -> Iterator[str]: ... - def next(self) -> str: ... - def read(self, n: int = ...) -> str: ... - def __enter__(self) -> BinaryIO: ... - def __exit__(self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ...) -> bool | None: ... - def flush(self) -> None: ... - def fileno(self) -> int: ... - def isatty(self) -> bool: ... - def close(self) -> None: ... - def readable(self) -> bool: ... - def writable(self) -> bool: ... - def seekable(self) -> bool: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def tell(self) -> int: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> list[str]: ... - def write(self, data: str) -> int: ... - def writelines(self, data: Iterable[str]) -> None: ... - def truncate(self, pos: int | None = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/bz2.pyi b/mypy/typeshed/stdlib/@python2/bz2.pyi deleted file mode 100644 index 95377347cce8..000000000000 --- a/mypy/typeshed/stdlib/@python2/bz2.pyi +++ /dev/null @@ -1,31 +0,0 @@ -import io -from _typeshed import ReadableBuffer, Self, WriteableBuffer -from typing import IO, Any, Iterable, Text -from typing_extensions import SupportsIndex - -_PathOrFile = Text | IO[bytes] - -def compress(data: bytes, compresslevel: int = ...) -> bytes: ... -def decompress(data: bytes) -> bytes: ... - -class BZ2File(io.BufferedIOBase, IO[bytes]): - def __enter__(self: Self) -> Self: ... - def __init__(self, filename: _PathOrFile, mode: str = ..., buffering: Any | None = ..., compresslevel: int = ...) -> None: ... - def read(self, size: int | None = ...) -> bytes: ... - def read1(self, size: int = ...) -> bytes: ... - def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore[override] - def readinto(self, b: WriteableBuffer) -> int: ... - def readlines(self, size: SupportsIndex = ...) -> list[bytes]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def write(self, data: ReadableBuffer) -> int: ... - def writelines(self, seq: Iterable[ReadableBuffer]) -> None: ... - -class BZ2Compressor(object): - def __init__(self, compresslevel: int = ...) -> None: ... - def compress(self, __data: bytes) -> bytes: ... - def flush(self) -> bytes: ... - -class BZ2Decompressor(object): - def decompress(self, data: bytes) -> bytes: ... - @property - def unused_data(self) -> bytes: ... diff --git a/mypy/typeshed/stdlib/@python2/cPickle.pyi b/mypy/typeshed/stdlib/@python2/cPickle.pyi deleted file mode 100644 index 9169a8df02b0..000000000000 --- a/mypy/typeshed/stdlib/@python2/cPickle.pyi +++ /dev/null @@ -1,26 +0,0 @@ -from typing import IO, Any - -HIGHEST_PROTOCOL: int -compatible_formats: list[str] -format_version: str - -class Pickler: - def __init__(self, file: IO[str], protocol: int = ...) -> None: ... - def dump(self, obj: Any) -> None: ... - def clear_memo(self) -> None: ... - -class Unpickler: - def __init__(self, file: IO[str]) -> None: ... - def load(self) -> Any: ... - def noload(self) -> Any: ... - -def dump(obj: Any, file: IO[str], protocol: int = ...) -> None: ... -def dumps(obj: Any, protocol: int = ...) -> str: ... -def load(file: IO[str]) -> Any: ... -def loads(str: str) -> Any: ... - -class PickleError(Exception): ... -class UnpicklingError(PickleError): ... -class BadPickleGet(UnpicklingError): ... -class PicklingError(PickleError): ... -class UnpickleableError(PicklingError): ... diff --git a/mypy/typeshed/stdlib/@python2/cProfile.pyi b/mypy/typeshed/stdlib/@python2/cProfile.pyi deleted file mode 100644 index 40731e2f3d76..000000000000 --- a/mypy/typeshed/stdlib/@python2/cProfile.pyi +++ /dev/null @@ -1,30 +0,0 @@ -from _typeshed import Self -from types import CodeType -from typing import Any, Callable, Text, TypeVar -from typing_extensions import ParamSpec - -def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... -def runctx( - statement: str, globals: dict[str, Any], locals: dict[str, Any], filename: str | None = ..., sort: str | int = ... -) -> None: ... - -_T = TypeVar("_T") -_P = ParamSpec("_P") -_Label = tuple[str, int, str] - -class Profile: - stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented - def __init__( - self, timer: Callable[[], float] = ..., timeunit: float = ..., subcalls: bool = ..., builtins: bool = ... - ) -> None: ... - def enable(self) -> None: ... - def disable(self) -> None: ... - def print_stats(self, sort: str | int = ...) -> None: ... - def dump_stats(self, file: Text) -> None: ... - def create_stats(self) -> None: ... - def snapshot_stats(self) -> None: ... - def run(self: Self, cmd: str) -> Self: ... - def runctx(self: Self, cmd: str, globals: dict[str, Any], locals: dict[str, Any]) -> Self: ... - def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... - -def label(code: str | CodeType) -> _Label: ... # undocumented diff --git a/mypy/typeshed/stdlib/@python2/cStringIO.pyi b/mypy/typeshed/stdlib/@python2/cStringIO.pyi deleted file mode 100644 index 33a20dd4a739..000000000000 --- a/mypy/typeshed/stdlib/@python2/cStringIO.pyi +++ /dev/null @@ -1,47 +0,0 @@ -from abc import ABCMeta -from typing import IO, Iterable, Iterator, overload - -# This class isn't actually abstract, but you can't instantiate it -# directly, so we might as well treat it as abstract in the stub. -class InputType(IO[str], Iterator[str], metaclass=ABCMeta): - def getvalue(self) -> str: ... - def close(self) -> None: ... - @property - def closed(self) -> bool: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, size: int = ...) -> str: ... - def readline(self, size: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> list[str]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def tell(self) -> int: ... - def truncate(self, size: int | None = ...) -> int: ... - def __iter__(self) -> InputType: ... - def next(self) -> str: ... - def reset(self) -> None: ... - -class OutputType(IO[str], Iterator[str], metaclass=ABCMeta): - @property - def softspace(self) -> int: ... - def getvalue(self) -> str: ... - def close(self) -> None: ... - @property - def closed(self) -> bool: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, size: int = ...) -> str: ... - def readline(self, size: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> list[str]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def tell(self) -> int: ... - def truncate(self, size: int | None = ...) -> int: ... - def __iter__(self) -> OutputType: ... - def next(self) -> str: ... - def reset(self) -> None: ... - def write(self, b: str | unicode) -> int: ... - def writelines(self, lines: Iterable[str | unicode]) -> None: ... - -@overload -def StringIO() -> OutputType: ... -@overload -def StringIO(s: str) -> InputType: ... diff --git a/mypy/typeshed/stdlib/@python2/calendar.pyi b/mypy/typeshed/stdlib/@python2/calendar.pyi deleted file mode 100644 index f14b0735fa67..000000000000 --- a/mypy/typeshed/stdlib/@python2/calendar.pyi +++ /dev/null @@ -1,103 +0,0 @@ -import datetime -from time import struct_time -from typing import Any, Iterable, Sequence - -_LocaleType = tuple[str | None, str | None] - -class IllegalMonthError(ValueError): - def __init__(self, month: int) -> None: ... - -class IllegalWeekdayError(ValueError): - def __init__(self, weekday: int) -> None: ... - -def isleap(year: int) -> bool: ... -def leapdays(y1: int, y2: int) -> int: ... -def weekday(year: int, month: int, day: int) -> int: ... -def monthrange(year: int, month: int) -> tuple[int, int]: ... - -class Calendar: - firstweekday: int - def __init__(self, firstweekday: int = ...) -> None: ... - def getfirstweekday(self) -> int: ... - def setfirstweekday(self, firstweekday: int) -> None: ... - def iterweekdays(self) -> Iterable[int]: ... - def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ... - def itermonthdays2(self, year: int, month: int) -> Iterable[tuple[int, int]]: ... - def itermonthdays(self, year: int, month: int) -> Iterable[int]: ... - def monthdatescalendar(self, year: int, month: int) -> list[list[datetime.date]]: ... - def monthdays2calendar(self, year: int, month: int) -> list[list[tuple[int, int]]]: ... - def monthdayscalendar(self, year: int, month: int) -> list[list[int]]: ... - def yeardatescalendar(self, year: int, width: int = ...) -> list[list[int]]: ... - def yeardays2calendar(self, year: int, width: int = ...) -> list[list[tuple[int, int]]]: ... - def yeardayscalendar(self, year: int, width: int = ...) -> list[list[int]]: ... - -class TextCalendar(Calendar): - def prweek(self, theweek: int, width: int) -> None: ... - def formatday(self, day: int, weekday: int, width: int) -> str: ... - def formatweek(self, theweek: int, width: int) -> str: ... - def formatweekday(self, day: int, width: int) -> str: ... - def formatweekheader(self, width: int) -> str: ... - def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... - def prmonth(self, theyear: int, themonth: int, w: int = ..., l: int = ...) -> None: ... - def formatmonth(self, theyear: int, themonth: int, w: int = ..., l: int = ...) -> str: ... - def formatyear(self, theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> str: ... - def pryear(self, theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> None: ... - -def firstweekday() -> int: ... -def monthcalendar(year: int, month: int) -> list[list[int]]: ... -def prweek(theweek: int, width: int) -> None: ... -def week(theweek: int, width: int) -> str: ... -def weekheader(width: int) -> str: ... -def prmonth(theyear: int, themonth: int, w: int = ..., l: int = ...) -> None: ... -def month(theyear: int, themonth: int, w: int = ..., l: int = ...) -> str: ... -def calendar(theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> str: ... -def prcal(theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> None: ... - -class HTMLCalendar(Calendar): - def formatday(self, day: int, weekday: int) -> str: ... - def formatweek(self, theweek: int) -> str: ... - def formatweekday(self, day: int) -> str: ... - def formatweekheader(self) -> str: ... - def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... - def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... - def formatyear(self, theyear: int, width: int = ...) -> str: ... - def formatyearpage(self, theyear: int, width: int = ..., css: str | None = ..., encoding: str | None = ...) -> str: ... - -class TimeEncoding: - def __init__(self, locale: _LocaleType) -> None: ... - def __enter__(self) -> _LocaleType: ... - def __exit__(self, *args: Any) -> None: ... - -class LocaleTextCalendar(TextCalendar): - def __init__(self, firstweekday: int = ..., locale: _LocaleType | None = ...) -> None: ... - def formatweekday(self, day: int, width: int) -> str: ... - def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... - -class LocaleHTMLCalendar(HTMLCalendar): - def __init__(self, firstweekday: int = ..., locale: _LocaleType | None = ...) -> None: ... - def formatweekday(self, day: int) -> str: ... - def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... - -c: TextCalendar - -def setfirstweekday(firstweekday: int) -> None: ... -def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... -def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... -def timegm(tuple: tuple[int, ...] | struct_time) -> int: ... - -# Data attributes -day_name: Sequence[str] -day_abbr: Sequence[str] -month_name: Sequence[str] -month_abbr: Sequence[str] - -# Below constants are not in docs or __all__, but enough people have used them -# they are now effectively public. - -MONDAY: int -TUESDAY: int -WEDNESDAY: int -THURSDAY: int -FRIDAY: int -SATURDAY: int -SUNDAY: int diff --git a/mypy/typeshed/stdlib/@python2/cgi.pyi b/mypy/typeshed/stdlib/@python2/cgi.pyi deleted file mode 100644 index 6c83a9c27e55..000000000000 --- a/mypy/typeshed/stdlib/@python2/cgi.pyi +++ /dev/null @@ -1,105 +0,0 @@ -from _typeshed import SupportsGetItem, SupportsItemAccess -from builtins import list as List, type as _type # aliases to avoid name clashes with `FieldStorage` attributes -from typing import IO, Any, AnyStr, Iterable, Iterator, Mapping, Protocol -from UserDict import UserDict - -def parse( - fp: IO[Any] | None = ..., - environ: SupportsItemAccess[str, str] = ..., - keep_blank_values: bool = ..., - strict_parsing: bool = ..., -) -> dict[str, list[str]]: ... -def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> dict[str, list[str]]: ... -def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> list[tuple[str, str]]: ... -def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> dict[str, list[bytes]]: ... - -class _Environ(Protocol): - def __getitem__(self, __k: str) -> str: ... - def keys(self) -> Iterable[str]: ... - -def parse_header(line: str) -> tuple[str, dict[str, str]]: ... -def test(environ: _Environ = ...) -> None: ... -def print_environ(environ: _Environ = ...) -> None: ... -def print_form(form: dict[str, Any]) -> None: ... -def print_directory() -> None: ... -def print_environ_usage() -> None: ... -def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ... - -class MiniFieldStorage: - # The first five "Any" attributes here are always None, but mypy doesn't support that - filename: Any - list: Any - type: Any - file: IO[bytes] | None - type_options: dict[Any, Any] - disposition: Any - disposition_options: dict[Any, Any] - headers: dict[Any, Any] - name: Any - value: Any - def __init__(self, name: Any, value: Any) -> None: ... - -class FieldStorage(object): - FieldStorageClass: _type | None - keep_blank_values: int - strict_parsing: int - qs_on_post: str | None - headers: Mapping[str, str] - fp: IO[bytes] - encoding: str - errors: str - outerboundary: bytes - bytes_read: int - limit: int | None - disposition: str - disposition_options: dict[str, str] - filename: str | None - file: IO[bytes] | None - type: str - type_options: dict[str, str] - innerboundary: bytes - length: int - done: int - list: List[Any] | None - value: None | bytes | List[Any] - def __init__( - self, - fp: IO[Any] = ..., - headers: Mapping[str, str] = ..., - outerboundary: bytes = ..., - environ: SupportsGetItem[str, str] = ..., - keep_blank_values: int = ..., - strict_parsing: int = ..., - ) -> None: ... - def __iter__(self) -> Iterator[str]: ... - def __getitem__(self, key: str) -> Any: ... - def getvalue(self, key: str, default: Any = ...) -> Any: ... - def getfirst(self, key: str, default: Any = ...) -> Any: ... - def getlist(self, key: str) -> List[Any]: ... - def keys(self) -> List[str]: ... - def has_key(self, key: str) -> bool: ... - def __contains__(self, key: str) -> bool: ... - def __len__(self) -> int: ... - def __nonzero__(self) -> bool: ... - # In Python 2 it always returns bytes and ignores the "binary" flag - def make_file(self, binary: Any = ...) -> IO[bytes]: ... - -class FormContentDict(UserDict[str, list[str]]): - query_string: str - def __init__(self, environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ... - -class SvFormContentDict(FormContentDict): - def getlist(self, key: Any) -> Any: ... - -class InterpFormContentDict(SvFormContentDict): ... - -class FormContent(FormContentDict): - # TODO this should have - # def values(self, key: Any) -> Any: ... - # but this is incompatible with the supertype, and adding '# type: ignore' triggers - # a parse error in pytype (https://github.com/google/pytype/issues/53) - def indexed_value(self, key: Any, location: int) -> Any: ... - def value(self, key: Any) -> Any: ... - def length(self, key: Any) -> int: ... - def stripped(self, key: Any) -> Any: ... - def pars(self) -> dict[Any, Any]: ... diff --git a/mypy/typeshed/stdlib/@python2/cgitb.pyi b/mypy/typeshed/stdlib/@python2/cgitb.pyi deleted file mode 100644 index aff45db6198c..000000000000 --- a/mypy/typeshed/stdlib/@python2/cgitb.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from types import FrameType, TracebackType -from typing import IO, Any, Callable, Optional, Text - -_ExcInfo = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]] - -def reset() -> str: ... # undocumented -def small(text: str) -> str: ... # undocumented -def strong(text: str) -> str: ... # undocumented -def grey(text: str) -> str: ... # undocumented -def lookup(name: str, frame: FrameType, locals: dict[str, Any]) -> tuple[str | None, Any]: ... # undocumented -def scanvars( - reader: Callable[[], bytes], frame: FrameType, locals: dict[str, Any] -) -> list[tuple[str, str | None, Any]]: ... # undocumented -def html(einfo: _ExcInfo, context: int = ...) -> str: ... -def text(einfo: _ExcInfo, context: int = ...) -> str: ... - -class Hook: # undocumented - def __init__( - self, display: int = ..., logdir: Text | None = ..., context: int = ..., file: IO[str] | None = ..., format: str = ... - ) -> None: ... - def __call__(self, etype: type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None) -> None: ... - def handle(self, info: _ExcInfo | None = ...) -> None: ... - -def handler(info: _ExcInfo | None = ...) -> None: ... -def enable(display: int = ..., logdir: Text | None = ..., context: int = ..., format: str = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/chunk.pyi b/mypy/typeshed/stdlib/@python2/chunk.pyi deleted file mode 100644 index 50ff267c5436..000000000000 --- a/mypy/typeshed/stdlib/@python2/chunk.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from typing import IO - -class Chunk: - closed: bool - align: bool - file: IO[bytes] - chunkname: bytes - chunksize: int - size_read: int - offset: int - seekable: bool - def __init__(self, file: IO[bytes], align: bool = ..., bigendian: bool = ..., inclheader: bool = ...) -> None: ... - def getname(self) -> bytes: ... - def getsize(self) -> int: ... - def close(self) -> None: ... - def isatty(self) -> bool: ... - def seek(self, pos: int, whence: int = ...) -> None: ... - def tell(self) -> int: ... - def read(self, size: int = ...) -> bytes: ... - def skip(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/cmath.pyi b/mypy/typeshed/stdlib/@python2/cmath.pyi deleted file mode 100644 index 1053b2269812..000000000000 --- a/mypy/typeshed/stdlib/@python2/cmath.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from typing import SupportsComplex, SupportsFloat - -e: float -pi: float -_C = SupportsFloat | SupportsComplex | complex - -def acos(__z: _C) -> complex: ... -def acosh(__z: _C) -> complex: ... -def asin(__z: _C) -> complex: ... -def asinh(__z: _C) -> complex: ... -def atan(__z: _C) -> complex: ... -def atanh(__z: _C) -> complex: ... -def cos(__z: _C) -> complex: ... -def cosh(__z: _C) -> complex: ... -def exp(__z: _C) -> complex: ... -def isinf(__z: _C) -> bool: ... -def isnan(__z: _C) -> bool: ... -def log(__x: _C, __y_obj: _C = ...) -> complex: ... -def log10(__z: _C) -> complex: ... -def phase(__z: _C) -> float: ... -def polar(__z: _C) -> tuple[float, float]: ... -def rect(__r: float, __phi: float) -> complex: ... -def sin(__z: _C) -> complex: ... -def sinh(__z: _C) -> complex: ... -def sqrt(__z: _C) -> complex: ... -def tan(__z: _C) -> complex: ... -def tanh(__z: _C) -> complex: ... diff --git a/mypy/typeshed/stdlib/@python2/cmd.pyi b/mypy/typeshed/stdlib/@python2/cmd.pyi deleted file mode 100644 index f6d818591a4e..000000000000 --- a/mypy/typeshed/stdlib/@python2/cmd.pyi +++ /dev/null @@ -1,39 +0,0 @@ -from typing import IO, Any, Callable - -class Cmd: - prompt: str - identchars: str - ruler: str - lastcmd: str - intro: Any | None - doc_leader: str - doc_header: str - misc_header: str - undoc_header: str - nohelp: str - use_rawinput: bool - stdin: IO[str] - stdout: IO[str] - cmdqueue: list[str] - completekey: str - def __init__(self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ...) -> None: ... - old_completer: Callable[[str, int], str | None] | None - def cmdloop(self, intro: Any | None = ...) -> None: ... - def precmd(self, line: str) -> str: ... - def postcmd(self, stop: bool, line: str) -> bool: ... - def preloop(self) -> None: ... - def postloop(self) -> None: ... - def parseline(self, line: str) -> tuple[str | None, str | None, str]: ... - def onecmd(self, line: str) -> bool: ... - def emptyline(self) -> bool: ... - def default(self, line: str) -> bool: ... - def completedefault(self, *ignored: Any) -> list[str]: ... - def completenames(self, text: str, *ignored: Any) -> list[str]: ... - completion_matches: list[str] | None - def complete(self, text: str, state: int) -> list[str] | None: ... - def get_names(self) -> list[str]: ... - # Only the first element of args matters. - def complete_help(self, *args: Any) -> list[str]: ... - def do_help(self, arg: str) -> bool | None: ... - def print_topics(self, header: str, cmds: list[str] | None, cmdlen: Any, maxcol: int) -> None: ... - def columnize(self, list: list[str] | None, displaywidth: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/code.pyi b/mypy/typeshed/stdlib/@python2/code.pyi deleted file mode 100644 index ae8dfc91a32b..000000000000 --- a/mypy/typeshed/stdlib/@python2/code.pyi +++ /dev/null @@ -1,22 +0,0 @@ -from types import CodeType -from typing import Any, Callable, Mapping - -class InteractiveInterpreter: - def __init__(self, locals: Mapping[str, Any] | None = ...) -> None: ... - def runsource(self, source: str, filename: str = ..., symbol: str = ...) -> bool: ... - def runcode(self, code: CodeType) -> None: ... - def showsyntaxerror(self, filename: str | None = ...) -> None: ... - def showtraceback(self) -> None: ... - def write(self, data: str) -> None: ... - -class InteractiveConsole(InteractiveInterpreter): - def __init__(self, locals: Mapping[str, Any] | None = ..., filename: str = ...) -> None: ... - def interact(self, banner: str | None = ...) -> None: ... - def push(self, line: str) -> bool: ... - def resetbuffer(self) -> None: ... - def raw_input(self, prompt: str = ...) -> str: ... - -def interact( - banner: str | None = ..., readfunc: Callable[[str], str] | None = ..., local: Mapping[str, Any] | None = ... -) -> None: ... -def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/mypy/typeshed/stdlib/@python2/codecs.pyi b/mypy/typeshed/stdlib/@python2/codecs.pyi deleted file mode 100644 index 9ed83567c148..000000000000 --- a/mypy/typeshed/stdlib/@python2/codecs.pyi +++ /dev/null @@ -1,262 +0,0 @@ -import types -from _typeshed import Self -from abc import abstractmethod -from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, Text, TextIO, overload -from typing_extensions import Literal - -# TODO: this only satisfies the most common interface, where -# bytes (py2 str) is the raw form and str (py2 unicode) is the cooked form. -# In the long run, both should become template parameters maybe? -# There *are* bytes->bytes and str->str encodings in the standard library. -# They are much more common in Python 2 than in Python 3. - -_Decoded = Text -_Encoded = bytes - -class _Encoder(Protocol): - def __call__(self, input: _Decoded, errors: str = ...) -> tuple[_Encoded, int]: ... # signature of Codec().encode - -class _Decoder(Protocol): - def __call__(self, input: _Encoded, errors: str = ...) -> tuple[_Decoded, int]: ... # signature of Codec().decode - -class _StreamReader(Protocol): - def __call__(self, stream: IO[_Encoded], errors: str = ...) -> StreamReader: ... - -class _StreamWriter(Protocol): - def __call__(self, stream: IO[_Encoded], errors: str = ...) -> StreamWriter: ... - -class _IncrementalEncoder(Protocol): - def __call__(self, errors: str = ...) -> IncrementalEncoder: ... - -class _IncrementalDecoder(Protocol): - def __call__(self, errors: str = ...) -> IncrementalDecoder: ... - -# The type ignore on `encode` and `decode` is to avoid issues with overlapping overloads, for more details, see #300 -# mypy and pytype disagree about where the type ignore can and cannot go, so alias the long type -_BytesToBytesEncodingT = Literal[ - "base64", - "base_64", - "base64_codec", - "bz2", - "bz2_codec", - "hex", - "hex_codec", - "quopri", - "quotedprintable", - "quoted_printable", - "quopri_codec", - "uu", - "uu_codec", - "zip", - "zlib", - "zlib_codec", -] - -@overload -def encode(obj: bytes, encoding: _BytesToBytesEncodingT, errors: str = ...) -> bytes: ... -@overload -def encode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = ...) -> str: ... -@overload -def encode(obj: _Decoded, encoding: str = ..., errors: str = ...) -> _Encoded: ... -@overload -def decode(obj: bytes, encoding: _BytesToBytesEncodingT, errors: str = ...) -> bytes: ... # type: ignore[misc] -@overload -def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = ...) -> Text: ... -@overload -def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ... -def lookup(__encoding: str) -> CodecInfo: ... -def utf_16_be_decode( - __data: _Encoded, __errors: str | None = ..., __final: bool = ... -) -> tuple[_Decoded, int]: ... # undocumented -def utf_16_be_encode(__str: _Decoded, __errors: str | None = ...) -> tuple[_Encoded, int]: ... # undocumented - -class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): - @property - def encode(self) -> _Encoder: ... - @property - def decode(self) -> _Decoder: ... - @property - def streamreader(self) -> _StreamReader: ... - @property - def streamwriter(self) -> _StreamWriter: ... - @property - def incrementalencoder(self) -> _IncrementalEncoder: ... - @property - def incrementaldecoder(self) -> _IncrementalDecoder: ... - name: str - def __new__( - cls: type[Self], - encode: _Encoder, - decode: _Decoder, - streamreader: _StreamReader | None = ..., - streamwriter: _StreamWriter | None = ..., - incrementalencoder: _IncrementalEncoder | None = ..., - incrementaldecoder: _IncrementalDecoder | None = ..., - name: str | None = ..., - *, - _is_text_encoding: bool | None = ..., - ) -> Self: ... - -def getencoder(encoding: str) -> _Encoder: ... -def getdecoder(encoding: str) -> _Decoder: ... -def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ... -def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ... -def getreader(encoding: str) -> _StreamReader: ... -def getwriter(encoding: str) -> _StreamWriter: ... -def register(__search_function: Callable[[str], CodecInfo | None]) -> None: ... -def open( - filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., buffering: int = ... -) -> StreamReaderWriter: ... -def EncodedFile(file: IO[_Encoded], data_encoding: str, file_encoding: str | None = ..., errors: str = ...) -> StreamRecoder: ... -def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ... -def iterdecode(iterator: Iterable[_Encoded], encoding: str, errors: str = ...) -> Generator[_Decoded, None, None]: ... - -BOM: bytes -BOM_BE: bytes -BOM_LE: bytes -BOM_UTF8: bytes -BOM_UTF16: bytes -BOM_UTF16_BE: bytes -BOM_UTF16_LE: bytes -BOM_UTF32: bytes -BOM_UTF32_BE: bytes -BOM_UTF32_LE: bytes - -# It is expected that different actions be taken depending on which of the -# three subclasses of `UnicodeError` is actually ...ed. However, the Union -# is still needed for at least one of the cases. -def register_error(__errors: str, __handler: Callable[[UnicodeError], tuple[str | bytes, int]]) -> None: ... -def lookup_error(__name: str) -> Callable[[UnicodeError], tuple[str | bytes, int]]: ... -def strict_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def replace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def ignore_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def xmlcharrefreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... -def backslashreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ... - -class Codec: - # These are sort of @abstractmethod but sort of not. - # The StreamReader and StreamWriter subclasses only implement one. - def encode(self, input: _Decoded, errors: str = ...) -> tuple[_Encoded, int]: ... - def decode(self, input: _Encoded, errors: str = ...) -> tuple[_Decoded, int]: ... - -class IncrementalEncoder: - errors: str - def __init__(self, errors: str = ...) -> None: ... - @abstractmethod - def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ... - def reset(self) -> None: ... - # documentation says int but str is needed for the subclass. - def getstate(self) -> int | _Decoded: ... - def setstate(self, state: int | _Decoded) -> None: ... - -class IncrementalDecoder: - errors: str - def __init__(self, errors: str = ...) -> None: ... - @abstractmethod - def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ... - def reset(self) -> None: ... - def getstate(self) -> tuple[_Encoded, int]: ... - def setstate(self, state: tuple[_Encoded, int]) -> None: ... - -# These are not documented but used in encodings/*.py implementations. -class BufferedIncrementalEncoder(IncrementalEncoder): - buffer: str - def __init__(self, errors: str = ...) -> None: ... - @abstractmethod - def _buffer_encode(self, input: _Decoded, errors: str, final: bool) -> _Encoded: ... - def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ... - -class BufferedIncrementalDecoder(IncrementalDecoder): - buffer: bytes - def __init__(self, errors: str = ...) -> None: ... - @abstractmethod - def _buffer_decode(self, input: _Encoded, errors: str, final: bool) -> tuple[_Decoded, int]: ... - def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ... - -# TODO: it is not possible to specify the requirement that all other -# attributes and methods are passed-through from the stream. -class StreamWriter(Codec): - errors: str - def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... - def write(self, object: _Decoded) -> None: ... - def writelines(self, list: Iterable[_Decoded]) -> None: ... - def reset(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... - def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... - -class StreamReader(Codec): - errors: str - def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... - def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _Decoded: ... - def readline(self, size: int | None = ..., keepends: bool = ...) -> _Decoded: ... - def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> list[_Decoded]: ... - def reset(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... - def __iter__(self) -> Iterator[_Decoded]: ... - def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... - -# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing -# and delegates attributes to the underlying binary stream with __getattr__. -class StreamReaderWriter(TextIO): - def __init__(self, stream: IO[_Encoded], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ... - def read(self, size: int = ...) -> _Decoded: ... - def readline(self, size: int | None = ...) -> _Decoded: ... - def readlines(self, sizehint: int | None = ...) -> list[_Decoded]: ... - def next(self) -> Text: ... - def __iter__(self: Self) -> Self: ... - # This actually returns None, but that's incompatible with the supertype - def write(self, data: _Decoded) -> int: ... - def writelines(self, list: Iterable[_Decoded]) -> None: ... - def reset(self) -> None: ... - # Same as write() - def seek(self, offset: int, whence: int = ...) -> int: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... - def __getattr__(self, name: str) -> Any: ... - # These methods don't actually exist directly, but they are needed to satisfy the TextIO - # interface. At runtime, they are delegated through __getattr__. - def close(self) -> None: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def readable(self) -> bool: ... - def truncate(self, size: int | None = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def writable(self) -> bool: ... - -class StreamRecoder(BinaryIO): - def __init__( - self, - stream: IO[_Encoded], - encode: _Encoder, - decode: _Decoder, - Reader: _StreamReader, - Writer: _StreamWriter, - errors: str = ..., - ) -> None: ... - def read(self, size: int = ...) -> bytes: ... - def readline(self, size: int | None = ...) -> bytes: ... - def readlines(self, sizehint: int | None = ...) -> list[bytes]: ... - def next(self) -> bytes: ... - def __iter__(self: Self) -> Self: ... - def write(self, data: bytes) -> int: ... - def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore[override] # it's supposed to return None - def reset(self) -> None: ... - def __getattr__(self, name: str) -> Any: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... - # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO - # interface. At runtime, they are delegated through __getattr__. - def seek(self, offset: int, whence: int = ...) -> int: ... - def close(self) -> None: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def readable(self) -> bool: ... - def truncate(self, size: int | None = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def writable(self) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/codeop.pyi b/mypy/typeshed/stdlib/@python2/codeop.pyi deleted file mode 100644 index 8ed5710c9891..000000000000 --- a/mypy/typeshed/stdlib/@python2/codeop.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from types import CodeType - -def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... - -class Compile: - flags: int - def __init__(self) -> None: ... - def __call__(self, source: str, filename: str, symbol: str) -> CodeType: ... - -class CommandCompiler: - compiler: Compile - def __init__(self) -> None: ... - def __call__(self, source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/mypy/typeshed/stdlib/@python2/collections.pyi b/mypy/typeshed/stdlib/@python2/collections.pyi deleted file mode 100644 index e7a2e7d1793f..000000000000 --- a/mypy/typeshed/stdlib/@python2/collections.pyi +++ /dev/null @@ -1,117 +0,0 @@ -from _typeshed import Self -from typing import ( - AbstractSet, - Any, - Callable as Callable, - Container as Container, - Generic, - Hashable as Hashable, - ItemsView as ItemsView, - Iterable as Iterable, - Iterator as Iterator, - KeysView as KeysView, - Mapping as Mapping, - MappingView as MappingView, - MutableMapping as MutableMapping, - MutableSequence as MutableSequence, - MutableSet as MutableSet, - Reversible, - Sequence as Sequence, - Sized as Sized, - TypeVar, - ValuesView as ValuesView, - overload, -) - -Set = AbstractSet - -_T = TypeVar("_T") -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") - -# namedtuple is special-cased in the type checker; the initializer is ignored. -def namedtuple( - typename: str | unicode, field_names: str | unicode | Iterable[str | unicode], verbose: bool = ..., rename: bool = ... -) -> type[tuple[Any, ...]]: ... - -class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): - def __init__(self, iterable: Iterable[_T] = ..., maxlen: int = ...) -> None: ... - @property - def maxlen(self) -> int | None: ... - def append(self, x: _T) -> None: ... - def appendleft(self, x: _T) -> None: ... - def clear(self) -> None: ... - def count(self, x: _T) -> int: ... - def extend(self, iterable: Iterable[_T]) -> None: ... - def extendleft(self, iterable: Iterable[_T]) -> None: ... - def pop(self) -> _T: ... - def popleft(self) -> _T: ... - def remove(self, value: _T) -> None: ... - def reverse(self) -> None: ... - def rotate(self, n: int = ...) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_T]: ... - def __hash__(self) -> int: ... - def __getitem__(self, i: int) -> _T: ... - def __setitem__(self, i: int, x: _T) -> None: ... - def __contains__(self, o: _T) -> bool: ... - def __reversed__(self) -> Iterator[_T]: ... - def __iadd__(self: Self, iterable: Iterable[_T]) -> Self: ... - -class Counter(dict[_T, int], Generic[_T]): - @overload - def __init__(self, **kwargs: int) -> None: ... - @overload - def __init__(self, mapping: Mapping[_T, int]) -> None: ... - @overload - def __init__(self, iterable: Iterable[_T]) -> None: ... - def copy(self: Self) -> Self: ... - def elements(self) -> Iterator[_T]: ... - def most_common(self, n: int | None = ...) -> list[tuple[_T, int]]: ... - @overload - def subtract(self, __mapping: Mapping[_T, int]) -> None: ... - @overload - def subtract(self, iterable: Iterable[_T]) -> None: ... - # The Iterable[Tuple[...]] argument type is not actually desirable - # (the tuples will be added as keys, breaking type safety) but - # it's included so that the signature is compatible with - # Dict.update. Not sure if we should use '# type: ignore' instead - # and omit the type from the union. - @overload - def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ... - @overload - def update(self, __m: Iterable[_T] | Iterable[tuple[_T, int]], **kwargs: int) -> None: ... - @overload - def update(self, **kwargs: int) -> None: ... - def __add__(self, other: Counter[_T]) -> Counter[_T]: ... - def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... - def __and__(self, other: Counter[_T]) -> Counter[_T]: ... - def __or__(self, other: Counter[_T]) -> Counter[_T]: ... - def __iadd__(self: Self, other: Counter[_T]) -> Self: ... - def __isub__(self: Self, other: Counter[_T]) -> Self: ... - def __iand__(self: Self, other: Counter[_T]) -> Self: ... - def __ior__(self: Self, other: Counter[_T]) -> Self: ... - -class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): - def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ... - def copy(self: Self) -> Self: ... - def __reversed__(self) -> Iterator[_KT]: ... - -class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]): - default_factory: Callable[[], _VT] - @overload - def __init__(self, **kwargs: _VT) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT] | None) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT] | None, map: Mapping[_KT, _VT]) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT] | None, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[tuple[_KT, _VT]]) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - def __missing__(self, key: _KT) -> _VT: ... - def copy(self: Self) -> Self: ... diff --git a/mypy/typeshed/stdlib/@python2/colorsys.pyi b/mypy/typeshed/stdlib/@python2/colorsys.pyi deleted file mode 100644 index 00c5f9d22cb1..000000000000 --- a/mypy/typeshed/stdlib/@python2/colorsys.pyi +++ /dev/null @@ -1,11 +0,0 @@ -def rgb_to_yiq(r: float, g: float, b: float) -> tuple[float, float, float]: ... -def yiq_to_rgb(y: float, i: float, q: float) -> tuple[float, float, float]: ... -def rgb_to_hls(r: float, g: float, b: float) -> tuple[float, float, float]: ... -def hls_to_rgb(h: float, l: float, s: float) -> tuple[float, float, float]: ... -def rgb_to_hsv(r: float, g: float, b: float) -> tuple[float, float, float]: ... -def hsv_to_rgb(h: float, s: float, v: float) -> tuple[float, float, float]: ... - -# TODO undocumented -ONE_SIXTH: float -ONE_THIRD: float -TWO_THIRD: float diff --git a/mypy/typeshed/stdlib/@python2/commands.pyi b/mypy/typeshed/stdlib/@python2/commands.pyi deleted file mode 100644 index 2c36033583ec..000000000000 --- a/mypy/typeshed/stdlib/@python2/commands.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from typing import AnyStr, Text, overload - -def getstatus(file: Text) -> str: ... -def getoutput(cmd: Text) -> str: ... -def getstatusoutput(cmd: Text) -> tuple[int, str]: ... -@overload -def mk2arg(head: bytes, x: bytes) -> bytes: ... -@overload -def mk2arg(head: Text, x: Text) -> Text: ... -def mkarg(x: AnyStr) -> AnyStr: ... diff --git a/mypy/typeshed/stdlib/@python2/compileall.pyi b/mypy/typeshed/stdlib/@python2/compileall.pyi deleted file mode 100644 index ef22929c4c19..000000000000 --- a/mypy/typeshed/stdlib/@python2/compileall.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from typing import Any, Pattern, Text - -# rx can be any object with a 'search' method; once we have Protocols we can change the type -def compile_dir( - dir: Text, maxlevels: int = ..., ddir: Text | None = ..., force: bool = ..., rx: Pattern[Any] | None = ..., quiet: int = ... -) -> int: ... -def compile_file( - fullname: Text, ddir: Text | None = ..., force: bool = ..., rx: Pattern[Any] | None = ..., quiet: int = ... -) -> int: ... -def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/contextlib.pyi b/mypy/typeshed/stdlib/@python2/contextlib.pyi deleted file mode 100644 index 4f39ba5dad5e..000000000000 --- a/mypy/typeshed/stdlib/@python2/contextlib.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from types import TracebackType -from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Protocol, TypeVar -from typing_extensions import ParamSpec - -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_F = TypeVar("_F", bound=Callable[..., Any]) -_P = ParamSpec("_P") - -_ExitFunc = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], bool] - -class GeneratorContextManager(ContextManager[_T_co]): - def __call__(self, func: _F) -> _F: ... - -def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, ContextManager[_T]]: ... -def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... - -class _SupportsClose(Protocol): - def close(self) -> None: ... - -_SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) - -class closing(ContextManager[_SupportsCloseT]): - def __init__(self, thing: _SupportsCloseT) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/cookielib.pyi b/mypy/typeshed/stdlib/@python2/cookielib.pyi deleted file mode 100644 index 0f813c128cc4..000000000000 --- a/mypy/typeshed/stdlib/@python2/cookielib.pyi +++ /dev/null @@ -1,142 +0,0 @@ -from typing import Any - -class Cookie: - version: Any - name: Any - value: Any - port: Any - port_specified: Any - domain: Any - domain_specified: Any - domain_initial_dot: Any - path: Any - path_specified: Any - secure: Any - expires: Any - discard: Any - comment: Any - comment_url: Any - rfc2109: Any - def __init__( - self, - version, - name, - value, - port, - port_specified, - domain, - domain_specified, - domain_initial_dot, - path, - path_specified, - secure, - expires, - discard, - comment, - comment_url, - rest, - rfc2109: bool = ..., - ): ... - def has_nonstandard_attr(self, name): ... - def get_nonstandard_attr(self, name, default: Any | None = ...): ... - def set_nonstandard_attr(self, name, value): ... - def is_expired(self, now: Any | None = ...): ... - -class CookiePolicy: - def set_ok(self, cookie, request): ... - def return_ok(self, cookie, request): ... - def domain_return_ok(self, domain, request): ... - def path_return_ok(self, path, request): ... - -class DefaultCookiePolicy(CookiePolicy): - DomainStrictNoDots: Any - DomainStrictNonDomain: Any - DomainRFC2965Match: Any - DomainLiberal: Any - DomainStrict: Any - netscape: Any - rfc2965: Any - rfc2109_as_netscape: Any - hide_cookie2: Any - strict_domain: Any - strict_rfc2965_unverifiable: Any - strict_ns_unverifiable: Any - strict_ns_domain: Any - strict_ns_set_initial_dollar: Any - strict_ns_set_path: Any - def __init__( - self, - blocked_domains: Any | None = ..., - allowed_domains: Any | None = ..., - netscape: bool = ..., - rfc2965: bool = ..., - rfc2109_as_netscape: Any | None = ..., - hide_cookie2: bool = ..., - strict_domain: bool = ..., - strict_rfc2965_unverifiable: bool = ..., - strict_ns_unverifiable: bool = ..., - strict_ns_domain=..., - strict_ns_set_initial_dollar: bool = ..., - strict_ns_set_path: bool = ..., - ): ... - def blocked_domains(self): ... - def set_blocked_domains(self, blocked_domains): ... - def is_blocked(self, domain): ... - def allowed_domains(self): ... - def set_allowed_domains(self, allowed_domains): ... - def is_not_allowed(self, domain): ... - def set_ok(self, cookie, request): ... - def set_ok_version(self, cookie, request): ... - def set_ok_verifiability(self, cookie, request): ... - def set_ok_name(self, cookie, request): ... - def set_ok_path(self, cookie, request): ... - def set_ok_domain(self, cookie, request): ... - def set_ok_port(self, cookie, request): ... - def return_ok(self, cookie, request): ... - def return_ok_version(self, cookie, request): ... - def return_ok_verifiability(self, cookie, request): ... - def return_ok_secure(self, cookie, request): ... - def return_ok_expires(self, cookie, request): ... - def return_ok_port(self, cookie, request): ... - def return_ok_domain(self, cookie, request): ... - def domain_return_ok(self, domain, request): ... - def path_return_ok(self, path, request): ... - -class Absent: ... - -class CookieJar: - non_word_re: Any - quote_re: Any - strict_domain_re: Any - domain_re: Any - dots_re: Any - magic_re: Any - def __init__(self, policy: Any | None = ...): ... - def set_policy(self, policy): ... - def add_cookie_header(self, request): ... - def make_cookies(self, response, request): ... - def set_cookie_if_ok(self, cookie, request): ... - def set_cookie(self, cookie): ... - def extract_cookies(self, response, request): ... - def clear(self, domain: Any | None = ..., path: Any | None = ..., name: Any | None = ...): ... - def clear_session_cookies(self): ... - def clear_expired_cookies(self): ... - def __iter__(self): ... - def __len__(self): ... - -class LoadError(IOError): ... - -class FileCookieJar(CookieJar): - filename: Any - delayload: Any - def __init__(self, filename: Any | None = ..., delayload: bool = ..., policy: Any | None = ...): ... - def save(self, filename: Any | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... - def load(self, filename: Any | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... - def revert(self, filename: Any | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... - -class LWPCookieJar(FileCookieJar): - def as_lwp_str(self, ignore_discard: bool = ..., ignore_expires: bool = ...) -> str: ... # undocumented - -MozillaCookieJar = FileCookieJar - -def lwp_cookie_str(cookie: Cookie) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/copy.pyi b/mypy/typeshed/stdlib/@python2/copy.pyi deleted file mode 100644 index a5f9420e3811..000000000000 --- a/mypy/typeshed/stdlib/@python2/copy.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from typing import Any, TypeVar - -_T = TypeVar("_T") - -# None in CPython but non-None in Jython -PyStringMap: Any - -# Note: memo and _nil are internal kwargs. -def deepcopy(x: _T, memo: dict[int, Any] | None = ..., _nil: Any = ...) -> _T: ... -def copy(x: _T) -> _T: ... - -class Error(Exception): ... - -error = Error diff --git a/mypy/typeshed/stdlib/@python2/copy_reg.pyi b/mypy/typeshed/stdlib/@python2/copy_reg.pyi deleted file mode 100644 index 2fccfcbf2208..000000000000 --- a/mypy/typeshed/stdlib/@python2/copy_reg.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Any, Callable, Hashable, SupportsInt, TypeVar, Union - -_TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Any | None]] - -__all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"] - -def pickle( - ob_type: _TypeT, - pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], - constructor_ob: Callable[[_Reduce[_TypeT]], _TypeT] | None = ..., -) -> None: ... -def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... -def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ... -def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ... -def clear_extension_cache() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/copyreg.pyi b/mypy/typeshed/stdlib/@python2/copyreg.pyi deleted file mode 100644 index 2fccfcbf2208..000000000000 --- a/mypy/typeshed/stdlib/@python2/copyreg.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Any, Callable, Hashable, SupportsInt, TypeVar, Union - -_TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Any | None]] - -__all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"] - -def pickle( - ob_type: _TypeT, - pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], - constructor_ob: Callable[[_Reduce[_TypeT]], _TypeT] | None = ..., -) -> None: ... -def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... -def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ... -def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ... -def clear_extension_cache() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/crypt.pyi b/mypy/typeshed/stdlib/@python2/crypt.pyi deleted file mode 100644 index a7c0cb1e8fbc..000000000000 --- a/mypy/typeshed/stdlib/@python2/crypt.pyi +++ /dev/null @@ -1,4 +0,0 @@ -import sys - -if sys.platform != "win32": - def crypt(word: str, salt: str) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/csv.pyi b/mypy/typeshed/stdlib/@python2/csv.pyi deleted file mode 100644 index a52db42291af..000000000000 --- a/mypy/typeshed/stdlib/@python2/csv.pyi +++ /dev/null @@ -1,90 +0,0 @@ -from _csv import ( - QUOTE_ALL as QUOTE_ALL, - QUOTE_MINIMAL as QUOTE_MINIMAL, - QUOTE_NONE as QUOTE_NONE, - QUOTE_NONNUMERIC as QUOTE_NONNUMERIC, - Dialect as Dialect, - Error as Error, - _DialectLike, - _reader, - _writer, - field_size_limit as field_size_limit, - get_dialect as get_dialect, - list_dialects as list_dialects, - reader as reader, - register_dialect as register_dialect, - unregister_dialect as unregister_dialect, - writer as writer, -) -from builtins import dict as _DictReadMapping -from typing import Any, Generic, Iterable, Iterator, Mapping, Sequence, Text, TypeVar, overload - -_T = TypeVar("_T") - -class excel(Dialect): - delimiter: str - quotechar: str - doublequote: bool - skipinitialspace: bool - lineterminator: str - quoting: int - -class excel_tab(excel): - delimiter: str - -class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): - fieldnames: Sequence[_T] | None - restkey: str | None - restval: str | None - reader: _reader - dialect: _DialectLike - line_num: int - @overload - def __init__( - self, - f: Iterable[Text], - fieldnames: Sequence[_T], - restkey: str | None = ..., - restval: str | None = ..., - dialect: _DialectLike = ..., - *args: Any, - **kwds: Any, - ) -> None: ... - @overload - def __init__( - self: DictReader[str], - f: Iterable[Text], - fieldnames: Sequence[str] | None = ..., - restkey: str | None = ..., - restval: str | None = ..., - dialect: _DialectLike = ..., - *args: Any, - **kwds: Any, - ) -> None: ... - def __iter__(self) -> DictReader[_T]: ... - def next(self) -> _DictReadMapping[_T, str]: ... - -class DictWriter(Generic[_T]): - fieldnames: Sequence[_T] - restval: Any | None - extrasaction: str - writer: _writer - def __init__( - self, - f: Any, - fieldnames: Sequence[_T], - restval: Any | None = ..., - extrasaction: str = ..., - dialect: _DialectLike = ..., - *args: Any, - **kwds: Any, - ) -> None: ... - def writeheader(self) -> None: ... - def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ... - def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ... - -class Sniffer(object): - preferred: list[str] - def __init__(self) -> None: ... - def sniff(self, sample: str, delimiters: str | None = ...) -> type[Dialect]: ... - def has_header(self, sample: str) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/ctypes/__init__.pyi b/mypy/typeshed/stdlib/@python2/ctypes/__init__.pyi deleted file mode 100644 index 18d5cbc77e94..000000000000 --- a/mypy/typeshed/stdlib/@python2/ctypes/__init__.pyi +++ /dev/null @@ -1,290 +0,0 @@ -import sys -from _typeshed import Self -from array import array -from typing import ( - Any, - Callable, - ClassVar, - Generic, - Iterable, - Iterator, - Mapping, - Sequence, - Text, - TypeVar, - Union as _UnionT, - overload, -) - -_T = TypeVar("_T") -_DLLT = TypeVar("_DLLT", bound=CDLL) -_CT = TypeVar("_CT", bound=_CData) - -RTLD_GLOBAL: int -RTLD_LOCAL: int -DEFAULT_MODE: int - -class CDLL(object): - _func_flags_: ClassVar[int] = ... - _func_restype_: ClassVar[_CData] = ... - _name: str = ... - _handle: int = ... - _FuncPtr: type[_FuncPointer] = ... - def __init__( - self, name: str | None, mode: int = ..., handle: int | None = ..., use_errno: bool = ..., use_last_error: bool = ... - ) -> None: ... - def __getattr__(self, name: str) -> _NamedFuncPointer: ... - def __getitem__(self, name: str) -> _NamedFuncPointer: ... - -if sys.platform == "win32": - class OleDLL(CDLL): ... - class WinDLL(CDLL): ... - -class PyDLL(CDLL): ... - -class LibraryLoader(Generic[_DLLT]): - def __init__(self, dlltype: type[_DLLT]) -> None: ... - def __getattr__(self, name: str) -> _DLLT: ... - def __getitem__(self, name: str) -> _DLLT: ... - def LoadLibrary(self, name: str) -> _DLLT: ... - -cdll: LibraryLoader[CDLL] -if sys.platform == "win32": - windll: LibraryLoader[WinDLL] - oledll: LibraryLoader[OleDLL] -pydll: LibraryLoader[PyDLL] -pythonapi: PyDLL - -# Anything that implements the read-write buffer interface. -# The buffer interface is defined purely on the C level, so we cannot define a normal Protocol -# for it. Instead we have to list the most common stdlib buffer classes in a Union. -_WritableBuffer = bytearray | memoryview | array[Any] | _CData -# Same as _WritableBuffer, but also includes read-only buffer types (like bytes). -_ReadOnlyBuffer = _WritableBuffer | bytes - -class _CDataMeta(type): - # By default mypy complains about the following two methods, because strictly speaking cls - # might not be a Type[_CT]. However this can never actually happen, because the only class that - # uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here. - def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] - def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] - -class _CData(metaclass=_CDataMeta): - _b_base: int = ... - _b_needsfree_: bool = ... - _objects: Mapping[Any, int] | None = ... - @classmethod - def from_buffer(cls: type[Self], source: _WritableBuffer, offset: int = ...) -> Self: ... - @classmethod - def from_buffer_copy(cls: type[Self], source: _ReadOnlyBuffer, offset: int = ...) -> Self: ... - @classmethod - def from_address(cls: type[Self], address: int) -> Self: ... - @classmethod - def from_param(cls: type[_CT], obj: Any) -> _CT | _CArgObject: ... - @classmethod - def in_dll(cls: type[Self], library: CDLL, name: str) -> Self: ... - -class _CanCastTo(_CData): ... -class _PointerLike(_CanCastTo): ... - -_ECT = Callable[[type[_CData] | None, _FuncPointer, tuple[_CData, ...]], _CData] -_PF = _UnionT[tuple[int], tuple[int, str], tuple[int, str, Any]] - -class _FuncPointer(_PointerLike, _CData): - restype: type[_CData] | Callable[[int], Any] | None = ... - argtypes: Sequence[type[_CData]] = ... - errcheck: _ECT = ... - @overload - def __init__(self, address: int) -> None: ... - @overload - def __init__(self, callable: Callable[..., Any]) -> None: ... - @overload - def __init__(self, func_spec: tuple[_UnionT[str, int], CDLL], paramflags: tuple[_PF, ...] = ...) -> None: ... - @overload - def __init__(self, vtlb_index: int, name: str, paramflags: tuple[_PF, ...] = ..., iid: pointer[c_int] = ...) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - -class _NamedFuncPointer(_FuncPointer): - __name__: str - -class ArgumentError(Exception): ... - -def CFUNCTYPE( - restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ... -) -> type[_FuncPointer]: ... - -if sys.platform == "win32": - def WINFUNCTYPE( - restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ... - ) -> type[_FuncPointer]: ... - -def PYFUNCTYPE(restype: type[_CData] | None, *argtypes: type[_CData]) -> type[_FuncPointer]: ... - -class _CArgObject: ... - -# Any type that can be implicitly converted to c_void_p when passed as a C function argument. -# (bytes is not included here, see below.) -_CVoidPLike = _PointerLike | Array[Any] | _CArgObject | int -# Same as above, but including types known to be read-only (i. e. bytes). -# This distinction is not strictly necessary (ctypes doesn't differentiate between const -# and non-const pointers), but it catches errors like memmove(b'foo', buf, 4) -# when memmove(buf, b'foo', 4) was intended. -_CVoidConstPLike = _CVoidPLike | bytes - -def addressof(obj: _CData) -> int: ... -def alignment(obj_or_type: _CData | type[_CData]) -> int: ... -def byref(obj: _CData, offset: int = ...) -> _CArgObject: ... - -_CastT = TypeVar("_CastT", bound=_CanCastTo) - -def cast(obj: _CData | _CArgObject | int, typ: type[_CastT]) -> _CastT: ... -def create_string_buffer(init: int | bytes, size: int | None = ...) -> Array[c_char]: ... - -c_buffer = create_string_buffer - -def create_unicode_buffer(init: int | Text, size: int | None = ...) -> Array[c_wchar]: ... - -if sys.platform == "win32": - def DllCanUnloadNow() -> int: ... - def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented - def FormatError(code: int = ...) -> str: ... - def GetLastError() -> int: ... - -def get_errno() -> int: ... - -if sys.platform == "win32": - def get_last_error() -> int: ... - -def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> None: ... -def memset(dst: _CVoidPLike, c: int, count: int) -> None: ... -def POINTER(type: type[_CT]) -> type[pointer[_CT]]: ... - -# The real ctypes.pointer is a function, not a class. The stub version of pointer behaves like -# ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer, -# it can be instantiated directly (to mimic the behavior of the real pointer function). -class pointer(Generic[_CT], _PointerLike, _CData): - _type_: type[_CT] = ... - contents: _CT = ... - def __init__(self, arg: _CT = ...) -> None: ... - @overload - def __getitem__(self, i: int) -> _CT: ... - @overload - def __getitem__(self, s: slice) -> list[_CT]: ... - @overload - def __setitem__(self, i: int, o: _CT) -> None: ... - @overload - def __setitem__(self, s: slice, o: Iterable[_CT]) -> None: ... - -def resize(obj: _CData, size: int) -> None: ... -def set_conversion_mode(encoding: str, errors: str) -> tuple[str, str]: ... -def set_errno(value: int) -> int: ... - -if sys.platform == "win32": - def set_last_error(value: int) -> int: ... - -def sizeof(obj_or_type: _CData | type[_CData]) -> int: ... -def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ... - -if sys.platform == "win32": - def WinError(code: int | None = ..., descr: str | None = ...) -> OSError: ... - -def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ... - -class _SimpleCData(Generic[_T], _CData): - value: _T = ... - def __init__(self, value: _T = ...) -> None: ... - -class c_byte(_SimpleCData[int]): ... - -class c_char(_SimpleCData[bytes]): - def __init__(self, value: int | bytes = ...) -> None: ... - -class c_char_p(_PointerLike, _SimpleCData[bytes | None]): - def __init__(self, value: int | bytes | None = ...) -> None: ... - -class c_double(_SimpleCData[float]): ... -class c_longdouble(_SimpleCData[float]): ... -class c_float(_SimpleCData[float]): ... -class c_int(_SimpleCData[int]): ... -class c_int8(_SimpleCData[int]): ... -class c_int16(_SimpleCData[int]): ... -class c_int32(_SimpleCData[int]): ... -class c_int64(_SimpleCData[int]): ... -class c_long(_SimpleCData[int]): ... -class c_longlong(_SimpleCData[int]): ... -class c_short(_SimpleCData[int]): ... -class c_size_t(_SimpleCData[int]): ... -class c_ssize_t(_SimpleCData[int]): ... -class c_ubyte(_SimpleCData[int]): ... -class c_uint(_SimpleCData[int]): ... -class c_uint8(_SimpleCData[int]): ... -class c_uint16(_SimpleCData[int]): ... -class c_uint32(_SimpleCData[int]): ... -class c_uint64(_SimpleCData[int]): ... -class c_ulong(_SimpleCData[int]): ... -class c_ulonglong(_SimpleCData[int]): ... -class c_ushort(_SimpleCData[int]): ... -class c_void_p(_PointerLike, _SimpleCData[int | None]): ... -class c_wchar(_SimpleCData[Text]): ... - -class c_wchar_p(_PointerLike, _SimpleCData[Text | None]): - def __init__(self, value: int | Text | None = ...) -> None: ... - -class c_bool(_SimpleCData[bool]): - def __init__(self, value: bool = ...) -> None: ... - -if sys.platform == "win32": - class HRESULT(_SimpleCData[int]): ... # TODO undocumented - -class py_object(_CanCastTo, _SimpleCData[_T]): ... - -class _CField: - offset: int = ... - size: int = ... - -class _StructUnionMeta(_CDataMeta): - _fields_: Sequence[_UnionT[tuple[str, type[_CData]], tuple[str, type[_CData], int]]] = ... - _pack_: int = ... - _anonymous_: Sequence[str] = ... - def __getattr__(self, name: str) -> _CField: ... - -class _StructUnionBase(_CData, metaclass=_StructUnionMeta): - def __init__(self, *args: Any, **kw: Any) -> None: ... - def __getattr__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - -class Union(_StructUnionBase): ... -class Structure(_StructUnionBase): ... -class BigEndianStructure(Structure): ... -class LittleEndianStructure(Structure): ... - -class Array(Generic[_CT], _CData): - _length_: int = ... - _type_: type[_CT] = ... - raw: bytes = ... # Note: only available if _CT == c_char - value: Any = ... # Note: bytes if _CT == c_char, Text if _CT == c_wchar, unavailable otherwise - # TODO These methods cannot be annotated correctly at the moment. - # All of these "Any"s stand for the array's element type, but it's not possible to use _CT - # here, because of a special feature of ctypes. - # By default, when accessing an element of an Array[_CT], the returned object has type _CT. - # However, when _CT is a "simple type" like c_int, ctypes automatically "unboxes" the object - # and converts it to the corresponding Python primitive. For example, when accessing an element - # of an Array[c_int], a Python int object is returned, not a c_int. - # This behavior does *not* apply to subclasses of "simple types". - # If MyInt is a subclass of c_int, then accessing an element of an Array[MyInt] returns - # a MyInt, not an int. - # This special behavior is not easy to model in a stub, so for now all places where - # the array element type would belong are annotated with Any instead. - def __init__(self, *args: Any) -> None: ... - @overload - def __getitem__(self, i: int) -> Any: ... - @overload - def __getitem__(self, s: slice) -> list[Any]: ... - @overload - def __setitem__(self, i: int, o: Any) -> None: ... - @overload - def __setitem__(self, s: slice, o: Iterable[Any]) -> None: ... - def __iter__(self) -> Iterator[Any]: ... - # Can't inherit from Sized because the metaclass conflict between - # Sized and _CData prevents using _CDataMeta. - def __len__(self) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/ctypes/util.pyi b/mypy/typeshed/stdlib/@python2/ctypes/util.pyi deleted file mode 100644 index c0274f5e539b..000000000000 --- a/mypy/typeshed/stdlib/@python2/ctypes/util.pyi +++ /dev/null @@ -1,6 +0,0 @@ -import sys - -def find_library(name: str) -> str | None: ... - -if sys.platform == "win32": - def find_msvcrt() -> str | None: ... diff --git a/mypy/typeshed/stdlib/@python2/ctypes/wintypes.pyi b/mypy/typeshed/stdlib/@python2/ctypes/wintypes.pyi deleted file mode 100644 index c178a9bdf936..000000000000 --- a/mypy/typeshed/stdlib/@python2/ctypes/wintypes.pyi +++ /dev/null @@ -1,234 +0,0 @@ -from ctypes import ( - Array, - Structure, - _SimpleCData, - c_byte, - c_char, - c_char_p, - c_double, - c_float, - c_int, - c_long, - c_longlong, - c_short, - c_uint, - c_ulong, - c_ulonglong, - c_ushort, - c_void_p, - c_wchar, - c_wchar_p, - pointer, -) - -BYTE = c_byte -WORD = c_ushort -DWORD = c_ulong -CHAR = c_char -WCHAR = c_wchar -UINT = c_uint -INT = c_int -DOUBLE = c_double -FLOAT = c_float -BOOLEAN = BYTE -BOOL = c_long - -class VARIANT_BOOL(_SimpleCData[bool]): ... - -ULONG = c_ulong -LONG = c_long -USHORT = c_ushort -SHORT = c_short -LARGE_INTEGER = c_longlong -_LARGE_INTEGER = c_longlong -ULARGE_INTEGER = c_ulonglong -_ULARGE_INTEGER = c_ulonglong - -OLESTR = c_wchar_p -LPOLESTR = c_wchar_p -LPCOLESTR = c_wchar_p -LPWSTR = c_wchar_p -LPCWSTR = c_wchar_p -LPSTR = c_char_p -LPCSTR = c_char_p -LPVOID = c_void_p -LPCVOID = c_void_p - -# These two types are pointer-sized unsigned and signed ints, respectively. -# At runtime, they are either c_[u]long or c_[u]longlong, depending on the host's pointer size -# (they are not really separate classes). -class WPARAM(_SimpleCData[int]): ... -class LPARAM(_SimpleCData[int]): ... - -ATOM = WORD -LANGID = WORD -COLORREF = DWORD -LGRPID = DWORD -LCTYPE = DWORD -LCID = DWORD - -HANDLE = c_void_p -HACCEL = HANDLE -HBITMAP = HANDLE -HBRUSH = HANDLE -HCOLORSPACE = HANDLE -HDC = HANDLE -HDESK = HANDLE -HDWP = HANDLE -HENHMETAFILE = HANDLE -HFONT = HANDLE -HGDIOBJ = HANDLE -HGLOBAL = HANDLE -HHOOK = HANDLE -HICON = HANDLE -HINSTANCE = HANDLE -HKEY = HANDLE -HKL = HANDLE -HLOCAL = HANDLE -HMENU = HANDLE -HMETAFILE = HANDLE -HMODULE = HANDLE -HMONITOR = HANDLE -HPALETTE = HANDLE -HPEN = HANDLE -HRGN = HANDLE -HRSRC = HANDLE -HSTR = HANDLE -HTASK = HANDLE -HWINSTA = HANDLE -HWND = HANDLE -SC_HANDLE = HANDLE -SERVICE_STATUS_HANDLE = HANDLE - -class RECT(Structure): - left: LONG - top: LONG - right: LONG - bottom: LONG - -RECTL = RECT -_RECTL = RECT -tagRECT = RECT - -class _SMALL_RECT(Structure): - Left: SHORT - Top: SHORT - Right: SHORT - Bottom: SHORT - -SMALL_RECT = _SMALL_RECT - -class _COORD(Structure): - X: SHORT - Y: SHORT - -class POINT(Structure): - x: LONG - y: LONG - -POINTL = POINT -_POINTL = POINT -tagPOINT = POINT - -class SIZE(Structure): - cx: LONG - cy: LONG - -SIZEL = SIZE -tagSIZE = SIZE - -def RGB(red: int, green: int, blue: int) -> int: ... - -class FILETIME(Structure): - dwLowDateTime: DWORD - dwHighDateTime: DWORD - -_FILETIME = FILETIME - -class MSG(Structure): - hWnd: HWND - message: UINT - wParam: WPARAM - lParam: LPARAM - time: DWORD - pt: POINT - -tagMSG = MSG -MAX_PATH: int - -class WIN32_FIND_DATAA(Structure): - dwFileAttributes: DWORD - ftCreationTime: FILETIME - ftLastAccessTime: FILETIME - ftLastWriteTime: FILETIME - nFileSizeHigh: DWORD - nFileSizeLow: DWORD - dwReserved0: DWORD - dwReserved1: DWORD - cFileName: Array[CHAR] - cAlternateFileName: Array[CHAR] - -class WIN32_FIND_DATAW(Structure): - dwFileAttributes: DWORD - ftCreationTime: FILETIME - ftLastAccessTime: FILETIME - ftLastWriteTime: FILETIME - nFileSizeHigh: DWORD - nFileSizeLow: DWORD - dwReserved0: DWORD - dwReserved1: DWORD - cFileName: Array[WCHAR] - cAlternateFileName: Array[WCHAR] - -# These pointer type definitions use pointer[...] instead of POINTER(...), to allow them -# to be used in type annotations. -PBOOL = pointer[BOOL] -LPBOOL = pointer[BOOL] -PBOOLEAN = pointer[BOOLEAN] -PBYTE = pointer[BYTE] -LPBYTE = pointer[BYTE] -PCHAR = pointer[CHAR] -LPCOLORREF = pointer[COLORREF] -PDWORD = pointer[DWORD] -LPDWORD = pointer[DWORD] -PFILETIME = pointer[FILETIME] -LPFILETIME = pointer[FILETIME] -PFLOAT = pointer[FLOAT] -PHANDLE = pointer[HANDLE] -LPHANDLE = pointer[HANDLE] -PHKEY = pointer[HKEY] -LPHKL = pointer[HKL] -PINT = pointer[INT] -LPINT = pointer[INT] -PLARGE_INTEGER = pointer[LARGE_INTEGER] -PLCID = pointer[LCID] -PLONG = pointer[LONG] -LPLONG = pointer[LONG] -PMSG = pointer[MSG] -LPMSG = pointer[MSG] -PPOINT = pointer[POINT] -LPPOINT = pointer[POINT] -PPOINTL = pointer[POINTL] -PRECT = pointer[RECT] -LPRECT = pointer[RECT] -PRECTL = pointer[RECTL] -LPRECTL = pointer[RECTL] -LPSC_HANDLE = pointer[SC_HANDLE] -PSHORT = pointer[SHORT] -PSIZE = pointer[SIZE] -LPSIZE = pointer[SIZE] -PSIZEL = pointer[SIZEL] -LPSIZEL = pointer[SIZEL] -PSMALL_RECT = pointer[SMALL_RECT] -PUINT = pointer[UINT] -LPUINT = pointer[UINT] -PULARGE_INTEGER = pointer[ULARGE_INTEGER] -PULONG = pointer[ULONG] -PUSHORT = pointer[USHORT] -PWCHAR = pointer[WCHAR] -PWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA] -LPWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA] -PWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW] -LPWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW] -PWORD = pointer[WORD] -LPWORD = pointer[WORD] diff --git a/mypy/typeshed/stdlib/@python2/curses/__init__.pyi b/mypy/typeshed/stdlib/@python2/curses/__init__.pyi deleted file mode 100644 index d5581ce11c22..000000000000 --- a/mypy/typeshed/stdlib/@python2/curses/__init__.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from _curses import * -from _curses import _CursesWindow as _CursesWindow -from typing import Any, Callable, TypeVar - -_T = TypeVar("_T") - -# available after calling `curses.initscr()` -LINES: int -COLS: int - -# available after calling `curses.start_color()` -COLORS: int -COLOR_PAIRS: int - -def wrapper(__func: Callable[..., _T], *arg: Any, **kwds: Any) -> _T: ... diff --git a/mypy/typeshed/stdlib/@python2/curses/ascii.pyi b/mypy/typeshed/stdlib/@python2/curses/ascii.pyi deleted file mode 100644 index 66efbe36a7df..000000000000 --- a/mypy/typeshed/stdlib/@python2/curses/ascii.pyi +++ /dev/null @@ -1,62 +0,0 @@ -from typing import TypeVar - -_CharT = TypeVar("_CharT", str, int) - -NUL: int -SOH: int -STX: int -ETX: int -EOT: int -ENQ: int -ACK: int -BEL: int -BS: int -TAB: int -HT: int -LF: int -NL: int -VT: int -FF: int -CR: int -SO: int -SI: int -DLE: int -DC1: int -DC2: int -DC3: int -DC4: int -NAK: int -SYN: int -ETB: int -CAN: int -EM: int -SUB: int -ESC: int -FS: int -GS: int -RS: int -US: int -SP: int -DEL: int - -controlnames: list[int] - -def isalnum(c: str | int) -> bool: ... -def isalpha(c: str | int) -> bool: ... -def isascii(c: str | int) -> bool: ... -def isblank(c: str | int) -> bool: ... -def iscntrl(c: str | int) -> bool: ... -def isdigit(c: str | int) -> bool: ... -def isgraph(c: str | int) -> bool: ... -def islower(c: str | int) -> bool: ... -def isprint(c: str | int) -> bool: ... -def ispunct(c: str | int) -> bool: ... -def isspace(c: str | int) -> bool: ... -def isupper(c: str | int) -> bool: ... -def isxdigit(c: str | int) -> bool: ... -def isctrl(c: str | int) -> bool: ... -def ismeta(c: str | int) -> bool: ... -def ascii(c: _CharT) -> _CharT: ... -def ctrl(c: _CharT) -> _CharT: ... -def alt(c: _CharT) -> _CharT: ... -def unctrl(c: str | int) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/curses/panel.pyi b/mypy/typeshed/stdlib/@python2/curses/panel.pyi deleted file mode 100644 index 138e4a9f727e..000000000000 --- a/mypy/typeshed/stdlib/@python2/curses/panel.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from _curses import _CursesWindow - -class _Curses_Panel: # type is (note the space in the class name) - def above(self) -> _Curses_Panel: ... - def below(self) -> _Curses_Panel: ... - def bottom(self) -> None: ... - def hidden(self) -> bool: ... - def hide(self) -> None: ... - def move(self, y: int, x: int) -> None: ... - def replace(self, win: _CursesWindow) -> None: ... - def set_userptr(self, obj: object) -> None: ... - def show(self) -> None: ... - def top(self) -> None: ... - def userptr(self) -> object: ... - def window(self) -> _CursesWindow: ... - -def bottom_panel() -> _Curses_Panel: ... -def new_panel(__win: _CursesWindow) -> _Curses_Panel: ... -def top_panel() -> _Curses_Panel: ... -def update_panels() -> _Curses_Panel: ... diff --git a/mypy/typeshed/stdlib/@python2/curses/textpad.pyi b/mypy/typeshed/stdlib/@python2/curses/textpad.pyi deleted file mode 100644 index 578a579fda38..000000000000 --- a/mypy/typeshed/stdlib/@python2/curses/textpad.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from _curses import _CursesWindow -from typing import Callable - -def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... - -class Textbox: - stripspaces: bool - def __init__(self, win: _CursesWindow, insert_mode: bool = ...) -> None: ... - def edit(self, validate: Callable[[int], int] | None = ...) -> str: ... - def do_command(self, ch: str | int) -> None: ... - def gather(self) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/datetime.pyi b/mypy/typeshed/stdlib/@python2/datetime.pyi deleted file mode 100644 index 62791461c885..000000000000 --- a/mypy/typeshed/stdlib/@python2/datetime.pyi +++ /dev/null @@ -1,230 +0,0 @@ -from _typeshed import Self -from time import struct_time -from typing import AnyStr, ClassVar, SupportsAbs, overload - -_Text = str | unicode - -MINYEAR: int -MAXYEAR: int - -class tzinfo: - def tzname(self, dt: datetime | None) -> str | None: ... - def utcoffset(self, dt: datetime | None) -> timedelta | None: ... - def dst(self, dt: datetime | None) -> timedelta | None: ... - def fromutc(self, dt: datetime) -> datetime: ... - -_tzinfo = tzinfo - -class date: - min: ClassVar[date] - max: ClassVar[date] - resolution: ClassVar[timedelta] - def __new__(cls: type[Self], year: int, month: int, day: int) -> Self: ... - @classmethod - def fromtimestamp(cls: type[Self], __timestamp: float) -> Self: ... - @classmethod - def today(cls: type[Self]) -> Self: ... - @classmethod - def fromordinal(cls: type[Self], n: int) -> Self: ... - @property - def year(self) -> int: ... - @property - def month(self) -> int: ... - @property - def day(self) -> int: ... - def ctime(self) -> str: ... - def strftime(self, fmt: _Text) -> str: ... - def __format__(self, fmt: AnyStr) -> AnyStr: ... - def isoformat(self) -> str: ... - def timetuple(self) -> struct_time: ... - def toordinal(self) -> int: ... - def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ... - def __le__(self, other: date) -> bool: ... - def __lt__(self, other: date) -> bool: ... - def __ge__(self, other: date) -> bool: ... - def __gt__(self, other: date) -> bool: ... - def __add__(self, other: timedelta) -> date: ... - def __radd__(self, other: timedelta) -> date: ... - @overload - def __sub__(self, other: timedelta) -> date: ... - @overload - def __sub__(self, other: date) -> timedelta: ... - def __hash__(self) -> int: ... - def weekday(self) -> int: ... - def isoweekday(self) -> int: ... - def isocalendar(self) -> tuple[int, int, int]: ... - -class time: - min: ClassVar[time] - max: ClassVar[time] - resolution: ClassVar[timedelta] - def __new__( - cls: type[Self], - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: _tzinfo | None = ..., - ) -> Self: ... - @property - def hour(self) -> int: ... - @property - def minute(self) -> int: ... - @property - def second(self) -> int: ... - @property - def microsecond(self) -> int: ... - @property - def tzinfo(self) -> _tzinfo | None: ... - def __le__(self, other: time) -> bool: ... - def __lt__(self, other: time) -> bool: ... - def __ge__(self, other: time) -> bool: ... - def __gt__(self, other: time) -> bool: ... - def __hash__(self) -> int: ... - def isoformat(self) -> str: ... - def strftime(self, fmt: _Text) -> str: ... - def __format__(self, fmt: AnyStr) -> AnyStr: ... - def utcoffset(self) -> timedelta | None: ... - def tzname(self) -> str | None: ... - def dst(self) -> timedelta | None: ... - def replace( - self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: _tzinfo | None = ... - ) -> time: ... - -_date = date -_time = time - -class timedelta(SupportsAbs[timedelta]): - min: ClassVar[timedelta] - max: ClassVar[timedelta] - resolution: ClassVar[timedelta] - def __new__( - cls: type[Self], - days: float = ..., - seconds: float = ..., - microseconds: float = ..., - milliseconds: float = ..., - minutes: float = ..., - hours: float = ..., - weeks: float = ..., - ) -> Self: ... - @property - def days(self) -> int: ... - @property - def seconds(self) -> int: ... - @property - def microseconds(self) -> int: ... - def total_seconds(self) -> float: ... - def __add__(self, other: timedelta) -> timedelta: ... - def __radd__(self, other: timedelta) -> timedelta: ... - def __sub__(self, other: timedelta) -> timedelta: ... - def __rsub__(self, other: timedelta) -> timedelta: ... - def __neg__(self) -> timedelta: ... - def __pos__(self) -> timedelta: ... - def __abs__(self) -> timedelta: ... - def __mul__(self, other: float) -> timedelta: ... - def __rmul__(self, other: float) -> timedelta: ... - @overload - def __floordiv__(self, other: timedelta) -> int: ... - @overload - def __floordiv__(self, other: int) -> timedelta: ... - @overload - def __div__(self, other: timedelta) -> float: ... - @overload - def __div__(self, other: float) -> timedelta: ... - def __le__(self, other: timedelta) -> bool: ... - def __lt__(self, other: timedelta) -> bool: ... - def __ge__(self, other: timedelta) -> bool: ... - def __gt__(self, other: timedelta) -> bool: ... - def __hash__(self) -> int: ... - -class datetime(date): - min: ClassVar[datetime] - max: ClassVar[datetime] - resolution: ClassVar[timedelta] - def __new__( - cls: type[Self], - year: int, - month: int, - day: int, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: _tzinfo | None = ..., - ) -> Self: ... - @property - def year(self) -> int: ... - @property - def month(self) -> int: ... - @property - def day(self) -> int: ... - @property - def hour(self) -> int: ... - @property - def minute(self) -> int: ... - @property - def second(self) -> int: ... - @property - def microsecond(self) -> int: ... - @property - def tzinfo(self) -> _tzinfo | None: ... - @classmethod - def fromtimestamp(cls: type[Self], t: float, tz: _tzinfo | None = ...) -> Self: ... - @classmethod - def utcfromtimestamp(cls: type[Self], t: float) -> Self: ... - @classmethod - def today(cls: type[Self]) -> Self: ... - @classmethod - def fromordinal(cls: type[Self], n: int) -> Self: ... - @overload - @classmethod - def now(cls: type[Self], tz: None = ...) -> Self: ... - @overload - @classmethod - def now(cls, tz: _tzinfo) -> datetime: ... - @classmethod - def utcnow(cls: type[Self]) -> Self: ... - @classmethod - def combine(cls, date: _date, time: _time) -> datetime: ... - def strftime(self, fmt: _Text) -> str: ... - def __format__(self, fmt: AnyStr) -> AnyStr: ... - def toordinal(self) -> int: ... - def timetuple(self) -> struct_time: ... - def utctimetuple(self) -> struct_time: ... - def date(self) -> _date: ... - def time(self) -> _time: ... - def timetz(self) -> _time: ... - def replace( - self, - year: int = ..., - month: int = ..., - day: int = ..., - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: _tzinfo | None = ..., - ) -> datetime: ... - def astimezone(self, tz: _tzinfo) -> datetime: ... - def ctime(self) -> str: ... - def isoformat(self, sep: str = ...) -> str: ... - @classmethod - def strptime(cls, date_string: _Text, format: _Text) -> datetime: ... - def utcoffset(self) -> timedelta | None: ... - def tzname(self) -> str | None: ... - def dst(self) -> timedelta | None: ... - def __le__(self, other: datetime) -> bool: ... # type: ignore[override] - def __lt__(self, other: datetime) -> bool: ... # type: ignore[override] - def __ge__(self, other: datetime) -> bool: ... # type: ignore[override] - def __gt__(self, other: datetime) -> bool: ... # type: ignore[override] - def __add__(self, other: timedelta) -> datetime: ... - def __radd__(self, other: timedelta) -> datetime: ... - @overload # type: ignore[override] - def __sub__(self, other: datetime) -> timedelta: ... - @overload - def __sub__(self, other: timedelta) -> datetime: ... - def __hash__(self) -> int: ... - def weekday(self) -> int: ... - def isoweekday(self) -> int: ... - def isocalendar(self) -> tuple[int, int, int]: ... diff --git a/mypy/typeshed/stdlib/@python2/dbm/__init__.pyi b/mypy/typeshed/stdlib/@python2/dbm/__init__.pyi deleted file mode 100644 index e9c1d01a5c9b..000000000000 --- a/mypy/typeshed/stdlib/@python2/dbm/__init__.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from _typeshed import Self -from types import TracebackType -from typing import Iterator, MutableMapping -from typing_extensions import Literal - -_KeyType = str | bytes -_ValueType = str | bytes - -class _Database(MutableMapping[_KeyType, bytes]): - def close(self) -> None: ... - def __getitem__(self, key: _KeyType) -> bytes: ... - def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... - def __delitem__(self, key: _KeyType) -> None: ... - def __iter__(self) -> Iterator[bytes]: ... - def __len__(self) -> int: ... - def __del__(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - -class _error(Exception): ... - -error = tuple[type[_error], type[OSError]] - -def whichdb(filename: str) -> str: ... -def open(file: str, flag: Literal["r", "w", "c", "n"] = ..., mode: int = ...) -> _Database: ... diff --git a/mypy/typeshed/stdlib/@python2/dbm/dumb.pyi b/mypy/typeshed/stdlib/@python2/dbm/dumb.pyi deleted file mode 100644 index acb4b3b7ae7f..000000000000 --- a/mypy/typeshed/stdlib/@python2/dbm/dumb.pyi +++ /dev/null @@ -1,26 +0,0 @@ -from _typeshed import Self -from types import TracebackType -from typing import Iterator, MutableMapping - -_KeyType = str | bytes -_ValueType = str | bytes - -error = OSError - -class _Database(MutableMapping[_KeyType, bytes]): - def __init__(self, filebasename: str, mode: str, flag: str = ...) -> None: ... - def sync(self) -> None: ... - def iterkeys(self) -> Iterator[bytes]: ... # undocumented - def close(self) -> None: ... - def __getitem__(self, key: _KeyType) -> bytes: ... - def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... - def __delitem__(self, key: _KeyType) -> None: ... - def __iter__(self) -> Iterator[bytes]: ... - def __len__(self) -> int: ... - def __del__(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - -def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ... diff --git a/mypy/typeshed/stdlib/@python2/dbm/gnu.pyi b/mypy/typeshed/stdlib/@python2/dbm/gnu.pyi deleted file mode 100644 index c6eed0be2098..000000000000 --- a/mypy/typeshed/stdlib/@python2/dbm/gnu.pyi +++ /dev/null @@ -1,36 +0,0 @@ -from _typeshed import Self -from types import TracebackType -from typing import TypeVar, overload - -_T = TypeVar("_T") -_KeyType = str | bytes -_ValueType = str | bytes - -class error(OSError): ... - -# Actual typename gdbm, not exposed by the implementation -class _gdbm: - def firstkey(self) -> bytes | None: ... - def nextkey(self, key: _KeyType) -> bytes | None: ... - def reorganize(self) -> None: ... - def sync(self) -> None: ... - def close(self) -> None: ... - def __getitem__(self, item: _KeyType) -> bytes: ... - def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... - def __delitem__(self, key: _KeyType) -> None: ... - def __len__(self) -> int: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - @overload - def get(self, k: _KeyType) -> bytes | None: ... - @overload - def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... - def keys(self) -> list[bytes]: ... - def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - -def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _gdbm: ... diff --git a/mypy/typeshed/stdlib/@python2/dbm/ndbm.pyi b/mypy/typeshed/stdlib/@python2/dbm/ndbm.pyi deleted file mode 100644 index 764aed01a357..000000000000 --- a/mypy/typeshed/stdlib/@python2/dbm/ndbm.pyi +++ /dev/null @@ -1,35 +0,0 @@ -from _typeshed import Self -from types import TracebackType -from typing import TypeVar, overload - -_T = TypeVar("_T") -_KeyType = str | bytes -_ValueType = str | bytes - -class error(OSError): ... - -library: str - -# Actual typename dbm, not exposed by the implementation -class _dbm: - def close(self) -> None: ... - def __getitem__(self, item: _KeyType) -> bytes: ... - def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... - def __delitem__(self, key: _KeyType) -> None: ... - def __len__(self) -> int: ... - def __del__(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - @overload - def get(self, k: _KeyType) -> bytes | None: ... - @overload - def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... - def keys(self) -> list[bytes]: ... - def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... - # Don't exist at runtime - __new__: None # type: ignore[assignment] - __init__: None # type: ignore[assignment] - -def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _dbm: ... diff --git a/mypy/typeshed/stdlib/@python2/decimal.pyi b/mypy/typeshed/stdlib/@python2/decimal.pyi deleted file mode 100644 index 5ea7348c2eaf..000000000000 --- a/mypy/typeshed/stdlib/@python2/decimal.pyi +++ /dev/null @@ -1,246 +0,0 @@ -from _typeshed import Self -from types import TracebackType -from typing import Any, Container, NamedTuple, Sequence, Text, Union - -_Decimal = Decimal | int -_DecimalNew = Union[Decimal, float, Text, tuple[int, Sequence[int], int]] -_ComparableNum = Decimal | float - -class DecimalTuple(NamedTuple): - sign: int - digits: tuple[int, ...] - exponent: int - -ROUND_DOWN: str -ROUND_HALF_UP: str -ROUND_HALF_EVEN: str -ROUND_CEILING: str -ROUND_FLOOR: str -ROUND_UP: str -ROUND_HALF_DOWN: str -ROUND_05UP: str - -class DecimalException(ArithmeticError): - def handle(self, context: Context, *args: Any) -> Decimal | None: ... - -class Clamped(DecimalException): ... -class InvalidOperation(DecimalException): ... -class ConversionSyntax(InvalidOperation): ... -class DivisionByZero(DecimalException, ZeroDivisionError): ... -class DivisionImpossible(InvalidOperation): ... -class DivisionUndefined(InvalidOperation, ZeroDivisionError): ... -class Inexact(DecimalException): ... -class InvalidContext(InvalidOperation): ... -class Rounded(DecimalException): ... -class Subnormal(DecimalException): ... -class Overflow(Inexact, Rounded): ... -class Underflow(Inexact, Rounded, Subnormal): ... - -def setcontext(__context: Context) -> None: ... -def getcontext() -> Context: ... -def localcontext(ctx: Context | None = ...) -> _ContextManager: ... - -class Decimal(object): - def __new__(cls: type[Self], value: _DecimalNew = ..., context: Context | None = ...) -> Self: ... - @classmethod - def from_float(cls, __f: float) -> Decimal: ... - def __nonzero__(self) -> bool: ... - def __div__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __rdiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __ne__(self, other: object, context: Context | None = ...) -> bool: ... - def compare(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __hash__(self) -> int: ... - def as_tuple(self) -> DecimalTuple: ... - def to_eng_string(self, context: Context | None = ...) -> str: ... - def __abs__(self, round: bool = ..., context: Context | None = ...) -> Decimal: ... - def __add__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __divmod__(self, other: _Decimal, context: Context | None = ...) -> tuple[Decimal, Decimal]: ... - def __eq__(self, other: object, context: Context | None = ...) -> bool: ... - def __floordiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __ge__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... - def __gt__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... - def __le__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... - def __lt__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... - def __mod__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __mul__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __neg__(self, context: Context | None = ...) -> Decimal: ... - def __pos__(self, context: Context | None = ...) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: _Decimal | None = ..., context: Context | None = ...) -> Decimal: ... - def __radd__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __rdivmod__(self, other: _Decimal, context: Context | None = ...) -> tuple[Decimal, Decimal]: ... - def __rfloordiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __rmod__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __rmul__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __rsub__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __rtruediv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __str__(self, eng: bool = ..., context: Context | None = ...) -> str: ... - def __sub__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __truediv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def remainder_near(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __float__(self) -> float: ... - def __int__(self) -> int: ... - def __trunc__(self) -> int: ... - @property - def real(self) -> Decimal: ... - @property - def imag(self) -> Decimal: ... - def conjugate(self) -> Decimal: ... - def __complex__(self) -> complex: ... - def __long__(self) -> long: ... - def fma(self, other: _Decimal, third: _Decimal, context: Context | None = ...) -> Decimal: ... - def __rpow__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def normalize(self, context: Context | None = ...) -> Decimal: ... - def quantize( - self, exp: _Decimal, rounding: str | None = ..., context: Context | None = ..., watchexp: bool = ... - ) -> Decimal: ... - def same_quantum(self, other: _Decimal) -> bool: ... - def to_integral_exact(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... - def to_integral_value(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... - def to_integral(self, rounding: str | None = ..., context: Context | None = ...) -> Decimal: ... - def sqrt(self, context: Context | None = ...) -> Decimal: ... - def max(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def min(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def adjusted(self) -> int: ... - def canonical(self, context: Context | None = ...) -> Decimal: ... - def compare_signal(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def compare_total(self, other: _Decimal) -> Decimal: ... - def compare_total_mag(self, other: _Decimal) -> Decimal: ... - def copy_abs(self) -> Decimal: ... - def copy_negate(self) -> Decimal: ... - def copy_sign(self, other: _Decimal) -> Decimal: ... - def exp(self, context: Context | None = ...) -> Decimal: ... - def is_canonical(self) -> bool: ... - def is_finite(self) -> bool: ... - def is_infinite(self) -> bool: ... - def is_nan(self) -> bool: ... - def is_normal(self, context: Context | None = ...) -> bool: ... - def is_qnan(self) -> bool: ... - def is_signed(self) -> bool: ... - def is_snan(self) -> bool: ... - def is_subnormal(self, context: Context | None = ...) -> bool: ... - def is_zero(self) -> bool: ... - def ln(self, context: Context | None = ...) -> Decimal: ... - def log10(self, context: Context | None = ...) -> Decimal: ... - def logb(self, context: Context | None = ...) -> Decimal: ... - def logical_and(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def logical_invert(self, context: Context | None = ...) -> Decimal: ... - def logical_or(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def logical_xor(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def max_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def min_mag(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def next_minus(self, context: Context | None = ...) -> Decimal: ... - def next_plus(self, context: Context | None = ...) -> Decimal: ... - def next_toward(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def number_class(self, context: Context | None = ...) -> str: ... - def radix(self) -> Decimal: ... - def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __reduce__(self) -> tuple[type[Decimal], tuple[str]]: ... - def __copy__(self) -> Decimal: ... - def __deepcopy__(self, memo: Any) -> Decimal: ... - def __format__(self, specifier: str, context: Context | None = ...) -> str: ... - -class _ContextManager(object): - new_context: Context - saved_context: Context - def __init__(self, new_context: Context) -> None: ... - def __enter__(self) -> Context: ... - def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... - -_TrapType = type[DecimalException] - -class Context(object): - prec: int - rounding: str - Emin: int - Emax: int - capitals: int - _clamp: int - traps: dict[_TrapType, bool] - flags: dict[_TrapType, bool] - def __init__( - self, - prec: int | None = ..., - rounding: str | None = ..., - traps: None | dict[_TrapType, bool] | Container[_TrapType] = ..., - flags: None | dict[_TrapType, bool] | Container[_TrapType] = ..., - Emin: int | None = ..., - Emax: int | None = ..., - capitals: int | None = ..., - _clamp: int | None = ..., - _ignored_flags: list[_TrapType] | None = ..., - ) -> None: ... - def clear_flags(self) -> None: ... - def copy(self) -> Context: ... - def __copy__(self) -> Context: ... - __hash__: Any = ... - def Etiny(self) -> int: ... - def Etop(self) -> int: ... - def create_decimal(self, __num: _DecimalNew = ...) -> Decimal: ... - def create_decimal_from_float(self, __f: float) -> Decimal: ... - def abs(self, __x: _Decimal) -> Decimal: ... - def add(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def canonical(self, __x: Decimal) -> Decimal: ... - def compare(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def compare_signal(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def compare_total(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def compare_total_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def copy_abs(self, __x: _Decimal) -> Decimal: ... - def copy_decimal(self, __x: _Decimal) -> Decimal: ... - def copy_negate(self, __x: _Decimal) -> Decimal: ... - def copy_sign(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def divide(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def divide_int(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def divmod(self, __x: _Decimal, __y: _Decimal) -> tuple[Decimal, Decimal]: ... - def exp(self, __x: _Decimal) -> Decimal: ... - def fma(self, __x: _Decimal, __y: _Decimal, __z: _Decimal) -> Decimal: ... - def is_canonical(self, __x: _Decimal) -> bool: ... - def is_finite(self, __x: _Decimal) -> bool: ... - def is_infinite(self, __x: _Decimal) -> bool: ... - def is_nan(self, __x: _Decimal) -> bool: ... - def is_normal(self, __x: _Decimal) -> bool: ... - def is_qnan(self, __x: _Decimal) -> bool: ... - def is_signed(self, __x: _Decimal) -> bool: ... - def is_snan(self, __x: _Decimal) -> bool: ... - def is_subnormal(self, __x: _Decimal) -> bool: ... - def is_zero(self, __x: _Decimal) -> bool: ... - def ln(self, __x: _Decimal) -> Decimal: ... - def log10(self, __x: _Decimal) -> Decimal: ... - def logb(self, __x: _Decimal) -> Decimal: ... - def logical_and(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def logical_invert(self, __x: _Decimal) -> Decimal: ... - def logical_or(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def logical_xor(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def max(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def max_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def min(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def min_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def minus(self, __x: _Decimal) -> Decimal: ... - def multiply(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def next_minus(self, __x: _Decimal) -> Decimal: ... - def next_plus(self, __x: _Decimal) -> Decimal: ... - def next_toward(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def normalize(self, __x: _Decimal) -> Decimal: ... - def number_class(self, __x: _Decimal) -> str: ... - def plus(self, __x: _Decimal) -> Decimal: ... - def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = ...) -> Decimal: ... - def quantize(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def radix(self) -> Decimal: ... - def remainder(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def remainder_near(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def rotate(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def same_quantum(self, __x: _Decimal, __y: _Decimal) -> bool: ... - def scaleb(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def shift(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def sqrt(self, __x: _Decimal) -> Decimal: ... - def subtract(self, __x: _Decimal, __y: _Decimal) -> Decimal: ... - def to_eng_string(self, __x: _Decimal) -> str: ... - def to_sci_string(self, __x: _Decimal) -> str: ... - def to_integral_exact(self, __x: _Decimal) -> Decimal: ... - def to_integral_value(self, __x: _Decimal) -> Decimal: ... - def to_integral(self, __x: _Decimal) -> Decimal: ... - -DefaultContext: Context -BasicContext: Context -ExtendedContext: Context diff --git a/mypy/typeshed/stdlib/@python2/difflib.pyi b/mypy/typeshed/stdlib/@python2/difflib.pyi deleted file mode 100644 index f4214cec2260..000000000000 --- a/mypy/typeshed/stdlib/@python2/difflib.pyi +++ /dev/null @@ -1,95 +0,0 @@ -from typing import Any, AnyStr, Callable, Generic, Iterable, Iterator, NamedTuple, Sequence, Text, TypeVar, overload - -_T = TypeVar("_T") - -# Aliases can't point to type vars, so we need to redeclare AnyStr -_StrType = TypeVar("_StrType", Text, bytes) - -_JunkCallback = Callable[[Text], bool] | Callable[[str], bool] - -class Match(NamedTuple): - a: int - b: int - size: int - -class SequenceMatcher(Generic[_T]): - def __init__( - self, isjunk: Callable[[_T], bool] | None = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ... - ) -> None: ... - def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ... - def set_seq1(self, a: Sequence[_T]) -> None: ... - def set_seq2(self, b: Sequence[_T]) -> None: ... - def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ... - def get_matching_blocks(self) -> list[Match]: ... - def get_opcodes(self) -> list[tuple[str, int, int, int, int]]: ... - def get_grouped_opcodes(self, n: int = ...) -> Iterable[list[tuple[str, int, int, int, int]]]: ... - def ratio(self) -> float: ... - def quick_ratio(self) -> float: ... - def real_quick_ratio(self) -> float: ... - -# mypy thinks the signatures of the overloads overlap, but the types still work fine -@overload -def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = ..., cutoff: float = ...) -> list[AnyStr]: ... # type: ignore[misc] -@overload -def get_close_matches( - word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = ..., cutoff: float = ... -) -> list[Sequence[_T]]: ... - -class Differ: - def __init__(self, linejunk: _JunkCallback | None = ..., charjunk: _JunkCallback | None = ...) -> None: ... - def compare(self, a: Sequence[_StrType], b: Sequence[_StrType]) -> Iterator[_StrType]: ... - -def IS_LINE_JUNK(line: _StrType, pat: Any = ...) -> bool: ... # pat is undocumented -def IS_CHARACTER_JUNK(ch: _StrType, ws: _StrType = ...) -> bool: ... # ws is undocumented -def unified_diff( - a: Sequence[_StrType], - b: Sequence[_StrType], - fromfile: _StrType = ..., - tofile: _StrType = ..., - fromfiledate: _StrType = ..., - tofiledate: _StrType = ..., - n: int = ..., - lineterm: _StrType = ..., -) -> Iterator[_StrType]: ... -def context_diff( - a: Sequence[_StrType], - b: Sequence[_StrType], - fromfile: _StrType = ..., - tofile: _StrType = ..., - fromfiledate: _StrType = ..., - tofiledate: _StrType = ..., - n: int = ..., - lineterm: _StrType = ..., -) -> Iterator[_StrType]: ... -def ndiff( - a: Sequence[_StrType], b: Sequence[_StrType], linejunk: _JunkCallback | None = ..., charjunk: _JunkCallback | None = ... -) -> Iterator[_StrType]: ... - -class HtmlDiff(object): - def __init__( - self, - tabsize: int = ..., - wrapcolumn: int | None = ..., - linejunk: _JunkCallback | None = ..., - charjunk: _JunkCallback | None = ..., - ) -> None: ... - def make_file( - self, - fromlines: Sequence[_StrType], - tolines: Sequence[_StrType], - fromdesc: _StrType = ..., - todesc: _StrType = ..., - context: bool = ..., - numlines: int = ..., - ) -> _StrType: ... - def make_table( - self, - fromlines: Sequence[_StrType], - tolines: Sequence[_StrType], - fromdesc: _StrType = ..., - todesc: _StrType = ..., - context: bool = ..., - numlines: int = ..., - ) -> _StrType: ... - -def restore(delta: Iterable[_StrType], which: int) -> Iterator[_StrType]: ... diff --git a/mypy/typeshed/stdlib/@python2/dircache.pyi b/mypy/typeshed/stdlib/@python2/dircache.pyi deleted file mode 100644 index dc1e129648e8..000000000000 --- a/mypy/typeshed/stdlib/@python2/dircache.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import MutableSequence, Text - -def reset() -> None: ... -def listdir(path: Text) -> list[str]: ... - -opendir = listdir - -def annotate(head: Text, list: MutableSequence[str] | MutableSequence[Text] | MutableSequence[str | Text]) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/dis.pyi b/mypy/typeshed/stdlib/@python2/dis.pyi deleted file mode 100644 index 79cc30a68a0a..000000000000 --- a/mypy/typeshed/stdlib/@python2/dis.pyi +++ /dev/null @@ -1,30 +0,0 @@ -import types -from opcode import ( - EXTENDED_ARG as EXTENDED_ARG, - HAVE_ARGUMENT as HAVE_ARGUMENT, - cmp_op as cmp_op, - hascompare as hascompare, - hasconst as hasconst, - hasfree as hasfree, - hasjabs as hasjabs, - hasjrel as hasjrel, - haslocal as haslocal, - hasname as hasname, - opmap as opmap, - opname as opname, -) -from typing import Any, Callable, Iterator - -# Strictly this should not have to include Callable, but mypy doesn't use FunctionType -# for functions (python/mypy#3171) -_have_code = types.MethodType | types.FunctionType | types.CodeType | type | Callable[..., Any] -_have_code_or_string = _have_code | str | bytes - -COMPILER_FLAG_NAMES: dict[int, str] - -def findlabels(code: _have_code) -> list[int]: ... -def findlinestarts(code: _have_code) -> Iterator[tuple[int, int]]: ... -def dis(x: _have_code_or_string = ...) -> None: ... -def distb(tb: types.TracebackType = ...) -> None: ... -def disassemble(co: _have_code, lasti: int = ...) -> None: ... -def disco(co: _have_code, lasti: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/__init__.pyi b/mypy/typeshed/stdlib/@python2/distutils/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/archive_util.pyi b/mypy/typeshed/stdlib/@python2/distutils/archive_util.pyi deleted file mode 100644 index dd2cbda73fc6..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/archive_util.pyi +++ /dev/null @@ -1,5 +0,0 @@ -def make_archive( - base_name: str, format: str, root_dir: str | None = ..., base_dir: str | None = ..., verbose: int = ..., dry_run: int = ... -) -> str: ... -def make_tarball(base_name: str, base_dir: str, compress: str | None = ..., verbose: int = ..., dry_run: int = ...) -> str: ... -def make_zipfile(base_name: str, base_dir: str, verbose: int = ..., dry_run: int = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/bcppcompiler.pyi b/mypy/typeshed/stdlib/@python2/distutils/bcppcompiler.pyi deleted file mode 100644 index 3e432f94b525..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/bcppcompiler.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from distutils.ccompiler import CCompiler - -class BCPPCompiler(CCompiler): ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/ccompiler.pyi b/mypy/typeshed/stdlib/@python2/distutils/ccompiler.pyi deleted file mode 100644 index 4cdc62ce3bae..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/ccompiler.pyi +++ /dev/null @@ -1,150 +0,0 @@ -from typing import Any, Callable, Union - -_Macro = Union[tuple[str], tuple[str, str | None]] - -def gen_lib_options( - compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str] -) -> list[str]: ... -def gen_preprocess_options(macros: list[_Macro], include_dirs: list[str]) -> list[str]: ... -def get_default_compiler(osname: str | None = ..., platform: str | None = ...) -> str: ... -def new_compiler( - plat: str | None = ..., compiler: str | None = ..., verbose: int = ..., dry_run: int = ..., force: int = ... -) -> CCompiler: ... -def show_compilers() -> None: ... - -class CCompiler: - dry_run: bool - force: bool - verbose: bool - output_dir: str | None - macros: list[_Macro] - include_dirs: list[str] - libraries: list[str] - library_dirs: list[str] - runtime_library_dirs: list[str] - objects: list[str] - def __init__(self, verbose: int = ..., dry_run: int = ..., force: int = ...) -> None: ... - def add_include_dir(self, dir: str) -> None: ... - def set_include_dirs(self, dirs: list[str]) -> None: ... - def add_library(self, libname: str) -> None: ... - def set_libraries(self, libnames: list[str]) -> None: ... - def add_library_dir(self, dir: str) -> None: ... - def set_library_dirs(self, dirs: list[str]) -> None: ... - def add_runtime_library_dir(self, dir: str) -> None: ... - def set_runtime_library_dirs(self, dirs: list[str]) -> None: ... - def define_macro(self, name: str, value: str | None = ...) -> None: ... - def undefine_macro(self, name: str) -> None: ... - def add_link_object(self, object: str) -> None: ... - def set_link_objects(self, objects: list[str]) -> None: ... - def detect_language(self, sources: str | list[str]) -> str | None: ... - def find_library_file(self, dirs: list[str], lib: str, debug: bool = ...) -> str | None: ... - def has_function( - self, - funcname: str, - includes: list[str] | None = ..., - include_dirs: list[str] | None = ..., - libraries: list[str] | None = ..., - library_dirs: list[str] | None = ..., - ) -> bool: ... - def library_dir_option(self, dir: str) -> str: ... - def library_option(self, lib: str) -> str: ... - def runtime_library_dir_option(self, dir: str) -> str: ... - def set_executables(self, **args: str) -> None: ... - def compile( - self, - sources: list[str], - output_dir: str | None = ..., - macros: _Macro | None = ..., - include_dirs: list[str] | None = ..., - debug: bool = ..., - extra_preargs: list[str] | None = ..., - extra_postargs: list[str] | None = ..., - depends: list[str] | None = ..., - ) -> list[str]: ... - def create_static_lib( - self, - objects: list[str], - output_libname: str, - output_dir: str | None = ..., - debug: bool = ..., - target_lang: str | None = ..., - ) -> None: ... - def link( - self, - target_desc: str, - objects: list[str], - output_filename: str, - output_dir: str | None = ..., - libraries: list[str] | None = ..., - library_dirs: list[str] | None = ..., - runtime_library_dirs: list[str] | None = ..., - export_symbols: list[str] | None = ..., - debug: bool = ..., - extra_preargs: list[str] | None = ..., - extra_postargs: list[str] | None = ..., - build_temp: str | None = ..., - target_lang: str | None = ..., - ) -> None: ... - def link_executable( - self, - objects: list[str], - output_progname: str, - output_dir: str | None = ..., - libraries: list[str] | None = ..., - library_dirs: list[str] | None = ..., - runtime_library_dirs: list[str] | None = ..., - debug: bool = ..., - extra_preargs: list[str] | None = ..., - extra_postargs: list[str] | None = ..., - target_lang: str | None = ..., - ) -> None: ... - def link_shared_lib( - self, - objects: list[str], - output_libname: str, - output_dir: str | None = ..., - libraries: list[str] | None = ..., - library_dirs: list[str] | None = ..., - runtime_library_dirs: list[str] | None = ..., - export_symbols: list[str] | None = ..., - debug: bool = ..., - extra_preargs: list[str] | None = ..., - extra_postargs: list[str] | None = ..., - build_temp: str | None = ..., - target_lang: str | None = ..., - ) -> None: ... - def link_shared_object( - self, - objects: list[str], - output_filename: str, - output_dir: str | None = ..., - libraries: list[str] | None = ..., - library_dirs: list[str] | None = ..., - runtime_library_dirs: list[str] | None = ..., - export_symbols: list[str] | None = ..., - debug: bool = ..., - extra_preargs: list[str] | None = ..., - extra_postargs: list[str] | None = ..., - build_temp: str | None = ..., - target_lang: str | None = ..., - ) -> None: ... - def preprocess( - self, - source: str, - output_file: str | None = ..., - macros: list[_Macro] | None = ..., - include_dirs: list[str] | None = ..., - extra_preargs: list[str] | None = ..., - extra_postargs: list[str] | None = ..., - ) -> None: ... - def executable_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... - def object_filenames(self, source_filenames: list[str], strip_dir: int = ..., output_dir: str = ...) -> list[str]: ... - def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... - def spawn(self, cmd: list[str]) -> None: ... - def mkpath(self, name: str, mode: int = ...) -> None: ... - def move_file(self, src: str, dst: str) -> str: ... - def announce(self, msg: str, level: int = ...) -> None: ... - def warn(self, msg: str) -> None: ... - def debug_print(self, msg: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/cmd.pyi b/mypy/typeshed/stdlib/@python2/distutils/cmd.pyi deleted file mode 100644 index 096414713f7f..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/cmd.pyi +++ /dev/null @@ -1,67 +0,0 @@ -from abc import abstractmethod -from distutils.dist import Distribution -from typing import Any, Callable, Iterable, Text - -class Command: - sub_commands: list[tuple[str, Callable[[Command], bool] | None]] - def __init__(self, dist: Distribution) -> None: ... - @abstractmethod - def initialize_options(self) -> None: ... - @abstractmethod - def finalize_options(self) -> None: ... - @abstractmethod - def run(self) -> None: ... - def announce(self, msg: Text, level: int = ...) -> None: ... - def debug_print(self, msg: Text) -> None: ... - def ensure_string(self, option: str, default: str | None = ...) -> None: ... - def ensure_string_list(self, option: str | list[str]) -> None: ... - def ensure_filename(self, option: str) -> None: ... - def ensure_dirname(self, option: str) -> None: ... - def get_command_name(self) -> str: ... - def set_undefined_options(self, src_cmd: Text, *option_pairs: tuple[str, str]) -> None: ... - def get_finalized_command(self, command: Text, create: int = ...) -> Command: ... - def reinitialize_command(self, command: Command | Text, reinit_subcommands: int = ...) -> Command: ... - def run_command(self, command: Text) -> None: ... - def get_sub_commands(self) -> list[str]: ... - def warn(self, msg: Text) -> None: ... - def execute(self, func: Callable[..., Any], args: Iterable[Any], msg: Text | None = ..., level: int = ...) -> None: ... - def mkpath(self, name: str, mode: int = ...) -> None: ... - def copy_file( - self, - infile: str, - outfile: str, - preserve_mode: int = ..., - preserve_times: int = ..., - link: str | None = ..., - level: Any = ..., - ) -> tuple[str, bool]: ... # level is not used - def copy_tree( - self, - infile: str, - outfile: str, - preserve_mode: int = ..., - preserve_times: int = ..., - preserve_symlinks: int = ..., - level: Any = ..., - ) -> list[str]: ... # level is not used - def move_file(self, src: str, dst: str, level: Any = ...) -> str: ... # level is not used - def spawn(self, cmd: Iterable[str], search_path: int = ..., level: Any = ...) -> None: ... # level is not used - def make_archive( - self, - base_name: str, - format: str, - root_dir: str | None = ..., - base_dir: str | None = ..., - owner: str | None = ..., - group: str | None = ..., - ) -> str: ... - def make_file( - self, - infiles: str | list[str] | tuple[str, ...], - outfile: str, - func: Callable[..., Any], - args: list[Any], - exec_msg: str | None = ..., - skip_msg: str | None = ..., - level: Any = ..., - ) -> None: ... # level is not used diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/__init__.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/bdist.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/bdist.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/bdist_dumb.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/bdist_dumb.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/bdist_msi.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/bdist_msi.pyi deleted file mode 100644 index 09351d29a673..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/command/bdist_msi.pyi +++ /dev/null @@ -1,9 +0,0 @@ -import sys - -if sys.platform == "win32": - from distutils.cmd import Command - - class bdist_msi(Command): - def initialize_options(self) -> None: ... - def finalize_options(self) -> None: ... - def run(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/bdist_packager.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/bdist_packager.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/bdist_rpm.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/bdist_rpm.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/bdist_wininst.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/bdist_wininst.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/build.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/build.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/build_clib.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/build_clib.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/build_ext.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/build_ext.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/build_py.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/build_py.pyi deleted file mode 100644 index a29a1f3a12a7..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/command/build_py.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from distutils.cmd import Command - -class build_py(Command): - def initialize_options(self) -> None: ... - def finalize_options(self) -> None: ... - def run(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/build_scripts.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/build_scripts.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/check.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/check.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/clean.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/clean.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/config.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/config.pyi deleted file mode 100644 index 790a8b485a56..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/command/config.pyi +++ /dev/null @@ -1,83 +0,0 @@ -from distutils import log as log -from distutils.ccompiler import CCompiler -from distutils.core import Command as Command -from distutils.errors import DistutilsExecError as DistutilsExecError -from distutils.sysconfig import customize_compiler as customize_compiler -from typing import Pattern, Sequence - -LANG_EXT: dict[str, str] - -class config(Command): - description: str = ... - # Tuple is full name, short name, description - user_options: Sequence[tuple[str, str | None, str]] = ... - compiler: str | CCompiler | None = ... - cc: str | None = ... - include_dirs: Sequence[str] | None = ... - libraries: Sequence[str] | None = ... - library_dirs: Sequence[str] | None = ... - noisy: int = ... - dump_source: int = ... - temp_files: Sequence[str] = ... - def initialize_options(self) -> None: ... - def finalize_options(self) -> None: ... - def run(self) -> None: ... - def try_cpp( - self, - body: str | None = ..., - headers: Sequence[str] | None = ..., - include_dirs: Sequence[str] | None = ..., - lang: str = ..., - ) -> bool: ... - def search_cpp( - self, - pattern: Pattern[str] | str, - body: str | None = ..., - headers: Sequence[str] | None = ..., - include_dirs: Sequence[str] | None = ..., - lang: str = ..., - ) -> bool: ... - def try_compile( - self, body: str, headers: Sequence[str] | None = ..., include_dirs: Sequence[str] | None = ..., lang: str = ... - ) -> bool: ... - def try_link( - self, - body: str, - headers: Sequence[str] | None = ..., - include_dirs: Sequence[str] | None = ..., - libraries: Sequence[str] | None = ..., - library_dirs: Sequence[str] | None = ..., - lang: str = ..., - ) -> bool: ... - def try_run( - self, - body: str, - headers: Sequence[str] | None = ..., - include_dirs: Sequence[str] | None = ..., - libraries: Sequence[str] | None = ..., - library_dirs: Sequence[str] | None = ..., - lang: str = ..., - ) -> bool: ... - def check_func( - self, - func: str, - headers: Sequence[str] | None = ..., - include_dirs: Sequence[str] | None = ..., - libraries: Sequence[str] | None = ..., - library_dirs: Sequence[str] | None = ..., - decl: int = ..., - call: int = ..., - ) -> bool: ... - def check_lib( - self, - library: str, - library_dirs: Sequence[str] | None = ..., - headers: Sequence[str] | None = ..., - include_dirs: Sequence[str] | None = ..., - other_libraries: list[str] = ..., - ) -> bool: ... - def check_header( - self, header: str, include_dirs: Sequence[str] | None = ..., library_dirs: Sequence[str] | None = ..., lang: str = ... - ) -> bool: ... - -def dump_file(filename: str, head: str | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/install.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/install.pyi deleted file mode 100644 index 2824236735f0..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/command/install.pyi +++ /dev/null @@ -1,12 +0,0 @@ -from distutils.cmd import Command -from typing import Text - -class install(Command): - user: bool - prefix: Text | None - home: Text | None - root: Text | None - install_lib: Text | None - def initialize_options(self) -> None: ... - def finalize_options(self) -> None: ... - def run(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/install_data.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/install_data.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/install_egg_info.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/install_egg_info.pyi deleted file mode 100644 index 1bee1ed07e45..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/command/install_egg_info.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from distutils.cmd import Command -from typing import ClassVar - -class install_egg_info(Command): - description: ClassVar[str] - user_options: ClassVar[list[tuple[str, str | None, str]]] - def initialize_options(self) -> None: ... - def finalize_options(self) -> None: ... - def run(self) -> None: ... - def get_outputs(self) -> list[str]: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/install_headers.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/install_headers.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/install_lib.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/install_lib.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/install_scripts.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/install_scripts.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/register.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/register.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/sdist.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/sdist.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/distutils/command/upload.pyi b/mypy/typeshed/stdlib/@python2/distutils/command/upload.pyi deleted file mode 100644 index 005db872b0bf..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/command/upload.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from distutils.config import PyPIRCCommand -from typing import ClassVar - -class upload(PyPIRCCommand): - description: ClassVar[str] - boolean_options: ClassVar[list[str]] - def run(self) -> None: ... - def upload_file(self, command, pyversion, filename) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/config.pyi b/mypy/typeshed/stdlib/@python2/distutils/config.pyi deleted file mode 100644 index 5814a82841cc..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/config.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from abc import abstractmethod -from distutils.cmd import Command -from typing import ClassVar - -DEFAULT_PYPIRC: str - -class PyPIRCCommand(Command): - DEFAULT_REPOSITORY: ClassVar[str] - DEFAULT_REALM: ClassVar[str] - repository: None - realm: None - user_options: ClassVar[list[tuple[str, str | None, str]]] - boolean_options: ClassVar[list[str]] - def initialize_options(self) -> None: ... - def finalize_options(self) -> None: ... - @abstractmethod - def run(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/core.pyi b/mypy/typeshed/stdlib/@python2/distutils/core.pyi deleted file mode 100644 index 6564c9a86ded..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/core.pyi +++ /dev/null @@ -1,48 +0,0 @@ -from distutils.cmd import Command as Command -from distutils.dist import Distribution as Distribution -from distutils.extension import Extension as Extension -from typing import Any, Mapping - -def setup( - *, - name: str = ..., - version: str = ..., - description: str = ..., - long_description: str = ..., - author: str = ..., - author_email: str = ..., - maintainer: str = ..., - maintainer_email: str = ..., - url: str = ..., - download_url: str = ..., - packages: list[str] = ..., - py_modules: list[str] = ..., - scripts: list[str] = ..., - ext_modules: list[Extension] = ..., - classifiers: list[str] = ..., - distclass: type[Distribution] = ..., - script_name: str = ..., - script_args: list[str] = ..., - options: Mapping[str, Any] = ..., - license: str = ..., - keywords: list[str] | str = ..., - platforms: list[str] | str = ..., - cmdclass: Mapping[str, type[Command]] = ..., - data_files: list[tuple[str, list[str]]] = ..., - package_dir: Mapping[str, str] = ..., - obsoletes: list[str] = ..., - provides: list[str] = ..., - requires: list[str] = ..., - command_packages: list[str] = ..., - command_options: Mapping[str, Mapping[str, tuple[Any, Any]]] = ..., - package_data: Mapping[str, list[str]] = ..., - include_package_data: bool = ..., - libraries: list[str] = ..., - headers: list[str] = ..., - ext_package: str = ..., - include_dirs: list[str] = ..., - password: str = ..., - fullname: str = ..., - **attrs: Any, -) -> None: ... -def run_setup(script_name: str, script_args: list[str] | None = ..., stop_after: str = ...) -> Distribution: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/cygwinccompiler.pyi b/mypy/typeshed/stdlib/@python2/distutils/cygwinccompiler.pyi deleted file mode 100644 index 1f85b254860b..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/cygwinccompiler.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from distutils.unixccompiler import UnixCCompiler - -class CygwinCCompiler(UnixCCompiler): ... -class Mingw32CCompiler(CygwinCCompiler): ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/debug.pyi b/mypy/typeshed/stdlib/@python2/distutils/debug.pyi deleted file mode 100644 index 098dc3dee246..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/debug.pyi +++ /dev/null @@ -1 +0,0 @@ -DEBUG: bool diff --git a/mypy/typeshed/stdlib/@python2/distutils/dep_util.pyi b/mypy/typeshed/stdlib/@python2/distutils/dep_util.pyi deleted file mode 100644 index 929d6ffd0c81..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/dep_util.pyi +++ /dev/null @@ -1,3 +0,0 @@ -def newer(source: str, target: str) -> bool: ... -def newer_pairwise(sources: list[str], targets: list[str]) -> list[tuple[str, str]]: ... -def newer_group(sources: list[str], target: str, missing: str = ...) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/dir_util.pyi b/mypy/typeshed/stdlib/@python2/distutils/dir_util.pyi deleted file mode 100644 index ffe5ff1cfbd4..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/dir_util.pyi +++ /dev/null @@ -1,13 +0,0 @@ -def mkpath(name: str, mode: int = ..., verbose: int = ..., dry_run: int = ...) -> list[str]: ... -def create_tree(base_dir: str, files: list[str], mode: int = ..., verbose: int = ..., dry_run: int = ...) -> None: ... -def copy_tree( - src: str, - dst: str, - preserve_mode: int = ..., - preserve_times: int = ..., - preserve_symlinks: int = ..., - update: int = ..., - verbose: int = ..., - dry_run: int = ..., -) -> list[str]: ... -def remove_tree(directory: str, verbose: int = ..., dry_run: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/dist.pyi b/mypy/typeshed/stdlib/@python2/distutils/dist.pyi deleted file mode 100644 index 8e6eeafc15b3..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/dist.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from distutils.cmd import Command -from typing import Any, Iterable, Mapping, Text - -class Distribution: - cmdclass: dict[str, type[Command]] - def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... - def get_option_dict(self, command: str) -> dict[str, tuple[str, Text]]: ... - def parse_config_files(self, filenames: Iterable[Text] | None = ...) -> None: ... - def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/emxccompiler.pyi b/mypy/typeshed/stdlib/@python2/distutils/emxccompiler.pyi deleted file mode 100644 index 19e4023fef04..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/emxccompiler.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from distutils.unixccompiler import UnixCCompiler - -class EMXCCompiler(UnixCCompiler): ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/errors.pyi b/mypy/typeshed/stdlib/@python2/distutils/errors.pyi deleted file mode 100644 index e483362bfbf1..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/errors.pyi +++ /dev/null @@ -1,19 +0,0 @@ -class DistutilsError(Exception): ... -class DistutilsModuleError(DistutilsError): ... -class DistutilsClassError(DistutilsError): ... -class DistutilsGetoptError(DistutilsError): ... -class DistutilsArgError(DistutilsError): ... -class DistutilsFileError(DistutilsError): ... -class DistutilsOptionError(DistutilsError): ... -class DistutilsSetupError(DistutilsError): ... -class DistutilsPlatformError(DistutilsError): ... -class DistutilsExecError(DistutilsError): ... -class DistutilsInternalError(DistutilsError): ... -class DistutilsTemplateError(DistutilsError): ... -class DistutilsByteCompileError(DistutilsError): ... -class CCompilerError(Exception): ... -class PreprocessError(CCompilerError): ... -class CompileError(CCompilerError): ... -class LibError(CCompilerError): ... -class LinkError(CCompilerError): ... -class UnknownFileError(CCompilerError): ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/extension.pyi b/mypy/typeshed/stdlib/@python2/distutils/extension.pyi deleted file mode 100644 index cff84ef59b6b..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/extension.pyi +++ /dev/null @@ -1,19 +0,0 @@ -class Extension: - def __init__( - self, - name: str, - sources: list[str], - include_dirs: list[str] = ..., - define_macros: list[tuple[str, str | None]] = ..., - undef_macros: list[str] = ..., - library_dirs: list[str] = ..., - libraries: list[str] = ..., - runtime_library_dirs: list[str] = ..., - extra_objects: list[str] = ..., - extra_compile_args: list[str] = ..., - extra_link_args: list[str] = ..., - export_symbols: list[str] = ..., - swig_opts: str | None = ..., # undocumented - depends: list[str] = ..., - language: str = ..., - ) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/fancy_getopt.pyi b/mypy/typeshed/stdlib/@python2/distutils/fancy_getopt.pyi deleted file mode 100644 index bf3754aab8ea..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/fancy_getopt.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from typing import Any, Mapping, overload - -_Option = tuple[str, str | None, str] -_GR = tuple[list[str], OptionDummy] - -def fancy_getopt( - options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None -) -> list[str] | _GR: ... -def wrap_text(text: str, width: int) -> list[str]: ... - -class FancyGetopt: - def __init__(self, option_table: list[_Option] | None = ...) -> None: ... - # TODO kinda wrong, `getopt(object=object())` is invalid - @overload - def getopt(self, args: list[str] | None = ...) -> _GR: ... - @overload - def getopt(self, args: list[str] | None, object: Any) -> list[str]: ... - def get_option_order(self) -> list[tuple[str, str]]: ... - def generate_help(self, header: str | None = ...) -> list[str]: ... - -class OptionDummy: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/file_util.pyi b/mypy/typeshed/stdlib/@python2/distutils/file_util.pyi deleted file mode 100644 index a7f24105a678..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/file_util.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from typing import Sequence - -def copy_file( - src: str, - dst: str, - preserve_mode: bool = ..., - preserve_times: bool = ..., - update: bool = ..., - link: str | None = ..., - verbose: bool = ..., - dry_run: bool = ..., -) -> tuple[str, str]: ... -def move_file(src: str, dst: str, verbose: bool = ..., dry_run: bool = ...) -> str: ... -def write_file(filename: str, contents: Sequence[str]) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/filelist.pyi b/mypy/typeshed/stdlib/@python2/distutils/filelist.pyi deleted file mode 100644 index 8fa55d09d265..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/filelist.pyi +++ /dev/null @@ -1 +0,0 @@ -class FileList: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/log.pyi b/mypy/typeshed/stdlib/@python2/distutils/log.pyi deleted file mode 100644 index 668adaab99d1..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/log.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from typing import Any, Text - -DEBUG: int -INFO: int -WARN: int -ERROR: int -FATAL: int - -class Log: - def __init__(self, threshold: int = ...) -> None: ... - def log(self, level: int, msg: Text, *args: Any) -> None: ... - def debug(self, msg: Text, *args: Any) -> None: ... - def info(self, msg: Text, *args: Any) -> None: ... - def warn(self, msg: Text, *args: Any) -> None: ... - def error(self, msg: Text, *args: Any) -> None: ... - def fatal(self, msg: Text, *args: Any) -> None: ... - -def log(level: int, msg: Text, *args: Any) -> None: ... -def debug(msg: Text, *args: Any) -> None: ... -def info(msg: Text, *args: Any) -> None: ... -def warn(msg: Text, *args: Any) -> None: ... -def error(msg: Text, *args: Any) -> None: ... -def fatal(msg: Text, *args: Any) -> None: ... -def set_threshold(level: int) -> int: ... -def set_verbosity(v: int) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/msvccompiler.pyi b/mypy/typeshed/stdlib/@python2/distutils/msvccompiler.pyi deleted file mode 100644 index 80872a6b739f..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/msvccompiler.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from distutils.ccompiler import CCompiler - -class MSVCCompiler(CCompiler): ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/spawn.pyi b/mypy/typeshed/stdlib/@python2/distutils/spawn.pyi deleted file mode 100644 index dda05ad7e85a..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/spawn.pyi +++ /dev/null @@ -1,2 +0,0 @@ -def spawn(cmd: list[str], search_path: bool = ..., verbose: bool = ..., dry_run: bool = ...) -> None: ... -def find_executable(executable: str, path: str | None = ...) -> str | None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/sysconfig.pyi b/mypy/typeshed/stdlib/@python2/distutils/sysconfig.pyi deleted file mode 100644 index 7d9fe7d34de3..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/sysconfig.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from distutils.ccompiler import CCompiler -from typing import Mapping - -PREFIX: str -EXEC_PREFIX: str - -def get_config_var(name: str) -> int | str | None: ... -def get_config_vars(*args: str) -> Mapping[str, int | str]: ... -def get_config_h_filename() -> str: ... -def get_makefile_filename() -> str: ... -def get_python_inc(plat_specific: bool = ..., prefix: str | None = ...) -> str: ... -def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: str | None = ...) -> str: ... -def customize_compiler(compiler: CCompiler) -> None: ... -def set_python_build() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/text_file.pyi b/mypy/typeshed/stdlib/@python2/distutils/text_file.pyi deleted file mode 100644 index 364bcf9ff154..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/text_file.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from typing import IO - -class TextFile: - def __init__( - self, - filename: str | None = ..., - file: IO[str] | None = ..., - *, - strip_comments: bool = ..., - lstrip_ws: bool = ..., - rstrip_ws: bool = ..., - skip_blanks: bool = ..., - join_lines: bool = ..., - collapse_join: bool = ..., - ) -> None: ... - def open(self, filename: str) -> None: ... - def close(self) -> None: ... - def warn(self, msg: str, line: list[int] | tuple[int, int] | int = ...) -> None: ... - def readline(self) -> str | None: ... - def readlines(self) -> list[str]: ... - def unreadline(self, line: str) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/unixccompiler.pyi b/mypy/typeshed/stdlib/@python2/distutils/unixccompiler.pyi deleted file mode 100644 index e1d443471af3..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/unixccompiler.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from distutils.ccompiler import CCompiler - -class UnixCCompiler(CCompiler): ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/util.pyi b/mypy/typeshed/stdlib/@python2/distutils/util.pyi deleted file mode 100644 index 935a695e58db..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/util.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from typing import Any, Callable, Mapping -from typing_extensions import Literal - -def get_platform() -> str: ... -def convert_path(pathname: str) -> str: ... -def change_root(new_root: str, pathname: str) -> str: ... -def check_environ() -> None: ... -def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... -def split_quoted(s: str) -> list[str]: ... -def execute( - func: Callable[..., None], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... -) -> None: ... -def strtobool(val: str) -> Literal[0, 1]: ... -def byte_compile( - py_files: list[str], - optimize: int = ..., - force: bool = ..., - prefix: str | None = ..., - base_dir: str | None = ..., - verbose: bool = ..., - dry_run: bool = ..., - direct: bool | None = ..., -) -> None: ... -def rfc822_escape(header: str) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/distutils/version.pyi b/mypy/typeshed/stdlib/@python2/distutils/version.pyi deleted file mode 100644 index 0e37a3a1a90c..000000000000 --- a/mypy/typeshed/stdlib/@python2/distutils/version.pyi +++ /dev/null @@ -1,33 +0,0 @@ -from _typeshed import Self -from abc import abstractmethod -from typing import Pattern, Text, TypeVar - -_T = TypeVar("_T", bound=Version) - -class Version: - @abstractmethod - def __init__(self, vstring: Text | None = ...) -> None: ... - @abstractmethod - def parse(self: Self, vstring: Text) -> Self: ... - @abstractmethod - def __str__(self) -> str: ... - @abstractmethod - def __cmp__(self: _T, other: _T | str) -> bool: ... - -class StrictVersion(Version): - version_re: Pattern[str] - version: tuple[int, int, int] - prerelease: tuple[Text, int] | None - def __init__(self, vstring: Text | None = ...) -> None: ... - def parse(self: Self, vstring: Text) -> Self: ... - def __str__(self) -> str: ... # noqa: Y029 - def __cmp__(self: _T, other: _T | str) -> bool: ... - -class LooseVersion(Version): - component_re: Pattern[str] - vstring: Text - version: tuple[Text | int, ...] - def __init__(self, vstring: Text | None = ...) -> None: ... - def parse(self: Self, vstring: Text) -> Self: ... - def __str__(self) -> str: ... # noqa: Y029 - def __cmp__(self: _T, other: _T | str) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/doctest.pyi b/mypy/typeshed/stdlib/@python2/doctest.pyi deleted file mode 100644 index 9f95d122eea5..000000000000 --- a/mypy/typeshed/stdlib/@python2/doctest.pyi +++ /dev/null @@ -1,209 +0,0 @@ -import types -import unittest -from typing import Any, Callable, NamedTuple - -class TestResults(NamedTuple): - failed: int - attempted: int - -OPTIONFLAGS_BY_NAME: dict[str, int] - -def register_optionflag(name: str) -> int: ... - -DONT_ACCEPT_TRUE_FOR_1: int -DONT_ACCEPT_BLANKLINE: int -NORMALIZE_WHITESPACE: int -ELLIPSIS: int -SKIP: int -IGNORE_EXCEPTION_DETAIL: int - -COMPARISON_FLAGS: int - -REPORT_UDIFF: int -REPORT_CDIFF: int -REPORT_NDIFF: int -REPORT_ONLY_FIRST_FAILURE: int -REPORTING_FLAGS: int - -BLANKLINE_MARKER: str -ELLIPSIS_MARKER: str - -class Example: - source: str - want: str - exc_msg: str | None - lineno: int - indent: int - options: dict[int, bool] - def __init__( - self, - source: str, - want: str, - exc_msg: str | None = ..., - lineno: int = ..., - indent: int = ..., - options: dict[int, bool] | None = ..., - ) -> None: ... - def __hash__(self) -> int: ... - -class DocTest: - examples: list[Example] - globs: dict[str, Any] - name: str - filename: str | None - lineno: int | None - docstring: str | None - def __init__( - self, - examples: list[Example], - globs: dict[str, Any], - name: str, - filename: str | None, - lineno: int | None, - docstring: str | None, - ) -> None: ... - def __hash__(self) -> int: ... - def __lt__(self, other: DocTest) -> bool: ... - -class DocTestParser: - def parse(self, string: str, name: str = ...) -> list[str | Example]: ... - def get_doctest(self, string: str, globs: dict[str, Any], name: str, filename: str | None, lineno: int | None) -> DocTest: ... - def get_examples(self, string: str, name: str = ...) -> list[Example]: ... - -class DocTestFinder: - def __init__( - self, verbose: bool = ..., parser: DocTestParser = ..., recurse: bool = ..., exclude_empty: bool = ... - ) -> None: ... - def find( - self, - obj: object, - name: str | None = ..., - module: None | bool | types.ModuleType = ..., - globs: dict[str, Any] | None = ..., - extraglobs: dict[str, Any] | None = ..., - ) -> list[DocTest]: ... - -_Out = Callable[[str], Any] -_ExcInfo = tuple[type[BaseException], BaseException, types.TracebackType] - -class DocTestRunner: - DIVIDER: str - optionflags: int - original_optionflags: int - tries: int - failures: int - test: DocTest - def __init__(self, checker: OutputChecker | None = ..., verbose: bool | None = ..., optionflags: int = ...) -> None: ... - def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ... - def report_success(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... - def report_failure(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... - def report_unexpected_exception(self, out: _Out, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ... - def run( - self, test: DocTest, compileflags: int | None = ..., out: _Out | None = ..., clear_globs: bool = ... - ) -> TestResults: ... - def summarize(self, verbose: bool | None = ...) -> TestResults: ... - def merge(self, other: DocTestRunner) -> None: ... - -class OutputChecker: - def check_output(self, want: str, got: str, optionflags: int) -> bool: ... - def output_difference(self, example: Example, got: str, optionflags: int) -> str: ... - -class DocTestFailure(Exception): - test: DocTest - example: Example - got: str - def __init__(self, test: DocTest, example: Example, got: str) -> None: ... - -class UnexpectedException(Exception): - test: DocTest - example: Example - exc_info: _ExcInfo - def __init__(self, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ... - -class DebugRunner(DocTestRunner): ... - -master: DocTestRunner | None - -def testmod( - m: types.ModuleType | None = ..., - name: str | None = ..., - globs: dict[str, Any] | None = ..., - verbose: bool | None = ..., - report: bool = ..., - optionflags: int = ..., - extraglobs: dict[str, Any] | None = ..., - raise_on_error: bool = ..., - exclude_empty: bool = ..., -) -> TestResults: ... -def testfile( - filename: str, - module_relative: bool = ..., - name: str | None = ..., - package: None | str | types.ModuleType = ..., - globs: dict[str, Any] | None = ..., - verbose: bool | None = ..., - report: bool = ..., - optionflags: int = ..., - extraglobs: dict[str, Any] | None = ..., - raise_on_error: bool = ..., - parser: DocTestParser = ..., - encoding: str | None = ..., -) -> TestResults: ... -def run_docstring_examples( - f: object, globs: dict[str, Any], verbose: bool = ..., name: str = ..., compileflags: int | None = ..., optionflags: int = ... -) -> None: ... -def set_unittest_reportflags(flags: int) -> int: ... - -class DocTestCase(unittest.TestCase): - def __init__( - self, - test: DocTest, - optionflags: int = ..., - setUp: Callable[[DocTest], Any] | None = ..., - tearDown: Callable[[DocTest], Any] | None = ..., - checker: OutputChecker | None = ..., - ) -> None: ... - def setUp(self) -> None: ... - def tearDown(self) -> None: ... - def runTest(self) -> None: ... - def format_failure(self, err: str) -> str: ... - def debug(self) -> None: ... - def id(self) -> str: ... - def __hash__(self) -> int: ... - def shortDescription(self) -> str: ... - -class SkipDocTestCase(DocTestCase): - def __init__(self, module: types.ModuleType) -> None: ... - def setUp(self) -> None: ... - def test_skip(self) -> None: ... - def shortDescription(self) -> str: ... - -_DocTestSuite = unittest.TestSuite - -def DocTestSuite( - module: None | str | types.ModuleType = ..., - globs: dict[str, Any] | None = ..., - extraglobs: dict[str, Any] | None = ..., - test_finder: DocTestFinder | None = ..., - **options: Any, -) -> _DocTestSuite: ... - -class DocFileCase(DocTestCase): - def id(self) -> str: ... - def format_failure(self, err: str) -> str: ... - -def DocFileTest( - path: str, - module_relative: bool = ..., - package: None | str | types.ModuleType = ..., - globs: dict[str, Any] | None = ..., - parser: DocTestParser = ..., - encoding: str | None = ..., - **options: Any, -) -> DocFileCase: ... -def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... -def script_from_examples(s: str) -> str: ... -def testsource(module: None | str | types.ModuleType, name: str) -> str: ... -def debug_src(src: str, pm: bool = ..., globs: dict[str, Any] | None = ...) -> None: ... -def debug_script(src: str, pm: bool = ..., globs: dict[str, Any] | None = ...) -> None: ... -def debug(module: None | str | types.ModuleType, name: str, pm: bool = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/dummy_thread.pyi b/mypy/typeshed/stdlib/@python2/dummy_thread.pyi deleted file mode 100644 index 1bd324b7eaaf..000000000000 --- a/mypy/typeshed/stdlib/@python2/dummy_thread.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from typing import Any, Callable, NoReturn - -class error(Exception): - def __init__(self, *args: Any) -> None: ... - -def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... -def exit() -> NoReturn: ... -def get_ident() -> int: ... -def allocate_lock() -> LockType: ... -def stack_size(size: int | None = ...) -> int: ... - -class LockType(object): - locked_status: bool - def __init__(self) -> None: ... - def acquire(self, waitflag: bool | None = ...) -> bool: ... - def __enter__(self, waitflag: bool | None = ...) -> bool: ... - def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ... - def release(self) -> bool: ... - def locked(self) -> bool: ... - -def interrupt_main() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/dummy_threading.pyi b/mypy/typeshed/stdlib/@python2/dummy_threading.pyi deleted file mode 100644 index 757cb8d4bd4c..000000000000 --- a/mypy/typeshed/stdlib/@python2/dummy_threading.pyi +++ /dev/null @@ -1,2 +0,0 @@ -from _dummy_threading import * -from _dummy_threading import __all__ as __all__ diff --git a/mypy/typeshed/stdlib/@python2/email/MIMEText.pyi b/mypy/typeshed/stdlib/@python2/email/MIMEText.pyi deleted file mode 100644 index 3b059778aa66..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/MIMEText.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email.mime.nonmultipart import MIMENonMultipart - -class MIMEText(MIMENonMultipart): - def __init__(self, _text, _subtype=..., _charset=...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/__init__.pyi b/mypy/typeshed/stdlib/@python2/email/__init__.pyi deleted file mode 100644 index 83d9895cab4d..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/__init__.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import IO, AnyStr - -def message_from_string(s: AnyStr, *args, **kwargs): ... -def message_from_bytes(s: str, *args, **kwargs): ... -def message_from_file(fp: IO[AnyStr], *args, **kwargs): ... -def message_from_binary_file(fp: IO[str], *args, **kwargs): ... diff --git a/mypy/typeshed/stdlib/@python2/email/_parseaddr.pyi b/mypy/typeshed/stdlib/@python2/email/_parseaddr.pyi deleted file mode 100644 index 74ea3a6e4a69..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/_parseaddr.pyi +++ /dev/null @@ -1,40 +0,0 @@ -from typing import Any - -def parsedate_tz(data): ... -def parsedate(data): ... -def mktime_tz(data): ... -def quote(str): ... - -class AddrlistClass: - specials: Any - pos: Any - LWS: Any - CR: Any - FWS: Any - atomends: Any - phraseends: Any - field: Any - commentlist: Any - def __init__(self, field): ... - def gotonext(self): ... - def getaddrlist(self): ... - def getaddress(self): ... - def getrouteaddr(self): ... - def getaddrspec(self): ... - def getdomain(self): ... - def getdelimited(self, beginchar, endchars, allowcomments: bool = ...): ... - def getquote(self): ... - def getcomment(self): ... - def getdomainliteral(self): ... - def getatom(self, atomends: Any | None = ...): ... - def getphraselist(self): ... - -class AddressList(AddrlistClass): - addresslist: Any - def __init__(self, field): ... - def __len__(self): ... - def __add__(self, other): ... - def __iadd__(self, other): ... - def __sub__(self, other): ... - def __isub__(self, other): ... - def __getitem__(self, index): ... diff --git a/mypy/typeshed/stdlib/@python2/email/base64mime.pyi b/mypy/typeshed/stdlib/@python2/email/base64mime.pyi deleted file mode 100644 index fc6552974e60..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/base64mime.pyi +++ /dev/null @@ -1,11 +0,0 @@ -def base64_len(s: bytes) -> int: ... -def header_encode(header, charset=..., keep_eols=..., maxlinelen=..., eol=...): ... -def encode(s, binary=..., maxlinelen=..., eol=...): ... - -body_encode = encode -encodestring = encode - -def decode(s, convert_eols=...): ... - -body_decode = decode -decodestring = decode diff --git a/mypy/typeshed/stdlib/@python2/email/charset.pyi b/mypy/typeshed/stdlib/@python2/email/charset.pyi deleted file mode 100644 index 88b5f88d1843..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/charset.pyi +++ /dev/null @@ -1,26 +0,0 @@ -def add_charset(charset, header_enc=..., body_enc=..., output_charset=...) -> None: ... -def add_alias(alias, canonical) -> None: ... -def add_codec(charset, codecname) -> None: ... - -QP: int # undocumented -BASE64: int # undocumented -SHORTEST: int # undocumented - -class Charset: - input_charset = ... - header_encoding = ... - body_encoding = ... - output_charset = ... - input_codec = ... - output_codec = ... - def __init__(self, input_charset=...) -> None: ... - def __eq__(self, other): ... - def __ne__(self, other): ... - def get_body_encoding(self): ... - def convert(self, s): ... - def to_splittable(self, s): ... - def from_splittable(self, ustr, to_output: bool = ...): ... - def get_output_charset(self): ... - def encoded_header_len(self, s): ... - def header_encode(self, s, convert: bool = ...): ... - def body_encode(self, s, convert: bool = ...): ... diff --git a/mypy/typeshed/stdlib/@python2/email/encoders.pyi b/mypy/typeshed/stdlib/@python2/email/encoders.pyi deleted file mode 100644 index 5670cbaf08ed..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/encoders.pyi +++ /dev/null @@ -1,4 +0,0 @@ -def encode_base64(msg) -> None: ... -def encode_quopri(msg) -> None: ... -def encode_7or8bit(msg) -> None: ... -def encode_noop(msg) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/feedparser.pyi b/mypy/typeshed/stdlib/@python2/email/feedparser.pyi deleted file mode 100644 index fb2aa9f5ff1b..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/feedparser.pyi +++ /dev/null @@ -1,17 +0,0 @@ -class BufferedSubFile: - def __init__(self) -> None: ... - def push_eof_matcher(self, pred) -> None: ... - def pop_eof_matcher(self): ... - def close(self) -> None: ... - def readline(self): ... - def unreadline(self, line) -> None: ... - def push(self, data): ... - def pushlines(self, lines) -> None: ... - def is_closed(self): ... - def __iter__(self): ... - def next(self): ... - -class FeedParser: - def __init__(self, _factory=...) -> None: ... - def feed(self, data) -> None: ... - def close(self): ... diff --git a/mypy/typeshed/stdlib/@python2/email/generator.pyi b/mypy/typeshed/stdlib/@python2/email/generator.pyi deleted file mode 100644 index a5f5983b48e6..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/generator.pyi +++ /dev/null @@ -1,8 +0,0 @@ -class Generator: - def __init__(self, outfp, mangle_from_: bool = ..., maxheaderlen: int = ...) -> None: ... - def write(self, s) -> None: ... - def flatten(self, msg, unixfrom: bool = ...) -> None: ... - def clone(self, fp): ... - -class DecodedGenerator(Generator): - def __init__(self, outfp, mangle_from_: bool = ..., maxheaderlen: int = ..., fmt=...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/header.pyi b/mypy/typeshed/stdlib/@python2/email/header.pyi deleted file mode 100644 index 429ee16d8917..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/header.pyi +++ /dev/null @@ -1,10 +0,0 @@ -def decode_header(header): ... -def make_header(decoded_seq, maxlinelen=..., header_name=..., continuation_ws=...): ... - -class Header: - def __init__(self, s=..., charset=..., maxlinelen=..., header_name=..., continuation_ws=..., errors=...) -> None: ... - def __unicode__(self): ... - def __eq__(self, other): ... - def __ne__(self, other): ... - def append(self, s, charset=..., errors=...) -> None: ... - def encode(self, splitchars=...): ... diff --git a/mypy/typeshed/stdlib/@python2/email/iterators.pyi b/mypy/typeshed/stdlib/@python2/email/iterators.pyi deleted file mode 100644 index 5002644117a4..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/iterators.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from typing import Any, Generator - -def walk(self) -> Generator[Any, Any, Any]: ... -def body_line_iterator(msg, decode: bool = ...) -> Generator[Any, Any, Any]: ... -def typed_subpart_iterator(msg, maintype=..., subtype=...) -> Generator[Any, Any, Any]: ... diff --git a/mypy/typeshed/stdlib/@python2/email/message.pyi b/mypy/typeshed/stdlib/@python2/email/message.pyi deleted file mode 100644 index 642bba7c0102..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/message.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from typing import Any, Generator - -class Message: - preamble = ... - epilogue = ... - defects = ... - def __init__(self): ... - def as_string(self, unixfrom=...): ... - def is_multipart(self) -> bool: ... - def set_unixfrom(self, unixfrom) -> None: ... - def get_unixfrom(self): ... - def attach(self, payload) -> None: ... - def get_payload(self, i=..., decode: bool = ...): ... - def set_payload(self, payload, charset=...) -> None: ... - def set_charset(self, charset): ... - def get_charset(self): ... - def __len__(self): ... - def __getitem__(self, name): ... - def __setitem__(self, name, val) -> None: ... - def __delitem__(self, name) -> None: ... - def __contains__(self, name): ... - def has_key(self, name) -> bool: ... - def keys(self): ... - def values(self): ... - def items(self): ... - def get(self, name, failobj=...): ... - def get_all(self, name, failobj=...): ... - def add_header(self, _name, _value, **_params) -> None: ... - def replace_header(self, _name, _value) -> None: ... - def get_content_type(self): ... - def get_content_maintype(self): ... - def get_content_subtype(self): ... - def get_default_type(self): ... - def set_default_type(self, ctype) -> None: ... - def get_params(self, failobj=..., header=..., unquote: bool = ...): ... - def get_param(self, param, failobj=..., header=..., unquote: bool = ...): ... - def set_param(self, param, value, header=..., requote: bool = ..., charset=..., language=...) -> None: ... - def del_param(self, param, header=..., requote: bool = ...): ... - def set_type(self, type, header=..., requote: bool = ...): ... - def get_filename(self, failobj=...): ... - def get_boundary(self, failobj=...): ... - def set_boundary(self, boundary) -> None: ... - def get_content_charset(self, failobj=...): ... - def get_charsets(self, failobj=...): ... - def walk(self) -> Generator[Any, Any, Any]: ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/__init__.pyi b/mypy/typeshed/stdlib/@python2/email/mime/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/email/mime/application.pyi b/mypy/typeshed/stdlib/@python2/email/mime/application.pyi deleted file mode 100644 index cb8c281261fe..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/application.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from email.mime.nonmultipart import MIMENonMultipart -from typing import Callable, Union - -_ParamsType = Union[str, None, tuple[str, str | None, str]] - -class MIMEApplication(MIMENonMultipart): - def __init__( - self, _data: bytes, _subtype: str = ..., _encoder: Callable[[MIMEApplication], None] = ..., **_params: _ParamsType - ) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/audio.pyi b/mypy/typeshed/stdlib/@python2/email/mime/audio.pyi deleted file mode 100644 index 5f11f8d79008..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/audio.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email.mime.nonmultipart import MIMENonMultipart - -class MIMEAudio(MIMENonMultipart): - def __init__(self, _audiodata, _subtype=..., _encoder=..., **_params) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/base.pyi b/mypy/typeshed/stdlib/@python2/email/mime/base.pyi deleted file mode 100644 index 4bde4f073395..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/base.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email import message - -class MIMEBase(message.Message): - def __init__(self, _maintype, _subtype, **_params) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/image.pyi b/mypy/typeshed/stdlib/@python2/email/mime/image.pyi deleted file mode 100644 index 3fe8249d6ac8..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/image.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email.mime.nonmultipart import MIMENonMultipart - -class MIMEImage(MIMENonMultipart): - def __init__(self, _imagedata, _subtype=..., _encoder=..., **_params) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/message.pyi b/mypy/typeshed/stdlib/@python2/email/mime/message.pyi deleted file mode 100644 index 9d6fafa2a19b..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/message.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email.mime.nonmultipart import MIMENonMultipart - -class MIMEMessage(MIMENonMultipart): - def __init__(self, _msg, _subtype=...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/multipart.pyi b/mypy/typeshed/stdlib/@python2/email/mime/multipart.pyi deleted file mode 100644 index 0a7d3fa8acb0..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/multipart.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email.mime.base import MIMEBase - -class MIMEMultipart(MIMEBase): - def __init__(self, _subtype=..., boundary=..., _subparts=..., **_params) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/nonmultipart.pyi b/mypy/typeshed/stdlib/@python2/email/mime/nonmultipart.pyi deleted file mode 100644 index 04d130e3da88..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/nonmultipart.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email.mime.base import MIMEBase - -class MIMENonMultipart(MIMEBase): - def attach(self, payload): ... diff --git a/mypy/typeshed/stdlib/@python2/email/mime/text.pyi b/mypy/typeshed/stdlib/@python2/email/mime/text.pyi deleted file mode 100644 index 3b059778aa66..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/mime/text.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from email.mime.nonmultipart import MIMENonMultipart - -class MIMEText(MIMENonMultipart): - def __init__(self, _text, _subtype=..., _charset=...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/email/parser.pyi b/mypy/typeshed/stdlib/@python2/email/parser.pyi deleted file mode 100644 index 4f2282834ca5..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/parser.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from .feedparser import FeedParser as FeedParser # not in __all__ but listed in documentation - -class Parser: - def __init__(self, *args, **kws) -> None: ... - def parse(self, fp, headersonly: bool = ...): ... - def parsestr(self, text, headersonly: bool = ...): ... - -class HeaderParser(Parser): - def parse(self, fp, headersonly: bool = ...): ... - def parsestr(self, text, headersonly: bool = ...): ... diff --git a/mypy/typeshed/stdlib/@python2/email/quoprimime.pyi b/mypy/typeshed/stdlib/@python2/email/quoprimime.pyi deleted file mode 100644 index 3f2963c06e6d..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/quoprimime.pyi +++ /dev/null @@ -1,18 +0,0 @@ -def header_quopri_check(c): ... -def body_quopri_check(c): ... -def header_quopri_len(s): ... -def body_quopri_len(str): ... -def unquote(s): ... -def quote(c): ... -def header_encode(header, charset: str = ..., keep_eols: bool = ..., maxlinelen: int = ..., eol=...): ... -def encode(body, binary: bool = ..., maxlinelen: int = ..., eol=...): ... - -body_encode = encode -encodestring = encode - -def decode(encoded, eol=...): ... - -body_decode = decode -decodestring = decode - -def header_decode(s): ... diff --git a/mypy/typeshed/stdlib/@python2/email/utils.pyi b/mypy/typeshed/stdlib/@python2/email/utils.pyi deleted file mode 100644 index 0d185134c9d7..000000000000 --- a/mypy/typeshed/stdlib/@python2/email/utils.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from email._parseaddr import ( - AddressList as _AddressList, - mktime_tz as mktime_tz, - parsedate as _parsedate, - parsedate_tz as _parsedate_tz, -) -from quopri import decodestring as _qdecode -from typing import Any - -def formataddr(pair): ... -def getaddresses(fieldvalues): ... -def formatdate(timeval: Any | None = ..., localtime: bool = ..., usegmt: bool = ...): ... -def make_msgid(idstring: Any | None = ...): ... -def parsedate(data): ... -def parsedate_tz(data): ... -def parseaddr(addr): ... -def unquote(str): ... -def decode_rfc2231(s): ... -def encode_rfc2231(s, charset: Any | None = ..., language: Any | None = ...): ... -def decode_params(params): ... -def collapse_rfc2231_value(value, errors=..., fallback_charset=...): ... diff --git a/mypy/typeshed/stdlib/@python2/encodings/__init__.pyi b/mypy/typeshed/stdlib/@python2/encodings/__init__.pyi deleted file mode 100644 index d6f4389bc820..000000000000 --- a/mypy/typeshed/stdlib/@python2/encodings/__init__.pyi +++ /dev/null @@ -1,7 +0,0 @@ -import codecs -from typing import Any - -def search_function(encoding: str) -> codecs.CodecInfo: ... - -# Explicitly mark this package as incomplete. -def __getattr__(name: str) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/encodings/utf_8.pyi b/mypy/typeshed/stdlib/@python2/encodings/utf_8.pyi deleted file mode 100644 index 349b61432eab..000000000000 --- a/mypy/typeshed/stdlib/@python2/encodings/utf_8.pyi +++ /dev/null @@ -1,15 +0,0 @@ -import codecs -from typing import Text - -class IncrementalEncoder(codecs.IncrementalEncoder): - def encode(self, input: Text, final: bool = ...) -> bytes: ... - -class IncrementalDecoder(codecs.BufferedIncrementalDecoder): - def _buffer_decode(self, input: bytes, errors: str, final: bool) -> tuple[Text, int]: ... - -class StreamWriter(codecs.StreamWriter): ... -class StreamReader(codecs.StreamReader): ... - -def getregentry() -> codecs.CodecInfo: ... -def encode(input: Text, errors: Text = ...) -> bytes: ... -def decode(input: bytes, errors: Text = ...) -> Text: ... diff --git a/mypy/typeshed/stdlib/@python2/ensurepip/__init__.pyi b/mypy/typeshed/stdlib/@python2/ensurepip/__init__.pyi deleted file mode 100644 index 60946e7cf35a..000000000000 --- a/mypy/typeshed/stdlib/@python2/ensurepip/__init__.pyi +++ /dev/null @@ -1,9 +0,0 @@ -def version() -> str: ... -def bootstrap( - root: str | None = ..., - upgrade: bool = ..., - user: bool = ..., - altinstall: bool = ..., - default_pip: bool = ..., - verbosity: int = ..., -) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/errno.pyi b/mypy/typeshed/stdlib/@python2/errno.pyi deleted file mode 100644 index b053604fc33a..000000000000 --- a/mypy/typeshed/stdlib/@python2/errno.pyi +++ /dev/null @@ -1,137 +0,0 @@ -from typing import Mapping - -errorcode: Mapping[int, str] - -EPERM: int -ENOENT: int -ESRCH: int -EINTR: int -EIO: int -ENXIO: int -E2BIG: int -ENOEXEC: int -EBADF: int -ECHILD: int -EAGAIN: int -ENOMEM: int -EACCES: int -EFAULT: int -ENOTBLK: int -EBUSY: int -EEXIST: int -EXDEV: int -ENODEV: int -ENOTDIR: int -EISDIR: int -EINVAL: int -ENFILE: int -EMFILE: int -ENOTTY: int -ETXTBSY: int -EFBIG: int -ENOSPC: int -ESPIPE: int -EROFS: int -EMLINK: int -EPIPE: int -EDOM: int -ERANGE: int -EDEADLCK: int -ENAMETOOLONG: int -ENOLCK: int -ENOSYS: int -ENOTEMPTY: int -ELOOP: int -EWOULDBLOCK: int -ENOMSG: int -EIDRM: int -ECHRNG: int -EL2NSYNC: int -EL3HLT: int -EL3RST: int -ELNRNG: int -EUNATCH: int -ENOCSI: int -EL2HLT: int -EBADE: int -EBADR: int -EXFULL: int -ENOANO: int -EBADRQC: int -EBADSLT: int -EDEADLOCK: int -EBFONT: int -ENOSTR: int -ENODATA: int -ETIME: int -ENOSR: int -ENONET: int -ENOPKG: int -EREMOTE: int -ENOLINK: int -EADV: int -ESRMNT: int -ECOMM: int -EPROTO: int -EMULTIHOP: int -EDOTDOT: int -EBADMSG: int -EOVERFLOW: int -ENOTUNIQ: int -EBADFD: int -EREMCHG: int -ELIBACC: int -ELIBBAD: int -ELIBSCN: int -ELIBMAX: int -ELIBEXEC: int -EILSEQ: int -ERESTART: int -ESTRPIPE: int -EUSERS: int -ENOTSOCK: int -EDESTADDRREQ: int -EMSGSIZE: int -EPROTOTYPE: int -ENOPROTOOPT: int -EPROTONOSUPPORT: int -ESOCKTNOSUPPORT: int -ENOTSUP: int -EOPNOTSUPP: int -EPFNOSUPPORT: int -EAFNOSUPPORT: int -EADDRINUSE: int -EADDRNOTAVAIL: int -ENETDOWN: int -ENETUNREACH: int -ENETRESET: int -ECONNABORTED: int -ECONNRESET: int -ENOBUFS: int -EISCONN: int -ENOTCONN: int -ESHUTDOWN: int -ETOOMANYREFS: int -ETIMEDOUT: int -ECONNREFUSED: int -EHOSTDOWN: int -EHOSTUNREACH: int -EALREADY: int -EINPROGRESS: int -ESTALE: int -EUCLEAN: int -ENOTNAM: int -ENAVAIL: int -EISNAM: int -EREMOTEIO: int -EDQUOT: int -ECANCELED: int # undocumented -EKEYEXPIRED: int # undocumented -EKEYREJECTED: int # undocumented -EKEYREVOKED: int # undocumented -EMEDIUMTYPE: int # undocumented -ENOKEY: int # undocumented -ENOMEDIUM: int # undocumented -ENOTRECOVERABLE: int # undocumented -EOWNERDEAD: int # undocumented -ERFKILL: int # undocumented diff --git a/mypy/typeshed/stdlib/@python2/exceptions.pyi b/mypy/typeshed/stdlib/@python2/exceptions.pyi deleted file mode 100644 index fbad89750731..000000000000 --- a/mypy/typeshed/stdlib/@python2/exceptions.pyi +++ /dev/null @@ -1,50 +0,0 @@ -from __builtin__ import ( - ArithmeticError as ArithmeticError, - AssertionError as AssertionError, - AttributeError as AttributeError, - BaseException as BaseException, - BufferError as BufferError, - BytesWarning as BytesWarning, - DeprecationWarning as DeprecationWarning, - EnvironmentError as EnvironmentError, - EOFError as EOFError, - Exception as Exception, - FloatingPointError as FloatingPointError, - FutureWarning as FutureWarning, - GeneratorExit as GeneratorExit, - ImportError as ImportError, - ImportWarning as ImportWarning, - IndentationError as IndentationError, - IndexError as IndexError, - IOError as IOError, - KeyboardInterrupt as KeyboardInterrupt, - KeyError as KeyError, - LookupError as LookupError, - MemoryError as MemoryError, - NameError as NameError, - NotImplementedError as NotImplementedError, - OSError as OSError, - OverflowError as OverflowError, - PendingDeprecationWarning as PendingDeprecationWarning, - ReferenceError as ReferenceError, - RuntimeError as RuntimeError, - RuntimeWarning as RuntimeWarning, - StandardError as StandardError, - StopIteration as StopIteration, - SyntaxError as SyntaxError, - SyntaxWarning as SyntaxWarning, - SystemError as SystemError, - SystemExit as SystemExit, - TabError as TabError, - TypeError as TypeError, - UnboundLocalError as UnboundLocalError, - UnicodeDecodeError as UnicodeDecodeError, - UnicodeEncodeError as UnicodeEncodeError, - UnicodeError as UnicodeError, - UnicodeTranslateError as UnicodeTranslateError, - UnicodeWarning as UnicodeWarning, - UserWarning as UserWarning, - ValueError as ValueError, - Warning as Warning, - ZeroDivisionError as ZeroDivisionError, -) diff --git a/mypy/typeshed/stdlib/@python2/fcntl.pyi b/mypy/typeshed/stdlib/@python2/fcntl.pyi deleted file mode 100644 index 0d9d598ab7c5..000000000000 --- a/mypy/typeshed/stdlib/@python2/fcntl.pyi +++ /dev/null @@ -1,83 +0,0 @@ -import sys -from _typeshed import FileDescriptorLike -from typing import Any - -if sys.platform != "win32": - FASYNC: int - FD_CLOEXEC: int - - DN_ACCESS: int - DN_ATTRIB: int - DN_CREATE: int - DN_DELETE: int - DN_MODIFY: int - DN_MULTISHOT: int - DN_RENAME: int - F_DUPFD: int - F_EXLCK: int - F_GETFD: int - F_GETFL: int - F_GETLEASE: int - F_GETLK: int - F_GETLK64: int - F_GETOWN: int - F_GETSIG: int - F_NOTIFY: int - F_RDLCK: int - F_SETFD: int - F_SETFL: int - F_SETLEASE: int - F_SETLK: int - F_SETLK64: int - F_SETLKW: int - F_SETLKW64: int - F_SETOWN: int - F_SETSIG: int - F_SHLCK: int - F_UNLCK: int - F_WRLCK: int - I_ATMARK: int - I_CANPUT: int - I_CKBAND: int - I_FDINSERT: int - I_FIND: int - I_FLUSH: int - I_FLUSHBAND: int - I_GETBAND: int - I_GETCLTIME: int - I_GETSIG: int - I_GRDOPT: int - I_GWROPT: int - I_LINK: int - I_LIST: int - I_LOOK: int - I_NREAD: int - I_PEEK: int - I_PLINK: int - I_POP: int - I_PUNLINK: int - I_PUSH: int - I_RECVFD: int - I_SENDFD: int - I_SETCLTIME: int - I_SETSIG: int - I_SRDOPT: int - I_STR: int - I_SWROPT: int - I_UNLINK: int - LOCK_EX: int - LOCK_MAND: int - LOCK_NB: int - LOCK_READ: int - LOCK_RW: int - LOCK_SH: int - LOCK_UN: int - LOCK_WRITE: int - - # TODO All these return either int or bytes depending on the value of - # cmd (not on the type of arg). - def fcntl(fd: FileDescriptorLike, op: int, arg: int | bytes = ...) -> Any: ... - # TODO: arg: int or read-only buffer interface or read-write buffer interface - def ioctl(fd: FileDescriptorLike, op: int, arg: int | bytes = ..., mutate_flag: bool = ...) -> Any: ... - def flock(fd: FileDescriptorLike, op: int) -> None: ... - def lockf(fd: FileDescriptorLike, op: int, length: int = ..., start: int = ..., whence: int = ...) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/filecmp.pyi b/mypy/typeshed/stdlib/@python2/filecmp.pyi deleted file mode 100644 index c50faedf2fa1..000000000000 --- a/mypy/typeshed/stdlib/@python2/filecmp.pyi +++ /dev/null @@ -1,40 +0,0 @@ -from typing import AnyStr, Callable, Generic, Iterable, Sequence, Text - -DEFAULT_IGNORES: list[str] - -def cmp(f1: bytes | Text, f2: bytes | Text, shallow: int | bool = ...) -> bool: ... -def cmpfiles( - a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: int | bool = ... -) -> tuple[list[AnyStr], list[AnyStr], list[AnyStr]]: ... - -class dircmp(Generic[AnyStr]): - def __init__( - self, a: AnyStr, b: AnyStr, ignore: Sequence[AnyStr] | None = ..., hide: Sequence[AnyStr] | None = ... - ) -> None: ... - left: AnyStr - right: AnyStr - hide: Sequence[AnyStr] - ignore: Sequence[AnyStr] - # These properties are created at runtime by __getattr__ - subdirs: dict[AnyStr, dircmp[AnyStr]] - same_files: list[AnyStr] - diff_files: list[AnyStr] - funny_files: list[AnyStr] - common_dirs: list[AnyStr] - common_files: list[AnyStr] - common_funny: list[AnyStr] - common: list[AnyStr] - left_only: list[AnyStr] - right_only: list[AnyStr] - left_list: list[AnyStr] - right_list: list[AnyStr] - def report(self) -> None: ... - def report_partial_closure(self) -> None: ... - def report_full_closure(self) -> None: ... - methodmap: dict[str, Callable[[], None]] - def phase0(self) -> None: ... - def phase1(self) -> None: ... - def phase2(self) -> None: ... - def phase3(self) -> None: ... - def phase4(self) -> None: ... - def phase4_closure(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/fileinput.pyi b/mypy/typeshed/stdlib/@python2/fileinput.pyi deleted file mode 100644 index 316643fcf15f..000000000000 --- a/mypy/typeshed/stdlib/@python2/fileinput.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Text - -def input( - files: Text | Iterable[Text] | None = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[Text, str], IO[AnyStr]] = ..., -) -> FileInput[AnyStr]: ... -def close() -> None: ... -def nextfile() -> None: ... -def filename() -> str: ... -def lineno() -> int: ... -def filelineno() -> int: ... -def fileno() -> int: ... -def isfirstline() -> bool: ... -def isstdin() -> bool: ... - -class FileInput(Iterable[AnyStr], Generic[AnyStr]): - def __init__( - self, - files: None | Text | Iterable[Text] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[Text, str], IO[AnyStr]] = ..., - ) -> None: ... - def __del__(self) -> None: ... - def close(self) -> None: ... - def __iter__(self) -> Iterator[AnyStr]: ... - def __next__(self) -> AnyStr: ... - def __getitem__(self, i: int) -> AnyStr: ... - def nextfile(self) -> None: ... - def readline(self) -> AnyStr: ... - def filename(self) -> str: ... - def lineno(self) -> int: ... - def filelineno(self) -> int: ... - def fileno(self) -> int: ... - def isfirstline(self) -> bool: ... - def isstdin(self) -> bool: ... - -def hook_compressed(filename: Text, mode: str) -> IO[Any]: ... -def hook_encoded(encoding: str) -> Callable[[Text, str], IO[Any]]: ... diff --git a/mypy/typeshed/stdlib/@python2/fnmatch.pyi b/mypy/typeshed/stdlib/@python2/fnmatch.pyi deleted file mode 100644 index 942a52bbac9a..000000000000 --- a/mypy/typeshed/stdlib/@python2/fnmatch.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import AnyStr, Iterable - -_EitherStr = str | unicode - -def fnmatch(filename: _EitherStr, pattern: _EitherStr) -> bool: ... -def fnmatchcase(filename: _EitherStr, pattern: _EitherStr) -> bool: ... -def filter(names: Iterable[AnyStr], pattern: _EitherStr) -> list[AnyStr]: ... -def translate(pattern: AnyStr) -> AnyStr: ... diff --git a/mypy/typeshed/stdlib/@python2/formatter.pyi b/mypy/typeshed/stdlib/@python2/formatter.pyi deleted file mode 100644 index f5d8348d08a1..000000000000 --- a/mypy/typeshed/stdlib/@python2/formatter.pyi +++ /dev/null @@ -1,103 +0,0 @@ -from typing import IO, Any, Iterable - -AS_IS: None -_FontType = tuple[str, bool, bool, bool] -_StylesType = tuple[Any, ...] - -class NullFormatter: - writer: NullWriter | None - def __init__(self, writer: NullWriter | None = ...) -> None: ... - def end_paragraph(self, blankline: int) -> None: ... - def add_line_break(self) -> None: ... - def add_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def add_label_data(self, format: str, counter: int, blankline: int | None = ...) -> None: ... - def add_flowing_data(self, data: str) -> None: ... - def add_literal_data(self, data: str) -> None: ... - def flush_softspace(self) -> None: ... - def push_alignment(self, align: str | None) -> None: ... - def pop_alignment(self) -> None: ... - def push_font(self, x: _FontType) -> None: ... - def pop_font(self) -> None: ... - def push_margin(self, margin: int) -> None: ... - def pop_margin(self) -> None: ... - def set_spacing(self, spacing: str | None) -> None: ... - def push_style(self, *styles: _StylesType) -> None: ... - def pop_style(self, n: int = ...) -> None: ... - def assert_line_data(self, flag: int = ...) -> None: ... - -class AbstractFormatter: - writer: NullWriter - align: str | None - align_stack: list[str | None] - font_stack: list[_FontType] - margin_stack: list[int] - spacing: str | None - style_stack: Any - nospace: int - softspace: int - para_end: int - parskip: int - hard_break: int - have_label: int - def __init__(self, writer: NullWriter) -> None: ... - def end_paragraph(self, blankline: int) -> None: ... - def add_line_break(self) -> None: ... - def add_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def add_label_data(self, format: str, counter: int, blankline: int | None = ...) -> None: ... - def format_counter(self, format: Iterable[str], counter: int) -> str: ... - def format_letter(self, case: str, counter: int) -> str: ... - def format_roman(self, case: str, counter: int) -> str: ... - def add_flowing_data(self, data: str) -> None: ... - def add_literal_data(self, data: str) -> None: ... - def flush_softspace(self) -> None: ... - def push_alignment(self, align: str | None) -> None: ... - def pop_alignment(self) -> None: ... - def push_font(self, font: _FontType) -> None: ... - def pop_font(self) -> None: ... - def push_margin(self, margin: int) -> None: ... - def pop_margin(self) -> None: ... - def set_spacing(self, spacing: str | None) -> None: ... - def push_style(self, *styles: _StylesType) -> None: ... - def pop_style(self, n: int = ...) -> None: ... - def assert_line_data(self, flag: int = ...) -> None: ... - -class NullWriter: - def __init__(self) -> None: ... - def flush(self) -> None: ... - def new_alignment(self, align: str | None) -> None: ... - def new_font(self, font: _FontType) -> None: ... - def new_margin(self, margin: int, level: int) -> None: ... - def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: tuple[Any, ...]) -> None: ... - def send_paragraph(self, blankline: int) -> None: ... - def send_line_break(self) -> None: ... - def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def send_label_data(self, data: str) -> None: ... - def send_flowing_data(self, data: str) -> None: ... - def send_literal_data(self, data: str) -> None: ... - -class AbstractWriter(NullWriter): - def new_alignment(self, align: str | None) -> None: ... - def new_font(self, font: _FontType) -> None: ... - def new_margin(self, margin: int, level: int) -> None: ... - def new_spacing(self, spacing: str | None) -> None: ... - def new_styles(self, styles: tuple[Any, ...]) -> None: ... - def send_paragraph(self, blankline: int) -> None: ... - def send_line_break(self) -> None: ... - def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def send_label_data(self, data: str) -> None: ... - def send_flowing_data(self, data: str) -> None: ... - def send_literal_data(self, data: str) -> None: ... - -class DumbWriter(NullWriter): - file: IO[str] - maxcol: int - def __init__(self, file: IO[str] | None = ..., maxcol: int = ...) -> None: ... - def reset(self) -> None: ... - def send_paragraph(self, blankline: int) -> None: ... - def send_line_break(self) -> None: ... - def send_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def send_literal_data(self, data: str) -> None: ... - def send_flowing_data(self, data: str) -> None: ... - -def test(file: str | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/fractions.pyi b/mypy/typeshed/stdlib/@python2/fractions.pyi deleted file mode 100644 index 27de79248c03..000000000000 --- a/mypy/typeshed/stdlib/@python2/fractions.pyi +++ /dev/null @@ -1,145 +0,0 @@ -from _typeshed import Self -from decimal import Decimal -from numbers import Integral, Rational, Real -from typing import overload -from typing_extensions import Literal - -_ComparableNum = int | float | Decimal | Real - -@overload -def gcd(a: int, b: int) -> int: ... -@overload -def gcd(a: Integral, b: int) -> Integral: ... -@overload -def gcd(a: int, b: Integral) -> Integral: ... -@overload -def gcd(a: Integral, b: Integral) -> Integral: ... - -class Fraction(Rational): - @overload - def __new__( - cls: type[Self], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ... - ) -> Self: ... - @overload - def __new__(cls: type[Self], __value: float | Decimal | str, *, _normalize: bool = ...) -> Self: ... - @classmethod - def from_float(cls, f: float) -> Fraction: ... - @classmethod - def from_decimal(cls, dec: Decimal) -> Fraction: ... - def limit_denominator(self, max_denominator: int = ...) -> Fraction: ... - @property - def numerator(self) -> int: ... - @property - def denominator(self) -> int: ... - @overload - def __add__(self, other: int | Fraction) -> Fraction: ... - @overload - def __add__(self, other: float) -> float: ... - @overload - def __add__(self, other: complex) -> complex: ... - @overload - def __radd__(self, other: int | Fraction) -> Fraction: ... - @overload - def __radd__(self, other: float) -> float: ... - @overload - def __radd__(self, other: complex) -> complex: ... - @overload - def __sub__(self, other: int | Fraction) -> Fraction: ... - @overload - def __sub__(self, other: float) -> float: ... - @overload - def __sub__(self, other: complex) -> complex: ... - @overload - def __rsub__(self, other: int | Fraction) -> Fraction: ... - @overload - def __rsub__(self, other: float) -> float: ... - @overload - def __rsub__(self, other: complex) -> complex: ... - @overload - def __mul__(self, other: int | Fraction) -> Fraction: ... - @overload - def __mul__(self, other: float) -> float: ... - @overload - def __mul__(self, other: complex) -> complex: ... - @overload - def __rmul__(self, other: int | Fraction) -> Fraction: ... - @overload - def __rmul__(self, other: float) -> float: ... - @overload - def __rmul__(self, other: complex) -> complex: ... - @overload - def __truediv__(self, other: int | Fraction) -> Fraction: ... - @overload - def __truediv__(self, other: float) -> float: ... - @overload - def __truediv__(self, other: complex) -> complex: ... - @overload - def __rtruediv__(self, other: int | Fraction) -> Fraction: ... - @overload - def __rtruediv__(self, other: float) -> float: ... - @overload - def __rtruediv__(self, other: complex) -> complex: ... - @overload - def __div__(self, other: int | Fraction) -> Fraction: ... - @overload - def __div__(self, other: float) -> float: ... - @overload - def __div__(self, other: complex) -> complex: ... - @overload - def __rdiv__(self, other: int | Fraction) -> Fraction: ... - @overload - def __rdiv__(self, other: float) -> float: ... - @overload - def __rdiv__(self, other: complex) -> complex: ... - @overload - def __floordiv__(self, other: int | Fraction) -> int: ... - @overload - def __floordiv__(self, other: float) -> float: ... - @overload - def __rfloordiv__(self, other: int | Fraction) -> int: ... - @overload - def __rfloordiv__(self, other: float) -> float: ... - @overload - def __mod__(self, other: int | Fraction) -> Fraction: ... - @overload - def __mod__(self, other: float) -> float: ... - @overload - def __rmod__(self, other: int | Fraction) -> Fraction: ... - @overload - def __rmod__(self, other: float) -> float: ... - @overload - def __divmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ... - @overload - def __divmod__(self, other: float) -> tuple[float, Fraction]: ... - @overload - def __rdivmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ... - @overload - def __rdivmod__(self, other: float) -> tuple[float, Fraction]: ... - @overload - def __pow__(self, other: int) -> Fraction: ... - @overload - def __pow__(self, other: float | Fraction) -> float: ... - @overload - def __pow__(self, other: complex) -> complex: ... - @overload - def __rpow__(self, other: int | float | Fraction) -> float: ... - @overload - def __rpow__(self, other: complex) -> complex: ... - def __pos__(self) -> Fraction: ... - def __neg__(self) -> Fraction: ... - def __abs__(self) -> Fraction: ... - def __trunc__(self) -> int: ... - def __hash__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... - def __lt__(self, other: _ComparableNum) -> bool: ... - def __gt__(self, other: _ComparableNum) -> bool: ... - def __le__(self, other: _ComparableNum) -> bool: ... - def __ge__(self, other: _ComparableNum) -> bool: ... - def __nonzero__(self) -> bool: ... - # Not actually defined within fractions.py, but provides more useful - # overrides - @property - def real(self) -> Fraction: ... - @property - def imag(self) -> Literal[0]: ... - def conjugate(self) -> Fraction: ... diff --git a/mypy/typeshed/stdlib/@python2/ftplib.pyi b/mypy/typeshed/stdlib/@python2/ftplib.pyi deleted file mode 100644 index 870d00d804ce..000000000000 --- a/mypy/typeshed/stdlib/@python2/ftplib.pyi +++ /dev/null @@ -1,127 +0,0 @@ -from _typeshed import SupportsRead, SupportsReadline -from socket import socket -from ssl import SSLContext -from typing import Any, BinaryIO, Callable, Text -from typing_extensions import Literal - -_IntOrStr = int | Text - -MSG_OOB: int -FTP_PORT: int -MAXLINE: int -CRLF: str - -class Error(Exception): ... -class error_reply(Error): ... -class error_temp(Error): ... -class error_perm(Error): ... -class error_proto(Error): ... - -all_errors: tuple[type[Exception], ...] - -class FTP: - debugging: int - - # Note: This is technically the type that's passed in as the host argument. But to make it easier in Python 2 we - # accept Text but return str. - host: str - - port: int - maxline: int - sock: socket | None - welcome: str | None - passiveserver: int - timeout: int - af: int - lastresp: str - - file: BinaryIO | None - def __init__( - self, host: Text = ..., user: Text = ..., passwd: Text = ..., acct: Text = ..., timeout: float = ... - ) -> None: ... - def connect(self, host: Text = ..., port: int = ..., timeout: float = ...) -> str: ... - def getwelcome(self) -> str: ... - def set_debuglevel(self, level: int) -> None: ... - def debug(self, level: int) -> None: ... - def set_pasv(self, val: bool | int) -> None: ... - def sanitize(self, s: Text) -> str: ... - def putline(self, line: Text) -> None: ... - def putcmd(self, line: Text) -> None: ... - def getline(self) -> str: ... - def getmultiline(self) -> str: ... - def getresp(self) -> str: ... - def voidresp(self) -> str: ... - def abort(self) -> str: ... - def sendcmd(self, cmd: Text) -> str: ... - def voidcmd(self, cmd: Text) -> str: ... - def sendport(self, host: Text, port: int) -> str: ... - def sendeprt(self, host: Text, port: int) -> str: ... - def makeport(self) -> socket: ... - def makepasv(self) -> tuple[str, int]: ... - def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ...) -> str: ... - # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers. - def ntransfercmd(self, cmd: Text, rest: _IntOrStr | None = ...) -> tuple[socket, int]: ... - def transfercmd(self, cmd: Text, rest: _IntOrStr | None = ...) -> socket: ... - def retrbinary( - self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: _IntOrStr | None = ... - ) -> str: ... - def storbinary( - self, - cmd: Text, - fp: SupportsRead[bytes], - blocksize: int = ..., - callback: Callable[[bytes], Any] | None = ..., - rest: _IntOrStr | None = ..., - ) -> str: ... - def retrlines(self, cmd: Text, callback: Callable[[str], Any] | None = ...) -> str: ... - def storlines(self, cmd: Text, fp: SupportsReadline[bytes], callback: Callable[[bytes], Any] | None = ...) -> str: ... - def acct(self, password: Text) -> str: ... - def nlst(self, *args: Text) -> list[str]: ... - # Technically only the last arg can be a Callable but ... - def dir(self, *args: str | Callable[[str], None]) -> None: ... - def rename(self, fromname: Text, toname: Text) -> str: ... - def delete(self, filename: Text) -> str: ... - def cwd(self, dirname: Text) -> str: ... - def size(self, filename: Text) -> int | None: ... - def mkd(self, dirname: Text) -> str: ... - def rmd(self, dirname: Text) -> str: ... - def pwd(self) -> str: ... - def quit(self) -> str: ... - def close(self) -> None: ... - -class FTP_TLS(FTP): - def __init__( - self, - host: Text = ..., - user: Text = ..., - passwd: Text = ..., - acct: Text = ..., - keyfile: str | None = ..., - certfile: str | None = ..., - context: SSLContext | None = ..., - timeout: float = ..., - source_address: tuple[str, int] | None = ..., - ) -> None: ... - ssl_version: int - keyfile: str | None - certfile: str | None - context: SSLContext - def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ..., secure: bool = ...) -> str: ... - def auth(self) -> str: ... - def prot_p(self) -> str: ... - def prot_c(self) -> str: ... - -class Netrc: - def __init__(self, filename: Text | None = ...) -> None: ... - def get_hosts(self) -> list[str]: ... - def get_account(self, host: Text) -> tuple[str | None, str | None, str | None]: ... - def get_macros(self) -> list[str]: ... - def get_macro(self, macro: Text) -> tuple[str, ...]: ... - -def parse150(resp: str) -> int | None: ... # undocumented -def parse227(resp: str) -> tuple[str, int]: ... # undocumented -def parse229(resp: str, peer: Any) -> tuple[str, int]: ... # undocumented -def parse257(resp: str) -> str: ... # undocumented -def ftpcp( - source: FTP, sourcename: str, target: FTP, targetname: str = ..., type: Literal["A", "I"] = ... -) -> None: ... # undocumented diff --git a/mypy/typeshed/stdlib/@python2/functools.pyi b/mypy/typeshed/stdlib/@python2/functools.pyi deleted file mode 100644 index 026a74faf6ff..000000000000 --- a/mypy/typeshed/stdlib/@python2/functools.pyi +++ /dev/null @@ -1,30 +0,0 @@ -from typing import Any, Callable, Generic, Iterable, Sequence, TypeVar, overload - -_AnyCallable = Callable[..., Any] - -_T = TypeVar("_T") -_S = TypeVar("_S") - -@overload -def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ... -@overload -def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ... - -WRAPPER_ASSIGNMENTS: Sequence[str] -WRAPPER_UPDATES: Sequence[str] - -def update_wrapper( - wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ... -) -> _AnyCallable: ... -def wraps( - wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ... -) -> Callable[[_AnyCallable], _AnyCallable]: ... -def total_ordering(cls: type[_T]) -> type[_T]: ... -def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ... - -class partial(Generic[_T]): - func = ... # Callable[..., _T] - args: tuple[Any, ...] - keywords: dict[str, Any] - def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> _T: ... diff --git a/mypy/typeshed/stdlib/@python2/future_builtins.pyi b/mypy/typeshed/stdlib/@python2/future_builtins.pyi deleted file mode 100644 index 2a06c73cf409..000000000000 --- a/mypy/typeshed/stdlib/@python2/future_builtins.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from itertools import ifilter, imap, izip -from typing import Any - -filter = ifilter -map = imap -zip = izip - -def ascii(obj: Any) -> str: ... -def hex(x: int) -> str: ... -def oct(x: int) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/gc.pyi b/mypy/typeshed/stdlib/@python2/gc.pyi deleted file mode 100644 index 0ee05387a5a8..000000000000 --- a/mypy/typeshed/stdlib/@python2/gc.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from typing import Any - -def enable() -> None: ... -def disable() -> None: ... -def isenabled() -> bool: ... -def collect(generation: int = ...) -> int: ... -def set_debug(flags: int) -> None: ... -def get_debug() -> int: ... -def get_objects() -> list[Any]: ... -def set_threshold(threshold0: int, threshold1: int = ..., threshold2: int = ...) -> None: ... -def get_count() -> tuple[int, int, int]: ... -def get_threshold() -> tuple[int, int, int]: ... -def get_referrers(*objs: Any) -> list[Any]: ... -def get_referents(*objs: Any) -> list[Any]: ... -def is_tracked(obj: Any) -> bool: ... - -garbage: list[Any] - -DEBUG_STATS: int -DEBUG_COLLECTABLE: int -DEBUG_UNCOLLECTABLE: int -DEBUG_INSTANCES: int -DEBUG_OBJECTS: int -DEBUG_SAVEALL: int -DEBUG_LEAK: int diff --git a/mypy/typeshed/stdlib/@python2/genericpath.pyi b/mypy/typeshed/stdlib/@python2/genericpath.pyi deleted file mode 100644 index 7ff27a62f959..000000000000 --- a/mypy/typeshed/stdlib/@python2/genericpath.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from _typeshed import SupportsLessThanT -from typing import Sequence, Text, overload -from typing_extensions import Literal - -# All overloads can return empty string. Ideally, Literal[""] would be a valid -# Iterable[T], so that Union[List[T], Literal[""]] could be used as a return -# type. But because this only works when T is str, we need Sequence[T] instead. -@overload -def commonprefix(m: Sequence[str]) -> str | Literal[""]: ... # type: ignore[misc] -@overload -def commonprefix(m: Sequence[Text]) -> Text: ... -@overload -def commonprefix(m: Sequence[list[SupportsLessThanT]]) -> Sequence[SupportsLessThanT]: ... -@overload -def commonprefix(m: Sequence[tuple[SupportsLessThanT, ...]]) -> Sequence[SupportsLessThanT]: ... -def exists(path: Text) -> bool: ... -def getsize(filename: Text) -> int: ... -def isfile(path: Text) -> bool: ... -def isdir(s: Text) -> bool: ... - -# These return float if os.stat_float_times() == True, -# but int is a subclass of float. -def getatime(filename: Text) -> float: ... -def getmtime(filename: Text) -> float: ... -def getctime(filename: Text) -> float: ... diff --git a/mypy/typeshed/stdlib/@python2/getopt.pyi b/mypy/typeshed/stdlib/@python2/getopt.pyi deleted file mode 100644 index b1e90a6c5a67..000000000000 --- a/mypy/typeshed/stdlib/@python2/getopt.pyi +++ /dev/null @@ -1,9 +0,0 @@ -class GetoptError(Exception): - opt: str - msg: str - def __init__(self, msg: str, opt: str = ...) -> None: ... - -error = GetoptError - -def getopt(args: list[str], shortopts: str, longopts: list[str] = ...) -> tuple[list[tuple[str, str]], list[str]]: ... -def gnu_getopt(args: list[str], shortopts: str, longopts: list[str] = ...) -> tuple[list[tuple[str, str]], list[str]]: ... diff --git a/mypy/typeshed/stdlib/@python2/getpass.pyi b/mypy/typeshed/stdlib/@python2/getpass.pyi deleted file mode 100644 index 784eb1a1d760..000000000000 --- a/mypy/typeshed/stdlib/@python2/getpass.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import IO, Any - -class GetPassWarning(UserWarning): ... - -def getpass(prompt: str = ..., stream: IO[Any] = ...) -> str: ... -def getuser() -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/gettext.pyi b/mypy/typeshed/stdlib/@python2/gettext.pyi deleted file mode 100644 index 02e306978160..000000000000 --- a/mypy/typeshed/stdlib/@python2/gettext.pyi +++ /dev/null @@ -1,48 +0,0 @@ -from typing import IO, Any, Container, Sequence - -def bindtextdomain(domain: str, localedir: str = ...) -> str: ... -def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ... -def textdomain(domain: str = ...) -> str: ... -def gettext(message: str) -> str: ... -def lgettext(message: str) -> str: ... -def dgettext(domain: str, message: str) -> str: ... -def ldgettext(domain: str, message: str) -> str: ... -def ngettext(singular: str, plural: str, n: int) -> str: ... -def lngettext(singular: str, plural: str, n: int) -> str: ... -def dngettext(domain: str, singular: str, plural: str, n: int) -> str: ... -def ldngettext(domain: str, singular: str, plural: str, n: int) -> str: ... - -class NullTranslations(object): - def __init__(self, fp: IO[str] = ...) -> None: ... - def _parse(self, fp: IO[str]) -> None: ... - def add_fallback(self, fallback: NullTranslations) -> None: ... - def gettext(self, message: str) -> str: ... - def lgettext(self, message: str) -> str: ... - def ugettext(self, message: str | unicode) -> unicode: ... - def ngettext(self, singular: str, plural: str, n: int) -> str: ... - def lngettext(self, singular: str, plural: str, n: int) -> str: ... - def ungettext(self, singular: str | unicode, plural: str | unicode, n: int) -> unicode: ... - def info(self) -> dict[str, str]: ... - def charset(self) -> str | None: ... - def output_charset(self) -> str | None: ... - def set_output_charset(self, charset: str | None) -> None: ... - def install(self, unicode: bool = ..., names: Container[str] = ...) -> None: ... - -class GNUTranslations(NullTranslations): - LE_MAGIC: int - BE_MAGIC: int - -def find( - domain: str, localedir: str | None = ..., languages: Sequence[str] | None = ..., all: Any = ... -) -> str | list[str] | None: ... -def translation( - domain: str, - localedir: str | None = ..., - languages: Sequence[str] | None = ..., - class_: type[NullTranslations] | None = ..., - fallback: bool = ..., - codeset: str | None = ..., -) -> NullTranslations: ... -def install( - domain: str, localedir: str | None = ..., unicode: bool = ..., codeset: str | None = ..., names: Container[str] = ... -) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/glob.pyi b/mypy/typeshed/stdlib/@python2/glob.pyi deleted file mode 100644 index 2fc01a03a48b..000000000000 --- a/mypy/typeshed/stdlib/@python2/glob.pyi +++ /dev/null @@ -1,7 +0,0 @@ -from typing import AnyStr, Iterator - -def glob(pathname: AnyStr) -> list[AnyStr]: ... -def iglob(pathname: AnyStr) -> Iterator[AnyStr]: ... -def glob1(dirname: str | unicode, pattern: AnyStr) -> list[AnyStr]: ... -def glob0(dirname: str | unicode, basename: AnyStr) -> list[AnyStr]: ... -def has_magic(s: str | unicode) -> bool: ... # undocumented diff --git a/mypy/typeshed/stdlib/@python2/grp.pyi b/mypy/typeshed/stdlib/@python2/grp.pyi deleted file mode 100644 index 1651663eb242..000000000000 --- a/mypy/typeshed/stdlib/@python2/grp.pyi +++ /dev/null @@ -1,12 +0,0 @@ -import sys -from typing import NamedTuple - -if sys.platform != "win32": - class struct_group(NamedTuple): - gr_name: str - gr_passwd: str | None - gr_gid: int - gr_mem: list[str] - def getgrall() -> list[struct_group]: ... - def getgrgid(id: int) -> struct_group: ... - def getgrnam(name: str) -> struct_group: ... diff --git a/mypy/typeshed/stdlib/@python2/gzip.pyi b/mypy/typeshed/stdlib/@python2/gzip.pyi deleted file mode 100644 index f5c5af9c4c40..000000000000 --- a/mypy/typeshed/stdlib/@python2/gzip.pyi +++ /dev/null @@ -1,38 +0,0 @@ -import io -from typing import IO, Any, Text - -class GzipFile(io.BufferedIOBase): - myfileobj: Any - max_read_chunk: Any - mode: Any - extrabuf: Any - extrasize: Any - extrastart: Any - name: Any - min_readsize: Any - compress: Any - fileobj: Any - offset: Any - mtime: Any - def __init__( - self, filename: str = ..., mode: Text = ..., compresslevel: int = ..., fileobj: IO[str] = ..., mtime: float = ... - ) -> None: ... - @property - def filename(self): ... - size: Any - crc: Any - def write(self, data): ... - def read(self, size=...): ... - @property - def closed(self): ... - def close(self): ... - def flush(self, zlib_mode=...): ... - def fileno(self): ... - def rewind(self): ... - def readable(self): ... - def writable(self): ... - def seekable(self): ... - def seek(self, offset, whence=...): ... - def readline(self, size=...): ... - -def open(filename: str, mode: Text = ..., compresslevel: int = ...) -> GzipFile: ... diff --git a/mypy/typeshed/stdlib/@python2/hashlib.pyi b/mypy/typeshed/stdlib/@python2/hashlib.pyi deleted file mode 100644 index 86e6c21159a6..000000000000 --- a/mypy/typeshed/stdlib/@python2/hashlib.pyi +++ /dev/null @@ -1,30 +0,0 @@ -_DataType = str | unicode | bytearray | buffer | memoryview - -class _hash(object): # This is not actually in the module namespace. - @property - def name(self) -> str: ... - @property - def block_size(self) -> int: ... - @property - def digest_size(self) -> int: ... - @property - def digestsize(self) -> int: ... - def __init__(self, arg: _DataType = ...) -> None: ... - def update(self, arg: _DataType) -> None: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def copy(self) -> _hash: ... - -def new(name: str, data: str = ...) -> _hash: ... -def md5(s: _DataType = ...) -> _hash: ... -def sha1(s: _DataType = ...) -> _hash: ... -def sha224(s: _DataType = ...) -> _hash: ... -def sha256(s: _DataType = ...) -> _hash: ... -def sha384(s: _DataType = ...) -> _hash: ... -def sha512(s: _DataType = ...) -> _hash: ... - -algorithms: tuple[str, ...] -algorithms_guaranteed: tuple[str, ...] -algorithms_available: tuple[str, ...] - -def pbkdf2_hmac(name: str, password: str, salt: str, rounds: int, dklen: int = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/heapq.pyi b/mypy/typeshed/stdlib/@python2/heapq.pyi deleted file mode 100644 index 5c393436d3c2..000000000000 --- a/mypy/typeshed/stdlib/@python2/heapq.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from _typeshed import SupportsLessThan -from typing import Callable, Iterable, TypeVar - -_T = TypeVar("_T") - -def cmp_lt(x, y) -> bool: ... -def heappush(heap: list[_T], item: _T) -> None: ... -def heappop(heap: list[_T]) -> _T: ... -def heappushpop(heap: list[_T], item: _T) -> _T: ... -def heapify(x: list[_T]) -> None: ... -def heapreplace(heap: list[_T], item: _T) -> _T: ... -def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... -def nlargest(n: int, iterable: Iterable[_T], key: Callable[[_T], SupportsLessThan] | None = ...) -> list[_T]: ... -def nsmallest(n: int, iterable: Iterable[_T], key: Callable[[_T], SupportsLessThan] | None = ...) -> list[_T]: ... -def _heapify_max(__x: list[_T]) -> None: ... # undocumented diff --git a/mypy/typeshed/stdlib/@python2/hmac.pyi b/mypy/typeshed/stdlib/@python2/hmac.pyi deleted file mode 100644 index a244f4112e87..000000000000 --- a/mypy/typeshed/stdlib/@python2/hmac.pyi +++ /dev/null @@ -1,23 +0,0 @@ -from _typeshed import ReadableBuffer -from types import ModuleType -from typing import Any, AnyStr, Callable, overload - -# TODO more precise type for object of hashlib -_Hash = Any -_DigestMod = str | Callable[[], _Hash] | ModuleType - -digest_size: None - -def new(key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod | None = ...) -> HMAC: ... - -class HMAC: - def __init__(self, key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod = ...) -> None: ... - def update(self, msg: ReadableBuffer) -> None: ... - def digest(self) -> bytes: ... - def hexdigest(self) -> str: ... - def copy(self) -> HMAC: ... - -@overload -def compare_digest(__a: ReadableBuffer, __b: ReadableBuffer) -> bool: ... -@overload -def compare_digest(__a: AnyStr, __b: AnyStr) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/htmlentitydefs.pyi b/mypy/typeshed/stdlib/@python2/htmlentitydefs.pyi deleted file mode 100644 index 3fcc4be2d5a0..000000000000 --- a/mypy/typeshed/stdlib/@python2/htmlentitydefs.pyi +++ /dev/null @@ -1,3 +0,0 @@ -name2codepoint: dict[str, int] -codepoint2name: dict[int, str] -entitydefs: dict[str, str] diff --git a/mypy/typeshed/stdlib/@python2/httplib.pyi b/mypy/typeshed/stdlib/@python2/httplib.pyi deleted file mode 100644 index b72423fc8ea9..000000000000 --- a/mypy/typeshed/stdlib/@python2/httplib.pyi +++ /dev/null @@ -1,217 +0,0 @@ -import mimetools -from typing import Any, Protocol - -class HTTPMessage(mimetools.Message): - def addcontinue(self, key: str, more: str) -> None: ... - dict: dict[str, str] - def addheader(self, key: str, value: str) -> None: ... - unixfrom: str - headers: Any - status: str - seekable: bool - def readheaders(self) -> None: ... - -class HTTPResponse: - fp: Any - debuglevel: Any - strict: Any - msg: Any - version: Any - status: Any - reason: Any - chunked: Any - chunk_left: Any - length: Any - will_close: Any - def __init__( - self, sock, debuglevel: int = ..., strict: int = ..., method: Any | None = ..., buffering: bool = ... - ) -> None: ... - def begin(self): ... - def close(self): ... - def isclosed(self): ... - def read(self, amt: Any | None = ...): ... - def fileno(self): ... - def getheader(self, name, default: Any | None = ...): ... - def getheaders(self): ... - -# This is an API stub only for HTTPConnection and HTTPSConnection, as used in -# urllib2.AbstractHTTPHandler.do_open, which takes either the class -# HTTPConnection or the class HTTPSConnection, *not* an instance of either -# class. do_open does not use all of the parameters of HTTPConnection.__init__ -# or HTTPSConnection.__init__, so HTTPConnectionProtocol only implements the -# parameters that do_open does use. -class HTTPConnectionProtocol(Protocol): - def __call__(self, host: str, timeout: int = ..., **http_con_args: Any) -> HTTPConnection: ... - -class HTTPConnection: - response_class: Any - default_port: Any - auto_open: Any - debuglevel: Any - strict: Any - timeout: Any - source_address: Any - sock: Any - host: str = ... - port: int = ... - def __init__( - self, host, port: Any | None = ..., strict: Any | None = ..., timeout=..., source_address: Any | None = ... - ) -> None: ... - def set_tunnel(self, host, port: Any | None = ..., headers: Any | None = ...): ... - def set_debuglevel(self, level): ... - def connect(self): ... - def close(self): ... - def send(self, data): ... - def putrequest(self, method, url, skip_host: int = ..., skip_accept_encoding: int = ...): ... - def putheader(self, header, *values): ... - def endheaders(self, message_body: Any | None = ...): ... - def request(self, method, url, body: Any | None = ..., headers=...): ... - def getresponse(self, buffering: bool = ...): ... - -class HTTP: - debuglevel: Any - def __init__(self, host: str = ..., port: Any | None = ..., strict: Any | None = ...) -> None: ... - def connect(self, host: Any | None = ..., port: Any | None = ...): ... - def getfile(self): ... - file: Any - headers: Any - def getreply(self, buffering: bool = ...): ... - def close(self): ... - -class HTTPSConnection(HTTPConnection): - default_port: Any - key_file: Any - cert_file: Any - def __init__( - self, - host, - port: Any | None = ..., - key_file: Any | None = ..., - cert_file: Any | None = ..., - strict: Any | None = ..., - timeout=..., - source_address: Any | None = ..., - context: Any | None = ..., - ) -> None: ... - sock: Any - def connect(self): ... - -class HTTPS(HTTP): - key_file: Any - cert_file: Any - def __init__( - self, - host: str = ..., - port: Any | None = ..., - key_file: Any | None = ..., - cert_file: Any | None = ..., - strict: Any | None = ..., - context: Any | None = ..., - ) -> None: ... - -class HTTPException(Exception): ... -class NotConnected(HTTPException): ... -class InvalidURL(HTTPException): ... - -class UnknownProtocol(HTTPException): - args: Any - version: Any - def __init__(self, version) -> None: ... - -class UnknownTransferEncoding(HTTPException): ... -class UnimplementedFileMode(HTTPException): ... - -class IncompleteRead(HTTPException): - args: Any - partial: Any - expected: Any - def __init__(self, partial, expected: Any | None = ...) -> None: ... - -class ImproperConnectionState(HTTPException): ... -class CannotSendRequest(ImproperConnectionState): ... -class CannotSendHeader(ImproperConnectionState): ... -class ResponseNotReady(ImproperConnectionState): ... - -class BadStatusLine(HTTPException): - args: Any - line: Any - def __init__(self, line) -> None: ... - -class LineTooLong(HTTPException): - def __init__(self, line_type) -> None: ... - -error: Any - -class LineAndFileWrapper: - def __init__(self, line, file) -> None: ... - def __getattr__(self, attr): ... - def read(self, amt: Any | None = ...): ... - def readline(self): ... - def readlines(self, size: Any | None = ...): ... - -# Constants - -responses: dict[int, str] - -HTTP_PORT: int -HTTPS_PORT: int - -# status codes -# informational -CONTINUE: int -SWITCHING_PROTOCOLS: int -PROCESSING: int - -# successful -OK: int -CREATED: int -ACCEPTED: int -NON_AUTHORITATIVE_INFORMATION: int -NO_CONTENT: int -RESET_CONTENT: int -PARTIAL_CONTENT: int -MULTI_STATUS: int -IM_USED: int - -# redirection -MULTIPLE_CHOICES: int -MOVED_PERMANENTLY: int -FOUND: int -SEE_OTHER: int -NOT_MODIFIED: int -USE_PROXY: int -TEMPORARY_REDIRECT: int - -# client error -BAD_REQUEST: int -UNAUTHORIZED: int -PAYMENT_REQUIRED: int -FORBIDDEN: int -NOT_FOUND: int -METHOD_NOT_ALLOWED: int -NOT_ACCEPTABLE: int -PROXY_AUTHENTICATION_REQUIRED: int -REQUEST_TIMEOUT: int -CONFLICT: int -GONE: int -LENGTH_REQUIRED: int -PRECONDITION_FAILED: int -REQUEST_ENTITY_TOO_LARGE: int -REQUEST_URI_TOO_LONG: int -UNSUPPORTED_MEDIA_TYPE: int -REQUESTED_RANGE_NOT_SATISFIABLE: int -EXPECTATION_FAILED: int -UNPROCESSABLE_ENTITY: int -LOCKED: int -FAILED_DEPENDENCY: int -UPGRADE_REQUIRED: int - -# server error -INTERNAL_SERVER_ERROR: int -NOT_IMPLEMENTED: int -BAD_GATEWAY: int -SERVICE_UNAVAILABLE: int -GATEWAY_TIMEOUT: int -HTTP_VERSION_NOT_SUPPORTED: int -INSUFFICIENT_STORAGE: int -NOT_EXTENDED: int diff --git a/mypy/typeshed/stdlib/@python2/imaplib.pyi b/mypy/typeshed/stdlib/@python2/imaplib.pyi deleted file mode 100644 index 72003eb48233..000000000000 --- a/mypy/typeshed/stdlib/@python2/imaplib.pyi +++ /dev/null @@ -1,131 +0,0 @@ -import subprocess -import time -from builtins import list as List # alias to avoid name clashes with `IMAP4.list` -from socket import socket as _socket -from ssl import SSLSocket -from typing import IO, Any, Callable, Pattern, Text -from typing_extensions import Literal - -# TODO: Commands should use their actual return types, not this type alias. -# E.g. tuple[Literal["OK"], list[bytes]] -_CommandResults = tuple[str, list[Any]] - -_AnyResponseData = list[None] | list[bytes | tuple[bytes, bytes]] - -class IMAP4: - error: type[Exception] = ... - abort: type[Exception] = ... - readonly: type[Exception] = ... - mustquote: Pattern[Text] = ... - debug: int = ... - state: str = ... - literal: Text | None = ... - tagged_commands: dict[bytes, List[bytes] | None] - untagged_responses: dict[str, List[bytes | tuple[bytes, bytes]]] - continuation_response: str = ... - is_readonly: bool = ... - tagnum: int = ... - tagpre: str = ... - tagre: Pattern[Text] = ... - welcome: bytes = ... - capabilities: tuple[str, ...] = ... - PROTOCOL_VERSION: str = ... - def __init__(self, host: str = ..., port: int = ...) -> None: ... - def open(self, host: str = ..., port: int = ...) -> None: ... - def __getattr__(self, attr: str) -> Any: ... - host: str = ... - port: int = ... - sock: _socket = ... - file: IO[Text] | IO[bytes] = ... - def read(self, size: int) -> bytes: ... - def readline(self) -> bytes: ... - def send(self, data: bytes) -> None: ... - def shutdown(self) -> None: ... - def socket(self) -> _socket: ... - 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[[bytes], bytes | None]) -> tuple[str, str]: ... - def capability(self) -> _CommandResults: ... - def check(self) -> _CommandResults: ... - def close(self) -> _CommandResults: ... - def copy(self, message_set: str, new_mailbox: str) -> _CommandResults: ... - def create(self, mailbox: str) -> _CommandResults: ... - def delete(self, mailbox: str) -> _CommandResults: ... - def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... - def expunge(self) -> _CommandResults: ... - def fetch(self, message_set: str, message_parts: str) -> tuple[str, _AnyResponseData]: ... - def getacl(self, mailbox: str) -> _CommandResults: ... - def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ... - def getquota(self, root: str) -> _CommandResults: ... - def getquotaroot(self, mailbox: str) -> _CommandResults: ... - def list(self, directory: str = ..., pattern: str = ...) -> tuple[str, _AnyResponseData]: ... - def login(self, user: str, password: str) -> tuple[Literal["OK"], List[bytes]]: ... - def login_cram_md5(self, user: str, password: str) -> _CommandResults: ... - def logout(self) -> tuple[str, _AnyResponseData]: ... - def lsub(self, directory: str = ..., pattern: str = ...) -> _CommandResults: ... - def myrights(self, mailbox: str) -> _CommandResults: ... - def namespace(self) -> _CommandResults: ... - def noop(self) -> tuple[str, List[bytes]]: ... - def partial(self, message_num: str, message_part: str, start: str, length: str) -> _CommandResults: ... - def proxyauth(self, user: str) -> _CommandResults: ... - def rename(self, oldmailbox: str, newmailbox: str) -> _CommandResults: ... - def search(self, charset: str | None, *criteria: str) -> _CommandResults: ... - def select(self, mailbox: str = ..., readonly: bool = ...) -> tuple[str, List[bytes | None]]: ... - def setacl(self, mailbox: str, who: str, what: str) -> _CommandResults: ... - def setannotation(self, *args: str) -> _CommandResults: ... - def setquota(self, root: str, limits: str) -> _CommandResults: ... - def sort(self, sort_criteria: str, charset: str, *search_criteria: str) -> _CommandResults: ... - def status(self, mailbox: str, names: str) -> _CommandResults: ... - def store(self, message_set: str, command: str, flags: str) -> _CommandResults: ... - def subscribe(self, mailbox: str) -> _CommandResults: ... - def thread(self, threading_algorithm: str, charset: str, *search_criteria: str) -> _CommandResults: ... - def uid(self, command: str, *args: str) -> _CommandResults: ... - def unsubscribe(self, mailbox: str) -> _CommandResults: ... - def xatom(self, name: str, *args: str) -> _CommandResults: ... - def print_log(self) -> None: ... - -class IMAP4_SSL(IMAP4): - keyfile: str = ... - certfile: str = ... - def __init__(self, host: str = ..., port: int = ..., keyfile: str | None = ..., certfile: str | None = ...) -> None: ... - host: str = ... - port: int = ... - sock: _socket = ... - sslobj: SSLSocket = ... - file: IO[Any] = ... - def open(self, host: str = ..., port: int | None = ...) -> None: ... - def read(self, size: int) -> bytes: ... - def readline(self) -> bytes: ... - def send(self, data: bytes) -> None: ... - def shutdown(self) -> None: ... - def socket(self) -> _socket: ... - def ssl(self) -> SSLSocket: ... - -class IMAP4_stream(IMAP4): - command: str = ... - def __init__(self, command: str) -> None: ... - host: str = ... - port: int = ... - sock: _socket = ... - file: IO[Any] = ... - process: subprocess.Popen[bytes] = ... - writefile: IO[Any] = ... - readfile: IO[Any] = ... - def open(self, host: str | None = ..., port: int | None = ...) -> None: ... - def read(self, size: int) -> bytes: ... - def readline(self) -> bytes: ... - def send(self, data: bytes) -> None: ... - def shutdown(self) -> None: ... - -class _Authenticator: - 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: ... - -def Internaldate2tuple(resp: str) -> time.struct_time: ... -def Int2AP(num: int) -> str: ... -def ParseFlags(resp: str) -> tuple[str, ...]: ... -def Time2Internaldate(date_time: float | time.struct_time | str) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/imghdr.pyi b/mypy/typeshed/stdlib/@python2/imghdr.pyi deleted file mode 100644 index 36db49902983..000000000000 --- a/mypy/typeshed/stdlib/@python2/imghdr.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Any, BinaryIO, Callable, Protocol, Text, overload - -class _ReadableBinary(Protocol): - def tell(self) -> int: ... - def read(self, size: int) -> bytes: ... - def seek(self, offset: int) -> Any: ... - -_File = Text | _ReadableBinary - -@overload -def what(file: _File, h: None = ...) -> str | None: ... -@overload -def what(file: Any, h: bytes) -> str | None: ... - -tests: list[Callable[[bytes, BinaryIO | None], str | None]] diff --git a/mypy/typeshed/stdlib/@python2/imp.pyi b/mypy/typeshed/stdlib/@python2/imp.pyi deleted file mode 100644 index 15d689249563..000000000000 --- a/mypy/typeshed/stdlib/@python2/imp.pyi +++ /dev/null @@ -1,33 +0,0 @@ -import types -from typing import IO, Any, Iterable - -C_BUILTIN: int -C_EXTENSION: int -IMP_HOOK: int -PKG_DIRECTORY: int -PY_CODERESOURCE: int -PY_COMPILED: int -PY_FROZEN: int -PY_RESOURCE: int -PY_SOURCE: int -SEARCH_ERROR: int - -def acquire_lock() -> None: ... -def find_module(name: str, path: Iterable[str] = ...) -> tuple[IO[Any], str, tuple[str, str, int]] | None: ... -def get_magic() -> str: ... -def get_suffixes() -> list[tuple[str, str, int]]: ... -def init_builtin(name: str) -> types.ModuleType: ... -def init_frozen(name: str) -> types.ModuleType: ... -def is_builtin(name: str) -> int: ... -def is_frozen(name: str) -> bool: ... -def load_compiled(name: str, pathname: str, file: IO[Any] = ...) -> types.ModuleType: ... -def load_dynamic(name: str, pathname: str, file: IO[Any] = ...) -> types.ModuleType: ... -def load_module(name: str, file: str, pathname: str, description: tuple[str, str, int]) -> types.ModuleType: ... -def load_source(name: str, pathname: str, file: IO[Any] = ...) -> types.ModuleType: ... -def lock_held() -> bool: ... -def new_module(name: str) -> types.ModuleType: ... -def release_lock() -> None: ... - -class NullImporter: - def __init__(self, path_string: str) -> None: ... - def find_module(self, fullname: str, path: str = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/importlib.pyi b/mypy/typeshed/stdlib/@python2/importlib.pyi deleted file mode 100644 index 530cb1a3c79c..000000000000 --- a/mypy/typeshed/stdlib/@python2/importlib.pyi +++ /dev/null @@ -1,4 +0,0 @@ -import types -from typing import Text - -def import_module(name: Text, package: Text | None = ...) -> types.ModuleType: ... diff --git a/mypy/typeshed/stdlib/@python2/inspect.pyi b/mypy/typeshed/stdlib/@python2/inspect.pyi deleted file mode 100644 index 8ffcc3edcb87..000000000000 --- a/mypy/typeshed/stdlib/@python2/inspect.pyi +++ /dev/null @@ -1,129 +0,0 @@ -from types import CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType -from typing import Any, AnyStr, Callable, NamedTuple, Sequence, Union - -# Types and members -class EndOfBlock(Exception): ... - -class BlockFinder: - indent: int - islambda: bool - started: bool - passline: bool - last: int - def tokeneater( - self, type: int, token: AnyStr, srow_scol: tuple[int, int], erow_ecol: tuple[int, int], line: AnyStr - ) -> None: ... - -CO_GENERATOR: int -CO_NESTED: int -CO_NEWLOCALS: int -CO_NOFREE: int -CO_OPTIMIZED: int -CO_VARARGS: int -CO_VARKEYWORDS: int -TPFLAGS_IS_ABSTRACT: int - -class ModuleInfo(NamedTuple): - name: str - suffix: str - mode: str - module_type: int - -def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> list[tuple[str, Any]]: ... -def getmoduleinfo(path: str | unicode) -> ModuleInfo | None: ... -def getmodulename(path: AnyStr) -> AnyStr | None: ... -def ismodule(object: object) -> bool: ... -def isclass(object: object) -> bool: ... -def ismethod(object: object) -> bool: ... -def isfunction(object: object) -> bool: ... -def isgeneratorfunction(object: object) -> bool: ... -def isgenerator(object: object) -> bool: ... -def istraceback(object: object) -> bool: ... -def isframe(object: object) -> bool: ... -def iscode(object: object) -> bool: ... -def isbuiltin(object: object) -> bool: ... -def isroutine(object: object) -> bool: ... -def isabstract(object: object) -> bool: ... -def ismethoddescriptor(object: object) -> bool: ... -def isdatadescriptor(object: object) -> bool: ... -def isgetsetdescriptor(object: object) -> bool: ... -def ismemberdescriptor(object: object) -> bool: ... - -# Retrieving source code -_SourceObjectType = Union[ModuleType, type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] - -def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ... -def getabsfile(object: _SourceObjectType) -> str: ... -def getblock(lines: Sequence[AnyStr]) -> Sequence[AnyStr]: ... -def getdoc(object: object) -> str | None: ... -def getcomments(object: object) -> str | None: ... -def getfile(object: _SourceObjectType) -> str: ... -def getmodule(object: object) -> ModuleType | None: ... -def getsourcefile(object: _SourceObjectType) -> str | None: ... -def getsourcelines(object: _SourceObjectType) -> tuple[list[str], int]: ... -def getsource(object: _SourceObjectType) -> str: ... -def cleandoc(doc: AnyStr) -> AnyStr: ... -def indentsize(line: str | unicode) -> int: ... - -# Classes and functions -def getclasstree(classes: list[type], unique: bool = ...) -> list[tuple[type, tuple[type, ...]] | list[Any]]: ... - -class ArgSpec(NamedTuple): - args: list[str] - varargs: str | None - keywords: str | None - defaults: tuple[Any, ...] - -class ArgInfo(NamedTuple): - args: list[str] - varargs: str | None - keywords: str | None - locals: dict[str, Any] - -class Arguments(NamedTuple): - args: list[str | list[Any]] - varargs: str | None - keywords: str | None - -def getargs(co: CodeType) -> Arguments: ... -def getargspec(func: object) -> ArgSpec: ... -def getargvalues(frame: FrameType) -> ArgInfo: ... -def formatargspec( - args, varargs=..., varkw=..., defaults=..., formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=..., join=... -) -> str: ... -def formatargvalues( - args, varargs=..., varkw=..., defaults=..., formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=..., join=... -) -> str: ... -def getmro(cls: type) -> tuple[type, ...]: ... -def getcallargs(func, *args, **kwds) -> dict[str, Any]: ... - -# The interpreter stack - -class Traceback(NamedTuple): - filename: str - lineno: int - function: str - code_context: list[str] | None - index: int | None # type: ignore[assignment] - -_FrameInfo = tuple[FrameType, str, int, str, list[str] | None, int | None] - -def getouterframes(frame: FrameType, context: int = ...) -> list[_FrameInfo]: ... -def getframeinfo(frame: FrameType | TracebackType, context: int = ...) -> Traceback: ... -def getinnerframes(traceback: TracebackType, context: int = ...) -> list[_FrameInfo]: ... -def getlineno(frame: FrameType) -> int: ... -def currentframe(depth: int = ...) -> FrameType: ... -def stack(context: int = ...) -> list[_FrameInfo]: ... -def trace(context: int = ...) -> list[_FrameInfo]: ... - -# Create private type alias to avoid conflict with symbol of same -# name created in Attribute class. -_Object = object - -class Attribute(NamedTuple): - name: str - kind: str - defining_class: type - object: _Object - -def classify_class_attrs(cls: type) -> list[Attribute]: ... diff --git a/mypy/typeshed/stdlib/@python2/io.pyi b/mypy/typeshed/stdlib/@python2/io.pyi deleted file mode 100644 index f36138edd598..000000000000 --- a/mypy/typeshed/stdlib/@python2/io.pyi +++ /dev/null @@ -1,40 +0,0 @@ -from typing import IO, Any - -import _io -from _io import ( - DEFAULT_BUFFER_SIZE as DEFAULT_BUFFER_SIZE, - BlockingIOError as BlockingIOError, - BufferedRandom as BufferedRandom, - BufferedReader as BufferedReader, - BufferedRWPair as BufferedRWPair, - BufferedWriter as BufferedWriter, - BytesIO as BytesIO, - FileIO as FileIO, - IncrementalNewlineDecoder as IncrementalNewlineDecoder, - StringIO as StringIO, - TextIOWrapper as TextIOWrapper, - UnsupportedOperation as UnsupportedOperation, - open as open, -) - -def _OpenWrapper( - file: str | unicode | int, - mode: unicode = ..., - buffering: int = ..., - encoding: unicode = ..., - errors: unicode = ..., - newline: unicode = ..., - closefd: bool = ..., -) -> IO[Any]: ... - -SEEK_SET: int -SEEK_CUR: int -SEEK_END: int - -class IOBase(_io._IOBase): ... -class RawIOBase(_io._RawIOBase, IOBase): ... -class BufferedIOBase(_io._BufferedIOBase, IOBase): ... - -# Note: In the actual io.py, TextIOBase subclasses IOBase. -# (Which we don't do here because we don't want to subclass both TextIO and BinaryIO.) -class TextIOBase(_io._TextIOBase): ... diff --git a/mypy/typeshed/stdlib/@python2/itertools.pyi b/mypy/typeshed/stdlib/@python2/itertools.pyi deleted file mode 100644 index b07a911c3e20..000000000000 --- a/mypy/typeshed/stdlib/@python2/itertools.pyi +++ /dev/null @@ -1,169 +0,0 @@ -from _typeshed import Self -from typing import Any, Callable, Generic, Iterable, Iterator, Sequence, TypeVar, overload - -_T = TypeVar("_T") -_S = TypeVar("_S") - -def count(start: int = ..., step: int = ...) -> Iterator[int]: ... # more general types? - -class cycle(Iterator[_T], Generic[_T]): - def __init__(self, iterable: Iterable[_T]) -> None: ... - def next(self) -> _T: ... - def __iter__(self: Self) -> Self: ... - -def repeat(object: _T, times: int = ...) -> Iterator[_T]: ... - -class chain(Iterator[_T], Generic[_T]): - def __init__(self, *iterables: Iterable[_T]) -> None: ... - def next(self) -> _T: ... - def __iter__(self: Self) -> Self: ... - @staticmethod - def from_iterable(iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ... - -def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ... -def dropwhile(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -@overload -def ifilter(predicate: None, iterable: Iterable[_T | None]) -> Iterator[_T]: ... -@overload -def ifilter(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -def ifilterfalse(predicate: Callable[[_T], Any] | None, iterable: Iterable[_T]) -> Iterator[_T]: ... -@overload -def groupby(iterable: Iterable[_T], key: None = ...) -> Iterator[tuple[_T, Iterator[_T]]]: ... -@overload -def groupby(iterable: Iterable[_T], key: Callable[[_T], _S]) -> Iterator[tuple[_S, Iterator[_T]]]: ... -@overload -def islice(iterable: Iterable[_T], stop: int | None) -> Iterator[_T]: ... -@overload -def islice(iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = ...) -> Iterator[_T]: ... - -_T1 = TypeVar("_T1") -_T2 = TypeVar("_T2") -_T3 = TypeVar("_T3") -_T4 = TypeVar("_T4") -_T5 = TypeVar("_T5") -_T6 = TypeVar("_T6") - -@overload -def imap(func: Callable[[_T1], _S], iter1: Iterable[_T1]) -> Iterator[_S]: ... -@overload -def imap(func: Callable[[_T1, _T2], _S], iter1: Iterable[_T1], iter2: Iterable[_T2]) -> Iterator[_S]: ... -@overload -def imap( - func: Callable[[_T1, _T2, _T3], _S], iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3] -) -> Iterator[_S]: ... -@overload -def imap( - func: Callable[[_T1, _T2, _T3, _T4], _S], - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], -) -> Iterator[_S]: ... -@overload -def imap( - func: Callable[[_T1, _T2, _T3, _T4, _T5], _S], - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - iter5: Iterable[_T5], -) -> Iterator[_S]: ... -@overload -def imap( - func: Callable[[_T1, _T2, _T3, _T4, _T5, _T6], _S], - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - iter5: Iterable[_T5], - iter6: Iterable[_T6], -) -> Iterator[_S]: ... -@overload -def imap( - func: Callable[..., _S], - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - iter7: Iterable[Any], - *iterables: Iterable[Any], -) -> Iterator[_S]: ... -def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: ... -def takewhile(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -def tee(iterable: Iterable[_T], n: int = ...) -> tuple[Iterator[_T], ...]: ... -@overload -def izip(iter1: Iterable[_T1]) -> Iterator[tuple[_T1]]: ... -@overload -def izip(iter1: Iterable[_T1], iter2: Iterable[_T2]) -> Iterator[tuple[_T1, _T2]]: ... -@overload -def izip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3]) -> Iterator[tuple[_T1, _T2, _T3]]: ... -@overload -def izip( - iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4] -) -> Iterator[tuple[_T1, _T2, _T3, _T4]]: ... -@overload -def izip( - iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], iter5: Iterable[_T5] -) -> Iterator[tuple[_T1, _T2, _T3, _T4, _T5]]: ... -@overload -def izip( - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - iter5: Iterable[_T5], - iter6: Iterable[_T6], -) -> Iterator[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... -@overload -def izip( - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - iter7: Iterable[Any], - *iterables: Iterable[Any], -) -> Iterator[tuple[Any, ...]]: ... -def izip_longest(*p: Iterable[Any], fillvalue: Any = ...) -> Iterator[Any]: ... -@overload -def product(iter1: Iterable[_T1]) -> Iterator[tuple[_T1]]: ... -@overload -def product(iter1: Iterable[_T1], iter2: Iterable[_T2]) -> Iterator[tuple[_T1, _T2]]: ... -@overload -def product(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3]) -> Iterator[tuple[_T1, _T2, _T3]]: ... -@overload -def product( - iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4] -) -> Iterator[tuple[_T1, _T2, _T3, _T4]]: ... -@overload -def product( - iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], iter5: Iterable[_T5] -) -> Iterator[tuple[_T1, _T2, _T3, _T4, _T5]]: ... -@overload -def product( - iter1: Iterable[_T1], - iter2: Iterable[_T2], - iter3: Iterable[_T3], - iter4: Iterable[_T4], - iter5: Iterable[_T5], - iter6: Iterable[_T6], -) -> Iterator[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... -@overload -def product( - iter1: Iterable[Any], - iter2: Iterable[Any], - iter3: Iterable[Any], - iter4: Iterable[Any], - iter5: Iterable[Any], - iter6: Iterable[Any], - iter7: Iterable[Any], - *iterables: Iterable[Any], -) -> Iterator[tuple[Any, ...]]: ... -@overload -def product(*iterables: Iterable[Any], repeat: int) -> Iterator[tuple[Any, ...]]: ... -def permutations(iterable: Iterable[_T], r: int = ...) -> Iterator[Sequence[_T]]: ... -def combinations(iterable: Iterable[_T], r: int) -> Iterator[Sequence[_T]]: ... -def combinations_with_replacement(iterable: Iterable[_T], r: int) -> Iterator[Sequence[_T]]: ... diff --git a/mypy/typeshed/stdlib/@python2/json.pyi b/mypy/typeshed/stdlib/@python2/json.pyi deleted file mode 100644 index fa6fdc49b9a9..000000000000 --- a/mypy/typeshed/stdlib/@python2/json.pyi +++ /dev/null @@ -1,93 +0,0 @@ -from _typeshed import SupportsRead -from typing import IO, Any, Callable, Text - -def dumps( - obj: Any, - skipkeys: bool = ..., - ensure_ascii: bool = ..., - check_circular: bool = ..., - allow_nan: bool = ..., - cls: type[JSONEncoder] | None = ..., - indent: int | None = ..., - separators: tuple[str, str] | None = ..., - encoding: str = ..., - default: Callable[[Any], Any] | None = ..., - sort_keys: bool = ..., - **kwds: Any, -) -> str: ... -def dump( - obj: Any, - fp: IO[str] | IO[Text], - skipkeys: bool = ..., - ensure_ascii: bool = ..., - check_circular: bool = ..., - allow_nan: bool = ..., - cls: type[JSONEncoder] | None = ..., - indent: int | None = ..., - separators: tuple[str, str] | None = ..., - encoding: str = ..., - default: Callable[[Any], Any] | None = ..., - sort_keys: bool = ..., - **kwds: Any, -) -> None: ... -def loads( - s: Text | bytes, - encoding: Any = ..., - cls: type[JSONDecoder] | None = ..., - object_hook: Callable[[dict[Any, Any]], Any] | None = ..., - parse_float: Callable[[str], Any] | None = ..., - parse_int: Callable[[str], Any] | None = ..., - parse_constant: Callable[[str], Any] | None = ..., - object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ..., - **kwds: Any, -) -> Any: ... -def load( - fp: SupportsRead[Text | bytes], - encoding: str | None = ..., - cls: type[JSONDecoder] | None = ..., - object_hook: Callable[[dict[Any, Any]], Any] | None = ..., - parse_float: Callable[[str], Any] | None = ..., - parse_int: Callable[[str], Any] | None = ..., - parse_constant: Callable[[str], Any] | None = ..., - object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ..., - **kwds: Any, -) -> Any: ... - -class JSONDecoder(object): - def __init__( - self, - encoding: Text | bytes = ..., - object_hook: Callable[..., Any] = ..., - parse_float: Callable[[str], float] = ..., - parse_int: Callable[[str], int] = ..., - parse_constant: Callable[[str], Any] = ..., - strict: bool = ..., - object_pairs_hook: Callable[..., Any] = ..., - ) -> None: ... - def decode(self, s: Text | bytes, _w: Any = ...) -> Any: ... - def raw_decode(self, s: Text | bytes, idx: int = ...) -> tuple[Any, Any]: ... - -class JSONEncoder(object): - item_separator: str - key_separator: str - skipkeys: bool - ensure_ascii: bool - check_circular: bool - allow_nan: bool - sort_keys: bool - indent: int | None - def __init__( - self, - skipkeys: bool = ..., - ensure_ascii: bool = ..., - check_circular: bool = ..., - allow_nan: bool = ..., - sort_keys: bool = ..., - indent: int | None = ..., - separators: tuple[Text | bytes, Text | bytes] = ..., - encoding: Text | bytes = ..., - default: Callable[..., Any] = ..., - ) -> None: ... - def default(self, o: Any) -> Any: ... - def encode(self, o: Any) -> str: ... - def iterencode(self, o: Any, _one_shot: bool = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/keyword.pyi b/mypy/typeshed/stdlib/@python2/keyword.pyi deleted file mode 100644 index e84ea1c919ec..000000000000 --- a/mypy/typeshed/stdlib/@python2/keyword.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from typing import Sequence, Text - -def iskeyword(s: Text) -> bool: ... - -kwlist: Sequence[str] diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/__init__.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/__init__.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/driver.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/driver.pyi deleted file mode 100644 index f36e3dd0a10c..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/driver.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from _typeshed import StrPath -from lib2to3.pgen2.grammar import Grammar -from lib2to3.pytree import _NL, _Convert -from logging import Logger -from typing import IO, Any, Iterable, Text - -class Driver: - grammar: Grammar - logger: Logger - convert: _Convert - def __init__(self, grammar: Grammar, convert: _Convert | None = ..., logger: Logger | None = ...) -> None: ... - def parse_tokens(self, tokens: Iterable[Any], debug: bool = ...) -> _NL: ... - def parse_stream_raw(self, stream: IO[Text], debug: bool = ...) -> _NL: ... - def parse_stream(self, stream: IO[Text], debug: bool = ...) -> _NL: ... - def parse_file(self, filename: StrPath, encoding: Text | None = ..., debug: bool = ...) -> _NL: ... - def parse_string(self, text: Text, debug: bool = ...) -> _NL: ... - -def load_grammar( - gt: Text = ..., gp: Text | None = ..., save: bool = ..., force: bool = ..., logger: Logger | None = ... -) -> Grammar: ... diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/grammar.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/grammar.pyi deleted file mode 100644 index 9d05082fc30c..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/grammar.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from _typeshed import Self, StrPath -from typing import Text - -_Label = tuple[int, Text | None] -_DFA = list[list[tuple[int, int]]] -_DFAS = tuple[_DFA, dict[int, int]] - -class Grammar: - symbol2number: dict[Text, int] - number2symbol: dict[int, Text] - states: list[_DFA] - dfas: dict[int, _DFAS] - labels: list[_Label] - keywords: dict[Text, int] - tokens: dict[int, int] - symbol2label: dict[Text, int] - start: int - def __init__(self) -> None: ... - def dump(self, filename: StrPath) -> None: ... - def load(self, filename: StrPath) -> None: ... - def copy(self: Self) -> Self: ... - def report(self) -> None: ... - -opmap_raw: Text -opmap: dict[Text, Text] diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/literals.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/literals.pyi deleted file mode 100644 index c7a219b5f9af..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/literals.pyi +++ /dev/null @@ -1,7 +0,0 @@ -from typing import Match, Text - -simple_escapes: dict[Text, Text] - -def escape(m: Match[str]) -> Text: ... -def evalString(s: Text) -> Text: ... -def test() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/parse.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/parse.pyi deleted file mode 100644 index be66a8e21e7e..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/parse.pyi +++ /dev/null @@ -1,26 +0,0 @@ -from lib2to3.pgen2.grammar import _DFAS, Grammar -from lib2to3.pytree import _NL, _Convert, _RawNode -from typing import Any, Sequence, Text - -_Context = Sequence[Any] - -class ParseError(Exception): - msg: Text - type: int - value: Text | None - context: _Context - def __init__(self, msg: Text, type: int, value: Text | None, context: _Context) -> None: ... - -class Parser: - grammar: Grammar - convert: _Convert - stack: list[tuple[_DFAS, int, _RawNode]] - rootnode: _NL | None - used_names: set[Text] - def __init__(self, grammar: Grammar, convert: _Convert | None = ...) -> None: ... - def setup(self, start: int | None = ...) -> None: ... - def addtoken(self, type: int, value: Text | None, context: _Context) -> bool: ... - def classify(self, type: int, value: Text | None, context: _Context) -> int: ... - def shift(self, type: int, value: Text | None, newstate: int, context: _Context) -> None: ... - def push(self, type: int, newdfa: _DFAS, newstate: int, context: _Context) -> None: ... - def pop(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/pgen.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/pgen.pyi deleted file mode 100644 index daddcf0cf113..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/pgen.pyi +++ /dev/null @@ -1,46 +0,0 @@ -from _typeshed import StrPath -from lib2to3.pgen2 import grammar -from lib2to3.pgen2.tokenize import _TokenInfo -from typing import IO, Any, Iterable, Iterator, NoReturn, Text - -class PgenGrammar(grammar.Grammar): ... - -class ParserGenerator: - filename: StrPath - stream: IO[Text] - generator: Iterator[_TokenInfo] - first: dict[Text, dict[Text, int]] - def __init__(self, filename: StrPath, stream: IO[Text] | None = ...) -> None: ... - def make_grammar(self) -> PgenGrammar: ... - def make_first(self, c: PgenGrammar, name: Text) -> dict[int, int]: ... - def make_label(self, c: PgenGrammar, label: Text) -> int: ... - def addfirstsets(self) -> None: ... - def calcfirst(self, name: Text) -> None: ... - def parse(self) -> tuple[dict[Text, list[DFAState]], Text]: ... - def make_dfa(self, start: NFAState, finish: NFAState) -> list[DFAState]: ... - def dump_nfa(self, name: Text, start: NFAState, finish: NFAState) -> list[DFAState]: ... - def dump_dfa(self, name: Text, dfa: Iterable[DFAState]) -> None: ... - def simplify_dfa(self, dfa: list[DFAState]) -> None: ... - def parse_rhs(self) -> tuple[NFAState, NFAState]: ... - def parse_alt(self) -> tuple[NFAState, NFAState]: ... - def parse_item(self) -> tuple[NFAState, NFAState]: ... - def parse_atom(self) -> tuple[NFAState, NFAState]: ... - def expect(self, type: int, value: Any | None = ...) -> Text: ... - def gettoken(self) -> None: ... - def raise_error(self, msg: str, *args: Any) -> NoReturn: ... - -class NFAState: - arcs: list[tuple[Text | None, NFAState]] - def __init__(self) -> None: ... - def addarc(self, next: NFAState, label: Text | None = ...) -> None: ... - -class DFAState: - nfaset: dict[NFAState, Any] - isfinal: bool - arcs: dict[Text, DFAState] - def __init__(self, nfaset: dict[NFAState, Any], final: NFAState) -> None: ... - def addarc(self, next: DFAState, label: Text) -> None: ... - def unifystate(self, old: DFAState, new: DFAState) -> None: ... - def __eq__(self, other: DFAState) -> bool: ... # type: ignore[override] - -def generate_grammar(filename: StrPath = ...) -> PgenGrammar: ... diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/token.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/token.pyi deleted file mode 100644 index 967c4df5d721..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/token.pyi +++ /dev/null @@ -1,63 +0,0 @@ -from typing import Text - -ENDMARKER: int -NAME: int -NUMBER: int -STRING: int -NEWLINE: int -INDENT: int -DEDENT: int -LPAR: int -RPAR: int -LSQB: int -RSQB: int -COLON: int -COMMA: int -SEMI: int -PLUS: int -MINUS: int -STAR: int -SLASH: int -VBAR: int -AMPER: int -LESS: int -GREATER: int -EQUAL: int -DOT: int -PERCENT: int -BACKQUOTE: int -LBRACE: int -RBRACE: int -EQEQUAL: int -NOTEQUAL: int -LESSEQUAL: int -GREATEREQUAL: int -TILDE: int -CIRCUMFLEX: int -LEFTSHIFT: int -RIGHTSHIFT: int -DOUBLESTAR: int -PLUSEQUAL: int -MINEQUAL: int -STAREQUAL: int -SLASHEQUAL: int -PERCENTEQUAL: int -AMPEREQUAL: int -VBAREQUAL: int -CIRCUMFLEXEQUAL: int -LEFTSHIFTEQUAL: int -RIGHTSHIFTEQUAL: int -DOUBLESTAREQUAL: int -DOUBLESLASH: int -DOUBLESLASHEQUAL: int -OP: int -COMMENT: int -NL: int -ERRORTOKEN: int -N_TOKENS: int -NT_OFFSET: int -tok_name: dict[int, Text] - -def ISTERMINAL(x: int) -> bool: ... -def ISNONTERMINAL(x: int) -> bool: ... -def ISEOF(x: int) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/tokenize.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/tokenize.pyi deleted file mode 100644 index d93d3f482766..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pgen2/tokenize.pyi +++ /dev/null @@ -1,23 +0,0 @@ -from lib2to3.pgen2.token import * # noqa -from typing import Callable, Iterable, Iterator, Text - -_Coord = tuple[int, int] -_TokenEater = Callable[[int, Text, _Coord, _Coord, Text], None] -_TokenInfo = tuple[int, Text, _Coord, _Coord, Text] - -class TokenError(Exception): ... -class StopTokenizing(Exception): ... - -def tokenize(readline: Callable[[], Text], tokeneater: _TokenEater = ...) -> None: ... - -class Untokenizer: - tokens: list[Text] - prev_row: int - prev_col: int - def __init__(self) -> None: ... - def add_whitespace(self, start: _Coord) -> None: ... - def untokenize(self, iterable: Iterable[_TokenInfo]) -> Text: ... - def compat(self, token: tuple[int, Text], iterable: Iterable[_TokenInfo]) -> None: ... - -def untokenize(iterable: Iterable[_TokenInfo]) -> Text: ... -def generate_tokens(readline: Callable[[], Text]) -> Iterator[_TokenInfo]: ... diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pygram.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pygram.pyi deleted file mode 100644 index bf96a55c41b3..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pygram.pyi +++ /dev/null @@ -1,113 +0,0 @@ -from lib2to3.pgen2.grammar import Grammar - -class Symbols: - def __init__(self, grammar: Grammar) -> None: ... - -class python_symbols(Symbols): - and_expr: int - and_test: int - annassign: int - arglist: int - argument: int - arith_expr: int - assert_stmt: int - async_funcdef: int - async_stmt: int - atom: int - augassign: int - break_stmt: int - classdef: int - comp_for: int - comp_if: int - comp_iter: int - comp_op: int - comparison: int - compound_stmt: int - continue_stmt: int - decorated: int - decorator: int - decorators: int - del_stmt: int - dictsetmaker: int - dotted_as_name: int - dotted_as_names: int - dotted_name: int - encoding_decl: int - eval_input: int - except_clause: int - exec_stmt: int - expr: int - expr_stmt: int - exprlist: int - factor: int - file_input: int - flow_stmt: int - for_stmt: int - funcdef: int - global_stmt: int - if_stmt: int - import_as_name: int - import_as_names: int - import_from: int - import_name: int - import_stmt: int - lambdef: int - listmaker: int - not_test: int - old_lambdef: int - old_test: int - or_test: int - parameters: int - pass_stmt: int - power: int - print_stmt: int - raise_stmt: int - return_stmt: int - shift_expr: int - simple_stmt: int - single_input: int - sliceop: int - small_stmt: int - star_expr: int - stmt: int - subscript: int - subscriptlist: int - suite: int - term: int - test: int - testlist: int - testlist1: int - testlist_gexp: int - testlist_safe: int - testlist_star_expr: int - tfpdef: int - tfplist: int - tname: int - trailer: int - try_stmt: int - typedargslist: int - varargslist: int - vfpdef: int - vfplist: int - vname: int - while_stmt: int - with_item: int - with_stmt: int - with_var: int - xor_expr: int - yield_arg: int - yield_expr: int - yield_stmt: int - -class pattern_symbols(Symbols): - Alternative: int - Alternatives: int - Details: int - Matcher: int - NegatedUnit: int - Repeater: int - Unit: int - -python_grammar: Grammar -python_grammar_no_print_statement: Grammar -pattern_grammar: Grammar diff --git a/mypy/typeshed/stdlib/@python2/lib2to3/pytree.pyi b/mypy/typeshed/stdlib/@python2/lib2to3/pytree.pyi deleted file mode 100644 index a3969e60d95e..000000000000 --- a/mypy/typeshed/stdlib/@python2/lib2to3/pytree.pyi +++ /dev/null @@ -1,91 +0,0 @@ -from _typeshed import Self -from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Iterator, Text, TypeVar - -_P = TypeVar("_P") -_NL = Node | Leaf -_Context = tuple[Text, int, int] -_Results = dict[Text, _NL] -_RawNode = tuple[int, Text, _Context, list[_NL] | None] -_Convert = Callable[[Grammar, _RawNode], Any] - -HUGE: int - -def type_repr(type_num: int) -> Text: ... - -class Base: - type: int - parent: Node | None - prefix: Text - children: list[_NL] - was_changed: bool - was_checked: bool - def __eq__(self, other: object) -> bool: ... - def _eq(self: _P, other: _P) -> bool: ... - def clone(self: Self) -> Self: ... - def post_order(self) -> Iterator[_NL]: ... - def pre_order(self) -> Iterator[_NL]: ... - def replace(self, new: _NL | list[_NL]) -> None: ... - def get_lineno(self) -> int: ... - def changed(self) -> None: ... - def remove(self) -> int | None: ... - @property - def next_sibling(self) -> _NL | None: ... - @property - def prev_sibling(self) -> _NL | None: ... - def leaves(self) -> Iterator[Leaf]: ... - def depth(self) -> int: ... - def get_suffix(self) -> Text: ... - def get_prefix(self) -> Text: ... - def set_prefix(self, prefix: Text) -> None: ... - -class Node(Base): - fixers_applied: list[Any] - def __init__( - self, - type: int, - children: list[_NL], - context: Any | None = ..., - prefix: Text | None = ..., - fixers_applied: list[Any] | None = ..., - ) -> None: ... - def set_child(self, i: int, child: _NL) -> None: ... - def insert_child(self, i: int, child: _NL) -> None: ... - def append_child(self, child: _NL) -> None: ... - -class Leaf(Base): - lineno: int - column: int - value: Text - fixers_applied: list[Any] - def __init__( - self, type: int, value: Text, context: _Context | None = ..., prefix: Text | None = ..., fixers_applied: list[Any] = ... - ) -> None: ... - -def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... - -class BasePattern: - type: int - content: Text | None - name: Text | None - def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns - def match(self, node: _NL, results: _Results | None = ...) -> bool: ... - def match_seq(self, nodes: list[_NL], results: _Results | None = ...) -> bool: ... - def generate_matches(self, nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ... - -class LeafPattern(BasePattern): - def __init__(self, type: int | None = ..., content: Text | None = ..., name: Text | None = ...) -> None: ... - -class NodePattern(BasePattern): - wildcards: bool - def __init__(self, type: int | None = ..., content: Text | None = ..., name: Text | None = ...) -> None: ... - -class WildcardPattern(BasePattern): - min: int - max: int - def __init__(self, content: Text | None = ..., min: int = ..., max: int = ..., name: Text | None = ...) -> None: ... - -class NegatedPattern(BasePattern): - def __init__(self, content: Text | None = ...) -> None: ... - -def generate_matches(patterns: list[BasePattern], nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ... diff --git a/mypy/typeshed/stdlib/@python2/linecache.pyi b/mypy/typeshed/stdlib/@python2/linecache.pyi deleted file mode 100644 index 68c907499867..000000000000 --- a/mypy/typeshed/stdlib/@python2/linecache.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Any, Text - -_ModuleGlobals = dict[str, Any] - -def getline(filename: Text, lineno: int, module_globals: _ModuleGlobals | None = ...) -> str: ... -def clearcache() -> None: ... -def getlines(filename: Text, module_globals: _ModuleGlobals | None = ...) -> list[str]: ... -def checkcache(filename: Text | None = ...) -> None: ... -def updatecache(filename: Text, module_globals: _ModuleGlobals | None = ...) -> list[str]: ... diff --git a/mypy/typeshed/stdlib/@python2/locale.pyi b/mypy/typeshed/stdlib/@python2/locale.pyi deleted file mode 100644 index c75d865b8746..000000000000 --- a/mypy/typeshed/stdlib/@python2/locale.pyi +++ /dev/null @@ -1,96 +0,0 @@ -# workaround for mypy#2010 -from __builtin__ import str as _str -from decimal import Decimal -from typing import Any, Callable, Iterable, Mapping, Sequence - -CODESET: int -D_T_FMT: int -D_FMT: int -T_FMT: int -T_FMT_AMPM: int - -DAY_1: int -DAY_2: int -DAY_3: int -DAY_4: int -DAY_5: int -DAY_6: int -DAY_7: int -ABDAY_1: int -ABDAY_2: int -ABDAY_3: int -ABDAY_4: int -ABDAY_5: int -ABDAY_6: int -ABDAY_7: int - -MON_1: int -MON_2: int -MON_3: int -MON_4: int -MON_5: int -MON_6: int -MON_7: int -MON_8: int -MON_9: int -MON_10: int -MON_11: int -MON_12: int -ABMON_1: int -ABMON_2: int -ABMON_3: int -ABMON_4: int -ABMON_5: int -ABMON_6: int -ABMON_7: int -ABMON_8: int -ABMON_9: int -ABMON_10: int -ABMON_11: int -ABMON_12: int - -RADIXCHAR: int -THOUSEP: int -YESEXPR: int -NOEXPR: int -CRNCYSTR: int - -ERA: int -ERA_D_T_FMT: int -ERA_D_FMT: int -ERA_T_FMT: int - -ALT_DIGITS: int - -LC_CTYPE: int -LC_COLLATE: int -LC_TIME: int -LC_MONETARY: int -LC_MESSAGES: int -LC_NUMERIC: int -LC_ALL: int - -CHAR_MAX: int - -class Error(Exception): ... - -def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... -def localeconv() -> Mapping[_str, int | _str | list[int]]: ... -def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... -def getlocale(category: int = ...) -> Sequence[_str]: ... -def getpreferredencoding(do_setlocale: bool = ...) -> _str: ... -def normalize(localename: _str) -> _str: ... -def resetlocale(category: int = ...) -> None: ... -def strcoll(string1: _str, string2: _str) -> int: ... -def strxfrm(string: _str) -> _str: ... -def format(percent: _str, value: float | Decimal, grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... -def format_string(f: _str, val: Any, grouping: bool = ...) -> _str: ... -def currency(val: int | float | Decimal, symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ... -def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... -def atoi(string: _str) -> int: ... -def str(val: float) -> _str: ... - -locale_alias: dict[_str, _str] # undocumented -locale_encoding_alias: dict[_str, _str] # undocumented -windows_locale: dict[int, _str] # undocumented diff --git a/mypy/typeshed/stdlib/@python2/logging/__init__.pyi b/mypy/typeshed/stdlib/@python2/logging/__init__.pyi deleted file mode 100644 index 059906d139ee..000000000000 --- a/mypy/typeshed/stdlib/@python2/logging/__init__.pyi +++ /dev/null @@ -1,262 +0,0 @@ -import threading -from _typeshed import StrPath, SupportsWrite -from time import struct_time -from types import FrameType, TracebackType -from typing import IO, Any, Callable, Generic, Mapping, MutableMapping, Sequence, Text, TypeVar, Union, overload - -_SysExcInfoType = Union[tuple[type, BaseException, TracebackType | None], tuple[None, None, None]] -_ExcInfoType = None | bool | _SysExcInfoType -_ArgsType = Union[tuple[Any, ...], Mapping[str, Any]] -_FilterType = Filter | Callable[[LogRecord], int] -_Level = int | Text - -raiseExceptions: bool -logThreads: bool -logMultiprocessing: bool -logProcesses: bool -_srcfile: str | None - -def currentframe() -> FrameType: ... - -_levelNames: dict[int | str, str | int] # Union[int:str, str:int] - -class Filterer(object): - filters: list[Filter] - def __init__(self) -> None: ... - def addFilter(self, filter: _FilterType) -> None: ... - def removeFilter(self, filter: _FilterType) -> None: ... - def filter(self, record: LogRecord) -> bool: ... - -class Logger(Filterer): - name: str - level: int - parent: Logger | PlaceHolder - propagate: bool - handlers: list[Handler] - disabled: int - def __init__(self, name: str, level: _Level = ...) -> None: ... - def setLevel(self, level: _Level) -> None: ... - def isEnabledFor(self, level: int) -> bool: ... - def getEffectiveLevel(self) -> int: ... - def getChild(self, suffix: str) -> Logger: ... - def debug( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def info( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def warning( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - warn = warning - def error( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def critical( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - fatal = critical - def log( - self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def exception( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def _log( - self, level: int, msg: Any, args: _ArgsType, exc_info: _ExcInfoType | None = ..., extra: dict[str, Any] | None = ... - ) -> None: ... # undocumented - def filter(self, record: LogRecord) -> bool: ... - def addHandler(self, hdlr: Handler) -> None: ... - def removeHandler(self, hdlr: Handler) -> None: ... - def findCaller(self) -> tuple[str, int, str]: ... - def handle(self, record: LogRecord) -> None: ... - def makeRecord( - self, - name: str, - level: int, - fn: str, - lno: int, - msg: Any, - args: _ArgsType, - exc_info: _SysExcInfoType | None, - func: str | None = ..., - extra: Mapping[str, Any] | None = ..., - ) -> LogRecord: ... - -CRITICAL: int -FATAL: int -ERROR: int -WARNING: int -WARN: int -INFO: int -DEBUG: int -NOTSET: int - -class Handler(Filterer): - level: int # undocumented - formatter: Formatter | None # undocumented - lock: threading.Lock | None # undocumented - name: str | None # undocumented - def __init__(self, level: _Level = ...) -> None: ... - def createLock(self) -> None: ... - def acquire(self) -> None: ... - def release(self) -> None: ... - def setLevel(self, level: _Level) -> None: ... - def setFormatter(self, fmt: Formatter) -> None: ... - def filter(self, record: LogRecord) -> bool: ... - def flush(self) -> None: ... - def close(self) -> None: ... - def handle(self, record: LogRecord) -> None: ... - def handleError(self, record: LogRecord) -> None: ... - def format(self, record: LogRecord) -> str: ... - def emit(self, record: LogRecord) -> None: ... - -class Formatter: - converter: Callable[[float | None], struct_time] - _fmt: str | None - datefmt: str | None - def __init__(self, fmt: str | None = ..., datefmt: str | None = ...) -> None: ... - def format(self, record: LogRecord) -> str: ... - def formatTime(self, record: LogRecord, datefmt: str | None = ...) -> str: ... - def formatException(self, ei: _SysExcInfoType) -> str: ... - -class Filter: - def __init__(self, name: str = ...) -> None: ... - def filter(self, record: LogRecord) -> bool: ... - -class LogRecord: - args: _ArgsType - asctime: str - created: int - exc_info: _SysExcInfoType | None - exc_text: str | None - filename: str - funcName: str - levelname: str - levelno: int - lineno: int - module: str - msecs: int - message: str - msg: str - name: str - pathname: str - process: int - processName: str - relativeCreated: int - thread: int - threadName: str - def __init__( - self, - name: str, - level: int, - pathname: str, - lineno: int, - msg: Any, - args: _ArgsType, - exc_info: _SysExcInfoType | None, - func: str | None = ..., - ) -> None: ... - def getMessage(self) -> str: ... - -_L = TypeVar("_L", Logger, LoggerAdapter[Logger], LoggerAdapter[Any]) - -class LoggerAdapter(Generic[_L]): - logger: _L - extra: Mapping[str, Any] - def __init__(self, logger: _L, extra: Mapping[str, Any]) -> None: ... - def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> tuple[Any, MutableMapping[str, Any]]: ... - def debug( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def info( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def warning( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def error( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def exception( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def critical( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def log( - self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any - ) -> None: ... - def isEnabledFor(self, level: int) -> bool: ... - -@overload -def getLogger() -> Logger: ... -@overload -def getLogger(name: Text | str) -> Logger: ... -def getLoggerClass() -> type: ... -def debug(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any) -> None: ... -def info(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any) -> None: ... -def warning(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any) -> None: ... - -warn = warning - -def error(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any) -> None: ... -def critical(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any) -> None: ... -def exception(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any) -> None: ... -def log( - level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: dict[str, Any] | None = ..., **kwargs: Any -) -> None: ... - -fatal = critical - -def disable(level: int) -> None: ... -def addLevelName(level: int, levelName: str) -> None: ... -def getLevelName(level: int | str) -> Any: ... -def makeLogRecord(dict: Mapping[str, Any]) -> LogRecord: ... -@overload -def basicConfig() -> None: ... -@overload -def basicConfig( - *, - filename: str | None = ..., - filemode: str = ..., - format: str = ..., - datefmt: str | None = ..., - level: _Level | None = ..., - stream: IO[str] = ..., -) -> None: ... -def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented -def setLoggerClass(klass: type) -> None: ... -def captureWarnings(capture: bool) -> None: ... - -_StreamT = TypeVar("_StreamT", bound=SupportsWrite[str]) - -class StreamHandler(Handler, Generic[_StreamT]): - stream: _StreamT # undocumented - @overload - def __init__(self: StreamHandler[IO[str]], stream: None = ...) -> None: ... - @overload - def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ... - -class FileHandler(StreamHandler): - baseFilename: str # undocumented - mode: str # undocumented - encoding: str | None # undocumented - delay: bool # undocumented - def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ... - def _open(self) -> IO[Any]: ... - -class NullHandler(Handler): ... - -class PlaceHolder: - def __init__(self, alogger: Logger) -> None: ... - def append(self, alogger: Logger) -> None: ... - -# Below aren't in module docs but still visible - -class RootLogger(Logger): - def __init__(self, level: int) -> None: ... - -root: RootLogger - -BASIC_FORMAT: str diff --git a/mypy/typeshed/stdlib/@python2/logging/config.pyi b/mypy/typeshed/stdlib/@python2/logging/config.pyi deleted file mode 100644 index 5597347d0961..000000000000 --- a/mypy/typeshed/stdlib/@python2/logging/config.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from _typeshed import StrPath -from threading import Thread -from typing import IO, Any - -_Path = StrPath - -def dictConfig(config: dict[str, Any]) -> None: ... -def fileConfig(fname: str | IO[str], defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ...) -> None: ... -def listen(port: int = ...) -> Thread: ... -def stopListening() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/logging/handlers.pyi b/mypy/typeshed/stdlib/@python2/logging/handlers.pyi deleted file mode 100644 index 212980e32ac6..000000000000 --- a/mypy/typeshed/stdlib/@python2/logging/handlers.pyi +++ /dev/null @@ -1,129 +0,0 @@ -from _typeshed import StrPath -from logging import FileHandler, Handler, LogRecord -from socket import SocketKind, SocketType -from typing import Any, ClassVar - -DEFAULT_TCP_LOGGING_PORT: int -DEFAULT_UDP_LOGGING_PORT: int -DEFAULT_HTTP_LOGGING_PORT: int -DEFAULT_SOAP_LOGGING_PORT: int -SYSLOG_UDP_PORT: int -SYSLOG_TCP_PORT: int - -class WatchedFileHandler(FileHandler): - dev: int - ino: int - def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ... - def _statstream(self) -> None: ... - -class RotatingFileHandler(Handler): - def __init__( - self, - filename: str, - mode: str = ..., - maxBytes: int = ..., - backupCount: int = ..., - encoding: str | None = ..., - delay: bool = ..., - ) -> None: ... - def doRollover(self) -> None: ... - -class TimedRotatingFileHandler(Handler): - def __init__( - self, - filename: str, - when: str = ..., - interval: int = ..., - backupCount: int = ..., - encoding: str | None = ..., - delay: bool = ..., - utc: bool = ..., - ) -> None: ... - def doRollover(self) -> None: ... - -class SocketHandler(Handler): - retryStart: float - retryFactor: float - retryMax: float - def __init__(self, host: str, port: int) -> None: ... - def makeSocket(self, timeout: float = ...) -> SocketType: ... # timeout is undocumented - def makePickle(self, record: LogRecord) -> bytes: ... - def send(self, s: bytes) -> None: ... - def createSocket(self) -> None: ... - -class DatagramHandler(SocketHandler): - def makeSocket(self) -> SocketType: ... # type: ignore[override] - -class SysLogHandler(Handler): - LOG_EMERG: int - LOG_ALERT: int - LOG_CRIT: int - LOG_ERR: int - LOG_WARNING: int - LOG_NOTICE: int - LOG_INFO: int - LOG_DEBUG: int - - LOG_KERN: int - LOG_USER: int - LOG_MAIL: int - LOG_DAEMON: int - LOG_AUTH: int - LOG_SYSLOG: int - LOG_LPR: int - LOG_NEWS: int - LOG_UUCP: int - LOG_CRON: int - LOG_AUTHPRIV: int - LOG_FTP: int - LOG_LOCAL0: int - LOG_LOCAL1: int - LOG_LOCAL2: int - LOG_LOCAL3: int - LOG_LOCAL4: int - LOG_LOCAL5: int - LOG_LOCAL6: int - LOG_LOCAL7: int - address: tuple[str, int] | str # undocumented - unixsocket: bool # undocumented - socktype: SocketKind # undocumented - facility: int # undocumented - priority_names: ClassVar[dict[str, int]] # undocumented - facility_names: ClassVar[dict[str, int]] # undocumented - priority_map: ClassVar[dict[str, str]] # undocumented - def __init__(self, address: tuple[str, int] | str = ..., facility: int = ..., socktype: SocketKind | None = ...) -> None: ... - def encodePriority(self, facility: int | str, priority: int | str) -> int: ... - def mapPriority(self, levelName: str) -> str: ... - -class NTEventLogHandler(Handler): - def __init__(self, appname: str, dllname: str | None = ..., logtype: str = ...) -> None: ... - def getEventCategory(self, record: LogRecord) -> int: ... - # TODO correct return value? - def getEventType(self, record: LogRecord) -> int: ... - def getMessageID(self, record: LogRecord) -> int: ... - -class SMTPHandler(Handler): - # TODO `secure` can also be an empty tuple - def __init__( - self, - mailhost: str | tuple[str, int], - fromaddr: str, - toaddrs: list[str], - subject: str, - credentials: tuple[str, str] | None = ..., - secure: tuple[str] | tuple[str, str] | None = ..., - ) -> None: ... - def getSubject(self, record: LogRecord) -> str: ... - -class BufferingHandler(Handler): - buffer: list[LogRecord] - def __init__(self, capacity: int) -> None: ... - def shouldFlush(self, record: LogRecord) -> bool: ... - -class MemoryHandler(BufferingHandler): - def __init__(self, capacity: int, flushLevel: int = ..., target: Handler | None = ...) -> None: ... - def setTarget(self, target: Handler) -> None: ... - -class HTTPHandler(Handler): - def __init__(self, host: str, url: str, method: str = ...) -> None: ... - def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ... diff --git a/mypy/typeshed/stdlib/@python2/macpath.pyi b/mypy/typeshed/stdlib/@python2/macpath.pyi deleted file mode 100644 index 73d55b15328f..000000000000 --- a/mypy/typeshed/stdlib/@python2/macpath.pyi +++ /dev/null @@ -1,55 +0,0 @@ -from genericpath import ( - commonprefix as commonprefix, - exists as exists, - getatime as getatime, - getctime as getctime, - getmtime as getmtime, - getsize as getsize, - isdir as isdir, - isfile as isfile, -) - -# Re-export common definitions from posixpath to reduce duplication -from posixpath import ( - abspath as abspath, - curdir as curdir, - defpath as defpath, - devnull as devnull, - expanduser as expanduser, - expandvars as expandvars, - extsep as extsep, - isabs as isabs, - lexists as lexists, - pardir as pardir, - pathsep as pathsep, - sep as sep, - splitdrive as splitdrive, - splitext as splitext, - supports_unicode_filenames as supports_unicode_filenames, -) -from typing import AnyStr, Text, overload - -altsep: str | None - -def basename(s: AnyStr) -> AnyStr: ... -def dirname(s: AnyStr) -> AnyStr: ... -def normcase(path: AnyStr) -> AnyStr: ... -def normpath(s: AnyStr) -> AnyStr: ... -def realpath(path: AnyStr) -> AnyStr: ... -def islink(s: Text) -> bool: ... - -# Make sure signatures are disjunct, and allow combinations of bytes and unicode. -# (Since Python 2 allows that, too) -# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in -# a type error. -@overload -def join(__p1: bytes, *p: bytes) -> bytes: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... -@overload -def join(__p1: Text, *p: Text) -> Text: ... -def split(s: AnyStr) -> tuple[AnyStr, AnyStr]: ... diff --git a/mypy/typeshed/stdlib/@python2/macurl2path.pyi b/mypy/typeshed/stdlib/@python2/macurl2path.pyi deleted file mode 100644 index 6aac6dfeace5..000000000000 --- a/mypy/typeshed/stdlib/@python2/macurl2path.pyi +++ /dev/null @@ -1,3 +0,0 @@ -def url2pathname(pathname: str) -> str: ... -def pathname2url(pathname: str) -> str: ... -def _pncomp2url(component: str | bytes) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/mailbox.pyi b/mypy/typeshed/stdlib/@python2/mailbox.pyi deleted file mode 100644 index 9d3f4d866aba..000000000000 --- a/mypy/typeshed/stdlib/@python2/mailbox.pyi +++ /dev/null @@ -1,168 +0,0 @@ -import email.message -from types import TracebackType -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Mapping, Protocol, Sequence, Text, TypeVar, overload -from typing_extensions import Literal - -_T = TypeVar("_T") -_MessageT = TypeVar("_MessageT", bound=Message) -_MessageData = email.message.Message | bytes | str | IO[str] | IO[bytes] - -class _HasIteritems(Protocol): - def iteritems(self) -> Iterator[tuple[str, _MessageData]]: ... - -class _HasItems(Protocol): - def items(self) -> Iterator[tuple[str, _MessageData]]: ... - -linesep: bytes - -class Mailbox(Generic[_MessageT]): - - _path: bytes | str # undocumented - _factory: Callable[[IO[Any]], _MessageT] | None # undocumented - def __init__(self, path: Text, factory: Callable[[IO[Any]], _MessageT] | None = ..., create: bool = ...) -> None: ... - def add(self, message: _MessageData) -> str: ... - def remove(self, key: str) -> None: ... - def __delitem__(self, key: str) -> None: ... - def discard(self, key: str) -> None: ... - def __setitem__(self, key: str, message: _MessageData) -> None: ... - @overload - def get(self, key: str, default: None = ...) -> _MessageT | None: ... - @overload - def get(self, key: str, default: _T) -> _MessageT | _T: ... - def __getitem__(self, key: str) -> _MessageT: ... - def get_message(self, key: str) -> _MessageT: ... - def get_string(self, key: str) -> str: ... - def get_bytes(self, key: str) -> bytes: ... - # As '_ProxyFile' doesn't implement the full IO spec, and BytesIO is incompatible with it, get_file return is Any here - def get_file(self, key: str) -> Any: ... - def iterkeys(self) -> Iterator[str]: ... - def keys(self) -> list[str]: ... - def itervalues(self) -> Iterator[_MessageT]: ... - def __iter__(self) -> Iterator[_MessageT]: ... - def values(self) -> list[_MessageT]: ... - def iteritems(self) -> Iterator[tuple[str, _MessageT]]: ... - def items(self) -> list[tuple[str, _MessageT]]: ... - def __contains__(self, key: str) -> bool: ... - def __len__(self) -> int: ... - def clear(self) -> None: ... - @overload - def pop(self, key: str, default: None = ...) -> _MessageT | None: ... - @overload - def pop(self, key: str, default: _T = ...) -> _MessageT | _T: ... - def popitem(self) -> tuple[str, _MessageT]: ... - def update(self, arg: _HasIteritems | _HasItems | Iterable[tuple[str, _MessageData]] | None = ...) -> None: ... - def flush(self) -> None: ... - def lock(self) -> None: ... - def unlock(self) -> None: ... - def close(self) -> None: ... - -class Maildir(Mailbox[MaildirMessage]): - - colon: str - def __init__(self, dirname: Text, factory: Callable[[IO[Any]], MaildirMessage] | None = ..., create: bool = ...) -> None: ... - def get_file(self, key: str) -> _ProxyFile[bytes]: ... - def list_folders(self) -> list[str]: ... - def get_folder(self, folder: Text) -> Maildir: ... - def add_folder(self, folder: Text) -> Maildir: ... - def remove_folder(self, folder: Text) -> None: ... - def clean(self) -> None: ... - def next(self) -> str | None: ... - -class _singlefileMailbox(Mailbox[_MessageT]): ... - -class _mboxMMDF(_singlefileMailbox[_MessageT]): - def get_file(self, key: str, from_: bool = ...) -> _PartialFile[bytes]: ... - def get_bytes(self, key: str, from_: bool = ...) -> bytes: ... - def get_string(self, key: str, from_: bool = ...) -> str: ... - -class mbox(_mboxMMDF[mboxMessage]): - def __init__(self, path: Text, factory: Callable[[IO[Any]], mboxMessage] | None = ..., create: bool = ...) -> None: ... - -class MMDF(_mboxMMDF[MMDFMessage]): - def __init__(self, path: Text, factory: Callable[[IO[Any]], MMDFMessage] | None = ..., create: bool = ...) -> None: ... - -class MH(Mailbox[MHMessage]): - def __init__(self, path: Text, factory: Callable[[IO[Any]], MHMessage] | None = ..., create: bool = ...) -> None: ... - def get_file(self, key: str) -> _ProxyFile[bytes]: ... - def list_folders(self) -> list[str]: ... - def get_folder(self, folder: Text) -> MH: ... - def add_folder(self, folder: Text) -> MH: ... - def remove_folder(self, folder: Text) -> None: ... - def get_sequences(self) -> dict[str, list[int]]: ... - def set_sequences(self, sequences: Mapping[str, Sequence[int]]) -> None: ... - def pack(self) -> None: ... - -class Babyl(_singlefileMailbox[BabylMessage]): - def __init__(self, path: Text, factory: Callable[[IO[Any]], BabylMessage] | None = ..., create: bool = ...) -> None: ... - def get_file(self, key: str) -> IO[bytes]: ... - def get_labels(self) -> list[str]: ... - -class Message(email.message.Message): - def __init__(self, message: _MessageData | None = ...) -> None: ... - -class MaildirMessage(Message): - def get_subdir(self) -> str: ... - def set_subdir(self, subdir: Literal["new", "cur"]) -> None: ... - def get_flags(self) -> str: ... - def set_flags(self, flags: Iterable[str]) -> None: ... - def add_flag(self, flag: str) -> None: ... - def remove_flag(self, flag: str) -> None: ... - def get_date(self) -> int: ... - def set_date(self, date: float) -> None: ... - def get_info(self) -> str: ... - def set_info(self, info: str) -> None: ... - -class _mboxMMDFMessage(Message): - def get_from(self) -> str: ... - def set_from(self, from_: str, time_: bool | tuple[int, int, int, int, int, int, int, int, int] | None = ...) -> None: ... - def get_flags(self) -> str: ... - def set_flags(self, flags: Iterable[str]) -> None: ... - def add_flag(self, flag: str) -> None: ... - def remove_flag(self, flag: str) -> None: ... - -class mboxMessage(_mboxMMDFMessage): ... - -class MHMessage(Message): - def get_sequences(self) -> list[str]: ... - def set_sequences(self, sequences: Iterable[str]) -> None: ... - def add_sequence(self, sequence: str) -> None: ... - def remove_sequence(self, sequence: str) -> None: ... - -class BabylMessage(Message): - def get_labels(self) -> list[str]: ... - def set_labels(self, labels: Iterable[str]) -> None: ... - def add_label(self, label: str) -> None: ... - def remove_label(self, label: str) -> None: ... - def get_visible(self) -> Message: ... - def set_visible(self, visible: _MessageData) -> None: ... - def update_visible(self) -> None: ... - -class MMDFMessage(_mboxMMDFMessage): ... - -class _ProxyFile(Generic[AnyStr]): - def __init__(self, f: IO[AnyStr], pos: int | None = ...) -> None: ... - def read(self, size: int | None = ...) -> AnyStr: ... - def read1(self, size: int | None = ...) -> AnyStr: ... - def readline(self, size: int | None = ...) -> AnyStr: ... - def readlines(self, sizehint: int | None = ...) -> list[AnyStr]: ... - def __iter__(self) -> Iterator[AnyStr]: ... - def tell(self) -> int: ... - def seek(self, offset: int, whence: int = ...) -> None: ... - def close(self) -> None: ... - def __enter__(self) -> _ProxyFile[AnyStr]: ... - def __exit__(self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... - def readable(self) -> bool: ... - def writable(self) -> bool: ... - def seekable(self) -> bool: ... - def flush(self) -> None: ... - @property - def closed(self) -> bool: ... - -class _PartialFile(_ProxyFile[AnyStr]): - def __init__(self, f: IO[AnyStr], start: int | None = ..., stop: int | None = ...) -> None: ... - -class Error(Exception): ... -class NoSuchMailboxError(Error): ... -class NotEmptyError(Error): ... -class ExternalClashError(Error): ... -class FormatError(Error): ... diff --git a/mypy/typeshed/stdlib/@python2/mailcap.pyi b/mypy/typeshed/stdlib/@python2/mailcap.pyi deleted file mode 100644 index 6e0c918280ad..000000000000 --- a/mypy/typeshed/stdlib/@python2/mailcap.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import Mapping, Sequence - -_Cap = dict[str, str | int] - -def findmatch( - caps: Mapping[str, list[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... -) -> tuple[str | None, _Cap | None]: ... -def getcaps() -> dict[str, list[_Cap]]: ... diff --git a/mypy/typeshed/stdlib/@python2/markupbase.pyi b/mypy/typeshed/stdlib/@python2/markupbase.pyi deleted file mode 100644 index 869c341b66aa..000000000000 --- a/mypy/typeshed/stdlib/@python2/markupbase.pyi +++ /dev/null @@ -1,6 +0,0 @@ -class ParserBase(object): - def __init__(self) -> None: ... - def error(self, message: str) -> None: ... - def reset(self) -> None: ... - def getpos(self) -> tuple[int, int]: ... - def unknown_decl(self, data: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/marshal.pyi b/mypy/typeshed/stdlib/@python2/marshal.pyi deleted file mode 100644 index b2fde674a647..000000000000 --- a/mypy/typeshed/stdlib/@python2/marshal.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import IO, Any - -version: int - -def dump(__value: Any, __file: IO[Any], __version: int = ...) -> None: ... -def load(__file: IO[Any]) -> Any: ... -def dumps(__value: Any, __version: int = ...) -> bytes: ... -def loads(__bytes: bytes) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/math.pyi b/mypy/typeshed/stdlib/@python2/math.pyi deleted file mode 100644 index 643242a73fa9..000000000000 --- a/mypy/typeshed/stdlib/@python2/math.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from typing import Iterable, SupportsFloat, SupportsInt - -e: float -pi: float - -def acos(__x: SupportsFloat) -> float: ... -def acosh(__x: SupportsFloat) -> float: ... -def asin(__x: SupportsFloat) -> float: ... -def asinh(__x: SupportsFloat) -> float: ... -def atan(__x: SupportsFloat) -> float: ... -def atan2(__y: SupportsFloat, __x: SupportsFloat) -> float: ... -def atanh(__x: SupportsFloat) -> float: ... -def ceil(__x: SupportsFloat) -> float: ... -def copysign(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -def cos(__x: SupportsFloat) -> float: ... -def cosh(__x: SupportsFloat) -> float: ... -def degrees(__x: SupportsFloat) -> float: ... -def erf(__x: SupportsFloat) -> float: ... -def erfc(__x: SupportsFloat) -> float: ... -def exp(__x: SupportsFloat) -> float: ... -def expm1(__x: SupportsFloat) -> float: ... -def fabs(__x: SupportsFloat) -> float: ... -def factorial(__x: SupportsInt) -> int: ... -def floor(__x: SupportsFloat) -> float: ... -def fmod(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -def frexp(__x: SupportsFloat) -> tuple[float, int]: ... -def fsum(__seq: Iterable[float]) -> float: ... -def gamma(__x: SupportsFloat) -> float: ... -def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -def isinf(__x: SupportsFloat) -> bool: ... -def isnan(__x: SupportsFloat) -> bool: ... -def ldexp(__x: SupportsFloat, __i: int) -> float: ... -def lgamma(__x: SupportsFloat) -> float: ... -def log(x: SupportsFloat, base: SupportsFloat = ...) -> float: ... -def log10(__x: SupportsFloat) -> float: ... -def log1p(__x: SupportsFloat) -> float: ... -def modf(__x: SupportsFloat) -> tuple[float, float]: ... -def pow(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -def radians(__x: SupportsFloat) -> float: ... -def sin(__x: SupportsFloat) -> float: ... -def sinh(__x: SupportsFloat) -> float: ... -def sqrt(__x: SupportsFloat) -> float: ... -def tan(__x: SupportsFloat) -> float: ... -def tanh(__x: SupportsFloat) -> float: ... -def trunc(__x: SupportsFloat) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/md5.pyi b/mypy/typeshed/stdlib/@python2/md5.pyi deleted file mode 100644 index 371f61135b7e..000000000000 --- a/mypy/typeshed/stdlib/@python2/md5.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from hashlib import md5 as md5 - -new = md5 -blocksize: int -digest_size: int diff --git a/mypy/typeshed/stdlib/@python2/mimetools.pyi b/mypy/typeshed/stdlib/@python2/mimetools.pyi deleted file mode 100644 index 3c6cbfcbacae..000000000000 --- a/mypy/typeshed/stdlib/@python2/mimetools.pyi +++ /dev/null @@ -1,27 +0,0 @@ -import rfc822 -from typing import Any - -class Message(rfc822.Message): - encodingheader: Any - typeheader: Any - def __init__(self, fp, seekable: int = ...): ... - plisttext: Any - type: Any - maintype: Any - subtype: Any - def parsetype(self): ... - plist: Any - def parseplist(self): ... - def getplist(self): ... - def getparam(self, name): ... - def getparamnames(self): ... - def getencoding(self): ... - def gettype(self): ... - def getmaintype(self): ... - def getsubtype(self): ... - -def choose_boundary(): ... -def decode(input, output, encoding): ... -def encode(input, output, encoding): ... -def copyliteral(input, output): ... -def copybinary(input, output): ... diff --git a/mypy/typeshed/stdlib/@python2/mimetypes.pyi b/mypy/typeshed/stdlib/@python2/mimetypes.pyi deleted file mode 100644 index a7cddca65921..000000000000 --- a/mypy/typeshed/stdlib/@python2/mimetypes.pyi +++ /dev/null @@ -1,30 +0,0 @@ -import sys -from typing import IO, Sequence, Text - -def guess_type(url: Text, strict: bool = ...) -> tuple[str | None, str | None]: ... -def guess_all_extensions(type: str, strict: bool = ...) -> list[str]: ... -def guess_extension(type: str, strict: bool = ...) -> str | None: ... -def init(files: Sequence[str] | None = ...) -> None: ... -def read_mime_types(file: str) -> dict[str, str] | None: ... -def add_type(type: str, ext: str, strict: bool = ...) -> None: ... - -inited: bool -knownfiles: list[str] -suffix_map: dict[str, str] -encodings_map: dict[str, str] -types_map: dict[str, str] -common_types: dict[str, str] - -class MimeTypes: - suffix_map: dict[str, str] - encodings_map: dict[str, str] - types_map: tuple[dict[str, str], dict[str, str]] - types_map_inv: tuple[dict[str, str], dict[str, str]] - def __init__(self, filenames: tuple[str, ...] = ..., strict: bool = ...) -> None: ... - def guess_extension(self, type: str, strict: bool = ...) -> str | None: ... - def guess_type(self, url: str, strict: bool = ...) -> tuple[str | None, str | None]: ... - def guess_all_extensions(self, type: str, strict: bool = ...) -> list[str]: ... - def read(self, filename: str, strict: bool = ...) -> None: ... - def readfp(self, fp: IO[str], strict: bool = ...) -> None: ... - if sys.platform == "win32": - def read_windows_registry(self, strict: bool = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/mmap.pyi b/mypy/typeshed/stdlib/@python2/mmap.pyi deleted file mode 100644 index 4e08bc28c28a..000000000000 --- a/mypy/typeshed/stdlib/@python2/mmap.pyi +++ /dev/null @@ -1,52 +0,0 @@ -import sys -from typing import NoReturn, Sequence - -ACCESS_DEFAULT: int -ACCESS_READ: int -ACCESS_WRITE: int -ACCESS_COPY: int - -ALLOCATIONGRANULARITY: int - -if sys.platform == "linux": - MAP_DENYWRITE: int - MAP_EXECUTABLE: int - -if sys.platform != "win32": - MAP_ANON: int - MAP_ANONYMOUS: int - MAP_PRIVATE: int - MAP_SHARED: int - PROT_EXEC: int - PROT_READ: int - PROT_WRITE: int - - PAGESIZE: int - -class mmap(Sequence[bytes]): - if sys.platform == "win32": - def __init__(self, fileno: int, length: int, tagname: str | None = ..., access: int = ..., offset: int = ...) -> None: ... - else: - def __init__( - self, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = ..., offset: int = ... - ) -> None: ... - - def close(self) -> None: ... - def flush(self, offset: int = ..., size: int = ...) -> int: ... - def move(self, dest: int, src: int, count: int) -> None: ... - def read_byte(self) -> bytes: ... - def readline(self) -> bytes: ... - def resize(self, newsize: int) -> None: ... - def seek(self, pos: int, whence: int = ...) -> None: ... - def size(self) -> int: ... - def tell(self) -> int: ... - def write_byte(self, byte: bytes) -> None: ... - def __len__(self) -> int: ... - def find(self, string: bytes, start: int = ..., end: int = ...) -> int: ... - def rfind(self, string: bytes, start: int = ..., stop: int = ...) -> int: ... - def read(self, num: int) -> bytes: ... - def write(self, string: bytes) -> None: ... - def __getitem__(self, index: int | slice) -> bytes: ... - def __getslice__(self, i: int | None, j: int | None) -> bytes: ... - def __delitem__(self, index: int | slice) -> NoReturn: ... - def __setitem__(self, index: int | slice, object: bytes) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/modulefinder.pyi b/mypy/typeshed/stdlib/@python2/modulefinder.pyi deleted file mode 100644 index 458b037723f3..000000000000 --- a/mypy/typeshed/stdlib/@python2/modulefinder.pyi +++ /dev/null @@ -1,62 +0,0 @@ -from types import CodeType -from typing import IO, Any, Container, Iterable, Sequence - -LOAD_CONST: int # undocumented -IMPORT_NAME: int # undocumented -STORE_NAME: int # undocumented -STORE_GLOBAL: int # undocumented -STORE_OPS: tuple[int, int] # undocumented -EXTENDED_ARG: int # undocumented - -packagePathMap: dict[str, list[str]] # undocumented - -def AddPackagePath(packagename: str, path: str) -> None: ... - -replacePackageMap: dict[str, str] # undocumented - -def ReplacePackage(oldname: str, newname: str) -> None: ... - -class Module: # undocumented - def __init__(self, name: str, file: str | None = ..., path: str | None = ...) -> None: ... - -class ModuleFinder: - - modules: dict[str, Module] - path: list[str] # undocumented - badmodules: dict[str, dict[str, int]] # undocumented - debug: int # undocumented - indent: int # undocumented - excludes: Container[str] # undocumented - replace_paths: Sequence[tuple[str, str]] # undocumented - def __init__( - self, - path: list[str] | None = ..., - debug: int = ..., - excludes: Container[str] = ..., - replace_paths: Sequence[tuple[str, str]] = ..., - ) -> None: ... - def msg(self, level: int, str: str, *args: Any) -> None: ... # undocumented - def msgin(self, *args: Any) -> None: ... # undocumented - def msgout(self, *args: Any) -> None: ... # undocumented - def run_script(self, pathname: str) -> None: ... - def load_file(self, pathname: str) -> None: ... # undocumented - def import_hook( - self, name: str, caller: Module | None = ..., fromlist: list[str] | None = ..., level: int = ... - ) -> Module | None: ... # undocumented - def determine_parent(self, caller: Module | None, level: int = ...) -> Module | None: ... # undocumented - def find_head_package(self, parent: Module, name: str) -> tuple[Module, str]: ... # undocumented - def load_tail(self, q: Module, tail: str) -> Module: ... # undocumented - def ensure_fromlist(self, m: Module, fromlist: Iterable[str], recursive: int = ...) -> None: ... # undocumented - def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented - def import_module(self, partname: str, fqname: str, parent: Module) -> Module | None: ... # undocumented - def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: tuple[str, str, str]) -> Module: ... # undocumented - def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented - def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented - def add_module(self, fqname: str) -> Module: ... # undocumented - def find_module( - self, name: str, path: str | None, parent: Module | None = ... - ) -> tuple[IO[Any] | None, str | None, tuple[str, str, int]]: ... # undocumented - def report(self) -> None: ... - def any_missing(self) -> list[str]: ... # undocumented - def any_missing_maybe(self) -> tuple[list[str], list[str]]: ... # undocumented - def replace_paths_in_code(self, co: CodeType) -> CodeType: ... # undocumented diff --git a/mypy/typeshed/stdlib/@python2/msilib/__init__.pyi b/mypy/typeshed/stdlib/@python2/msilib/__init__.pyi deleted file mode 100644 index a49f37f0de1d..000000000000 --- a/mypy/typeshed/stdlib/@python2/msilib/__init__.pyi +++ /dev/null @@ -1,184 +0,0 @@ -import sys -from types import ModuleType -from typing import Any, Container, Iterable, Sequence -from typing_extensions import Literal - -if sys.platform == "win32": - from _msi import _Database - - AMD64: bool - Itanium: bool - Win64: bool - - datasizemask: Literal[0x00FF] - type_valid: Literal[0x0100] - type_localizable: Literal[0x0200] - typemask: Literal[0x0C00] - type_long: Literal[0x0000] - type_short: Literal[0x0400] - type_string: Literal[0x0C00] - type_binary: Literal[0x0800] - type_nullable: Literal[0x1000] - type_key: Literal[0x2000] - knownbits: Literal[0x3FFF] - - class Table: - - name: str - fields: list[tuple[int, str, int]] - def __init__(self, name: str) -> None: ... - def add_field(self, index: int, name: str, type: int) -> None: ... - def sql(self) -> str: ... - def create(self, db: _Database) -> None: ... - - class _Unspecified: ... - - def change_sequence( - seq: Sequence[tuple[str, str | None, int]], - action: str, - seqno: int | type[_Unspecified] = ..., - cond: str | type[_Unspecified] = ..., - ) -> None: ... - def add_data(db: _Database, table: str, values: Iterable[tuple[Any, ...]]) -> None: ... - def add_stream(db: _Database, name: str, path: str) -> None: ... - def init_database( - name: str, schema: ModuleType, ProductName: str, ProductCode: str, ProductVersion: str, Manufacturer: str - ) -> _Database: ... - def add_tables(db: _Database, module: ModuleType) -> None: ... - def make_id(str: str) -> str: ... - def gen_uuid() -> str: ... - - class CAB: - - name: str - files: list[tuple[str, str]] - filenames: set[str] - index: int - def __init__(self, name: str) -> None: ... - def gen_id(self, file: str) -> str: ... - def append(self, full: str, file: str, logical: str) -> tuple[int, str]: ... - def commit(self, db: _Database) -> None: ... - _directories: set[str] - - class Directory: - - db: _Database - cab: CAB - basedir: str - physical: str - logical: str - component: str | None - short_names: set[str] - ids: set[str] - keyfiles: dict[str, str] - componentflags: int | None - absolute: str - def __init__( - self, - db: _Database, - cab: CAB, - basedir: str, - physical: str, - _logical: str, - default: str, - componentflags: int | None = ..., - ) -> None: ... - def start_component( - self, - component: str | None = ..., - feature: Feature | None = ..., - flags: int | None = ..., - keyfile: str | None = ..., - uuid: str | None = ..., - ) -> None: ... - def make_short(self, file: str) -> str: ... - def add_file(self, file: str, src: str | None = ..., version: str | None = ..., language: str | None = ...) -> str: ... - def glob(self, pattern: str, exclude: Container[str] | None = ...) -> list[str]: ... - def remove_pyc(self) -> None: ... - - class Binary: - - name: str - def __init__(self, fname: str) -> None: ... - - class Feature: - - id: str - def __init__( - self, - db: _Database, - id: str, - title: str, - desc: str, - display: int, - level: int = ..., - parent: Feature | None = ..., - directory: str | None = ..., - attributes: int = ..., - ) -> None: ... - def set_current(self) -> None: ... - - class Control: - - dlg: Dialog - name: str - def __init__(self, dlg: Dialog, name: str) -> None: ... - def event(self, event: str, argument: str, condition: str = ..., ordering: int | None = ...) -> None: ... - def mapping(self, event: str, attribute: str) -> None: ... - def condition(self, action: str, condition: str) -> None: ... - - class RadioButtonGroup(Control): - - property: str - index: int - def __init__(self, dlg: Dialog, name: str, property: str) -> None: ... - def add(self, name: str, x: int, y: int, w: int, h: int, text: str, value: str | None = ...) -> None: ... - - class Dialog: - - db: _Database - name: str - x: int - y: int - w: int - h: int - def __init__( - self, - db: _Database, - name: str, - x: int, - y: int, - w: int, - h: int, - attr: int, - title: str, - first: str, - default: str, - cancel: str, - ) -> None: ... - def control( - self, - name: str, - type: str, - x: int, - y: int, - w: int, - h: int, - attr: int, - prop: str | None, - text: str | None, - next: str | None, - help: str | None, - ) -> Control: ... - def text(self, name: str, x: int, y: int, w: int, h: int, attr: int, text: str | None) -> Control: ... - def bitmap(self, name: str, x: int, y: int, w: int, h: int, text: str | None) -> Control: ... - def line(self, name: str, x: int, y: int, w: int, h: int) -> Control: ... - def pushbutton( - self, name: str, x: int, y: int, w: int, h: int, attr: int, text: str | None, next: str | None - ) -> Control: ... - def radiogroup( - self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: str | None, text: str | None, next: str | None - ) -> RadioButtonGroup: ... - def checkbox( - self, name: str, x: int, y: int, w: int, h: int, attr: int, prop: str | None, text: str | None, next: str | None - ) -> Control: ... diff --git a/mypy/typeshed/stdlib/@python2/msilib/schema.pyi b/mypy/typeshed/stdlib/@python2/msilib/schema.pyi deleted file mode 100644 index 4ad9a1783fcd..000000000000 --- a/mypy/typeshed/stdlib/@python2/msilib/schema.pyi +++ /dev/null @@ -1,94 +0,0 @@ -import sys - -if sys.platform == "win32": - from . import Table - - _Validation: Table - ActionText: Table - AdminExecuteSequence: Table - Condition: Table - AdminUISequence: Table - AdvtExecuteSequence: Table - AdvtUISequence: Table - AppId: Table - AppSearch: Table - Property: Table - BBControl: Table - Billboard: Table - Feature: Table - Binary: Table - BindImage: Table - File: Table - CCPSearch: Table - CheckBox: Table - Class: Table - Component: Table - Icon: Table - ProgId: Table - ComboBox: Table - CompLocator: Table - Complus: Table - Directory: Table - Control: Table - Dialog: Table - ControlCondition: Table - ControlEvent: Table - CreateFolder: Table - CustomAction: Table - DrLocator: Table - DuplicateFile: Table - Environment: Table - Error: Table - EventMapping: Table - Extension: Table - MIME: Table - FeatureComponents: Table - FileSFPCatalog: Table - SFPCatalog: Table - Font: Table - IniFile: Table - IniLocator: Table - InstallExecuteSequence: Table - InstallUISequence: Table - IsolatedComponent: Table - LaunchCondition: Table - ListBox: Table - ListView: Table - LockPermissions: Table - Media: Table - MoveFile: Table - MsiAssembly: Table - MsiAssemblyName: Table - MsiDigitalCertificate: Table - MsiDigitalSignature: Table - MsiFileHash: Table - MsiPatchHeaders: Table - ODBCAttribute: Table - ODBCDriver: Table - ODBCDataSource: Table - ODBCSourceAttribute: Table - ODBCTranslator: Table - Patch: Table - PatchPackage: Table - PublishComponent: Table - RadioButton: Table - Registry: Table - RegLocator: Table - RemoveFile: Table - RemoveIniFile: Table - RemoveRegistry: Table - ReserveCost: Table - SelfReg: Table - ServiceControl: Table - ServiceInstall: Table - Shortcut: Table - Signature: Table - TextStyle: Table - TypeLib: Table - UIText: Table - Upgrade: Table - Verb: Table - - tables: list[Table] - - _Validation_records: list[tuple[str, str, str, int | None, int | None, str | None, int | None, str | None, str | None, str]] diff --git a/mypy/typeshed/stdlib/@python2/msilib/sequence.pyi b/mypy/typeshed/stdlib/@python2/msilib/sequence.pyi deleted file mode 100644 index 30346aba3367..000000000000 --- a/mypy/typeshed/stdlib/@python2/msilib/sequence.pyi +++ /dev/null @@ -1,13 +0,0 @@ -import sys - -if sys.platform == "win32": - - _SequenceType = list[tuple[str, str | None, int]] - - AdminExecuteSequence: _SequenceType - AdminUISequence: _SequenceType - AdvtExecuteSequence: _SequenceType - InstallExecuteSequence: _SequenceType - InstallUISequence: _SequenceType - - tables: list[str] diff --git a/mypy/typeshed/stdlib/@python2/msilib/text.pyi b/mypy/typeshed/stdlib/@python2/msilib/text.pyi deleted file mode 100644 index 879429ecea85..000000000000 --- a/mypy/typeshed/stdlib/@python2/msilib/text.pyi +++ /dev/null @@ -1,8 +0,0 @@ -import sys - -if sys.platform == "win32": - - ActionText: list[tuple[str, str, str | None]] - UIText: list[tuple[str, str | None]] - - tables: list[str] diff --git a/mypy/typeshed/stdlib/@python2/msvcrt.pyi b/mypy/typeshed/stdlib/@python2/msvcrt.pyi deleted file mode 100644 index ede80c9fbb66..000000000000 --- a/mypy/typeshed/stdlib/@python2/msvcrt.pyi +++ /dev/null @@ -1,24 +0,0 @@ -import sys -from typing import Text - -# This module is only available on Windows -if sys.platform == "win32": - LK_LOCK: int - LK_NBLCK: int - LK_NBRLCK: int - LK_RLCK: int - LK_UNLCK: int - def locking(__fd: int, __mode: int, __nbytes: int) -> None: ... - def setmode(__fd: int, __mode: int) -> int: ... - def open_osfhandle(__handle: int, __flags: int) -> int: ... - def get_osfhandle(__fd: int) -> int: ... - def kbhit() -> bool: ... - def getch() -> bytes: ... - def getwch() -> Text: ... - def getche() -> bytes: ... - def getwche() -> Text: ... - def putch(__char: bytes) -> None: ... - def putwch(__unicode_char: Text) -> None: ... - def ungetch(__char: bytes) -> None: ... - def ungetwch(__unicode_char: Text) -> None: ... - def heapmin() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/multiprocessing/__init__.pyi b/mypy/typeshed/stdlib/@python2/multiprocessing/__init__.pyi deleted file mode 100644 index e22e09000de1..000000000000 --- a/mypy/typeshed/stdlib/@python2/multiprocessing/__init__.pyi +++ /dev/null @@ -1,50 +0,0 @@ -from multiprocessing import pool -from multiprocessing.process import Process as Process, active_children as active_children, current_process as current_process -from multiprocessing.util import SUBDEBUG as SUBDEBUG, SUBWARNING as SUBWARNING -from Queue import Queue as _BaseQueue -from typing import Any, Callable, Iterable, TypeVar - -class ProcessError(Exception): ... -class BufferTooShort(ProcessError): ... -class TimeoutError(ProcessError): ... -class AuthenticationError(ProcessError): ... - -_T = TypeVar("_T") - -class Queue(_BaseQueue[_T]): - def __init__(self, maxsize: int = ...) -> None: ... - def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... - def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ... - def qsize(self) -> int: ... - def empty(self) -> bool: ... - def full(self) -> bool: ... - def put_nowait(self, item: _T) -> None: ... - def get_nowait(self) -> _T: ... - def close(self) -> None: ... - def join_thread(self) -> None: ... - def cancel_join_thread(self) -> None: ... - -def Manager(): ... -def Pipe(duplex: bool = ...): ... -def cpu_count() -> int: ... -def freeze_support(): ... -def get_logger(): ... -def log_to_stderr(level: Any | None = ...): ... -def allow_connection_pickling(): ... -def Lock(): ... -def RLock(): ... -def Condition(lock: Any | None = ...): ... -def Semaphore(value: int = ...): ... -def BoundedSemaphore(value: int = ...): ... -def Event(): ... -def JoinableQueue(maxsize: int = ...): ... -def RawValue(typecode_or_type, *args): ... -def RawArray(typecode_or_type, size_or_initializer): ... -def Value(typecode_or_type, *args, **kwds): ... -def Array(typecode_or_type, size_or_initializer, **kwds): ... -def Pool( - processes: int | None = ..., - initializer: Callable[..., Any] | None = ..., - initargs: Iterable[Any] = ..., - maxtasksperchild: int | None = ..., -) -> pool.Pool: ... diff --git a/mypy/typeshed/stdlib/@python2/multiprocessing/dummy/__init__.pyi b/mypy/typeshed/stdlib/@python2/multiprocessing/dummy/__init__.pyi deleted file mode 100644 index a5381ed3839c..000000000000 --- a/mypy/typeshed/stdlib/@python2/multiprocessing/dummy/__init__.pyi +++ /dev/null @@ -1,41 +0,0 @@ -import array -import threading -import weakref -from Queue import Queue -from typing import Any - -class DummyProcess(threading.Thread): - _children: weakref.WeakKeyDictionary[Any, Any] - _parent: threading.Thread - _pid: None - _start_called: bool - def __init__(self, group=..., target=..., name=..., args=..., kwargs=...) -> None: ... - @property - def exitcode(self) -> int | None: ... - -Process = DummyProcess - -# This should be threading._Condition but threading.pyi exports it as Condition -class Condition(threading.Condition): - notify_all: Any - -class Namespace(object): - def __init__(self, **kwds) -> None: ... - -class Value(object): - _typecode: Any - _value: Any - value: Any - def __init__(self, typecode, value, lock=...) -> None: ... - def _get(self) -> Any: ... - def _set(self, value) -> None: ... - -JoinableQueue = Queue - -def Array(typecode, sequence, lock=...) -> array.array[Any]: ... -def Manager() -> Any: ... -def Pool(processes=..., initializer=..., initargs=...) -> Any: ... -def active_children() -> list[Any]: ... -def current_process() -> threading.Thread: ... -def freeze_support() -> None: ... -def shutdown() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/multiprocessing/dummy/connection.pyi b/mypy/typeshed/stdlib/@python2/multiprocessing/dummy/connection.pyi deleted file mode 100644 index f01b3f8cd660..000000000000 --- a/mypy/typeshed/stdlib/@python2/multiprocessing/dummy/connection.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from Queue import Queue -from typing import Any - -families: list[None] - -class Connection(object): - _in: Any - _out: Any - recv: Any - recv_bytes: Any - send: Any - send_bytes: Any - def __init__(self, _in, _out) -> None: ... - def close(self) -> None: ... - def poll(self, timeout=...) -> Any: ... - -class Listener(object): - _backlog_queue: Queue[Any] | None - address: Any - def __init__(self, address=..., family=..., backlog=...) -> None: ... - def accept(self) -> Connection: ... - def close(self) -> None: ... - -def Client(address) -> Connection: ... -def Pipe(duplex=...) -> tuple[Connection, Connection]: ... diff --git a/mypy/typeshed/stdlib/@python2/multiprocessing/pool.pyi b/mypy/typeshed/stdlib/@python2/multiprocessing/pool.pyi deleted file mode 100644 index 440b5e83c500..000000000000 --- a/mypy/typeshed/stdlib/@python2/multiprocessing/pool.pyi +++ /dev/null @@ -1,51 +0,0 @@ -from _typeshed import Self -from typing import Any, Callable, Iterable, Iterator - -class AsyncResult: - def get(self, timeout: float | None = ...) -> Any: ... - def wait(self, timeout: float | None = ...) -> None: ... - def ready(self) -> bool: ... - def successful(self) -> bool: ... - -class IMapIterator(Iterator[Any]): - def __iter__(self: Self) -> Self: ... - def next(self, timeout: float | None = ...) -> Any: ... - -class IMapUnorderedIterator(IMapIterator): ... - -class Pool(object): - def __init__( - self, - processes: int | None = ..., - initializer: Callable[..., None] | None = ..., - initargs: Iterable[Any] = ..., - maxtasksperchild: int | None = ..., - ) -> None: ... - def apply(self, func: Callable[..., Any], args: Iterable[Any] = ..., kwds: dict[str, Any] = ...) -> Any: ... - def apply_async( - self, - func: Callable[..., Any], - args: Iterable[Any] = ..., - kwds: dict[str, Any] = ..., - callback: Callable[..., None] | None = ..., - ) -> AsyncResult: ... - def map(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ...) -> list[Any]: ... - def map_async( - self, - func: Callable[..., Any], - iterable: Iterable[Any] = ..., - chunksize: int | None = ..., - callback: Callable[..., None] | None = ..., - ) -> AsyncResult: ... - def imap(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ...) -> IMapIterator: ... - def imap_unordered( - self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ... - ) -> IMapIterator: ... - def close(self) -> None: ... - def terminate(self) -> None: ... - def join(self) -> None: ... - -class ThreadPool(Pool): - def __init__( - self, processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ... - ) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/multiprocessing/process.pyi b/mypy/typeshed/stdlib/@python2/multiprocessing/process.pyi deleted file mode 100644 index 2cb691342580..000000000000 --- a/mypy/typeshed/stdlib/@python2/multiprocessing/process.pyi +++ /dev/null @@ -1,35 +0,0 @@ -from typing import Any - -def current_process(): ... -def active_children(): ... - -class Process: - def __init__(self, group: Any | None = ..., target: Any | None = ..., name: Any | None = ..., args=..., kwargs=...): ... - def run(self): ... - def start(self): ... - def terminate(self): ... - def join(self, timeout: Any | None = ...): ... - def is_alive(self): ... - @property - def name(self): ... - @name.setter - def name(self, name): ... - @property - def daemon(self): ... - @daemon.setter - def daemon(self, daemonic): ... - @property - def authkey(self): ... - @authkey.setter - def authkey(self, authkey): ... - @property - def exitcode(self): ... - @property - def ident(self): ... - pid: Any - -class AuthenticationString(bytes): - def __reduce__(self): ... - -class _MainProcess(Process): - def __init__(self): ... diff --git a/mypy/typeshed/stdlib/@python2/multiprocessing/util.pyi b/mypy/typeshed/stdlib/@python2/multiprocessing/util.pyi deleted file mode 100644 index 6976bc3e6cf4..000000000000 --- a/mypy/typeshed/stdlib/@python2/multiprocessing/util.pyi +++ /dev/null @@ -1,29 +0,0 @@ -import threading -from typing import Any - -SUBDEBUG: Any -SUBWARNING: Any - -def sub_debug(msg, *args): ... -def debug(msg, *args): ... -def info(msg, *args): ... -def sub_warning(msg, *args): ... -def get_logger(): ... -def log_to_stderr(level: Any | None = ...): ... -def get_temp_dir(): ... -def register_after_fork(obj, func): ... - -class Finalize: - def __init__(self, obj, callback, args=..., kwargs: Any | None = ..., exitpriority: Any | None = ...): ... - def __call__(self, wr: Any | None = ...): ... - def cancel(self): ... - def still_active(self): ... - -def is_exiting(): ... - -class ForkAwareThreadLock: - def __init__(self): ... - -class ForkAwareLocal(threading.local): - def __init__(self): ... - def __reduce__(self): ... diff --git a/mypy/typeshed/stdlib/@python2/mutex.pyi b/mypy/typeshed/stdlib/@python2/mutex.pyi deleted file mode 100644 index fd5363de73e5..000000000000 --- a/mypy/typeshed/stdlib/@python2/mutex.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from collections import deque -from typing import Any, Callable, TypeVar - -_T = TypeVar("_T") - -class mutex: - locked: bool - queue: deque[Any] - def __init__(self) -> None: ... - def test(self) -> bool: ... - def testandset(self) -> bool: ... - def lock(self, function: Callable[[_T], Any], argument: _T) -> None: ... - def unlock(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/netrc.pyi b/mypy/typeshed/stdlib/@python2/netrc.pyi deleted file mode 100644 index fc5fababa7e7..000000000000 --- a/mypy/typeshed/stdlib/@python2/netrc.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Text - -class NetrcParseError(Exception): - filename: str | None - lineno: int | None - msg: str - def __init__(self, msg: str, filename: Text | None = ..., lineno: int | None = ...) -> None: ... - -# (login, account, password) tuple -_NetrcTuple = tuple[str, str | None, str | None] - -class netrc: - hosts: dict[str, _NetrcTuple] - macros: dict[str, list[str]] - def __init__(self, file: Text | None = ...) -> None: ... - def authenticators(self, host: str) -> _NetrcTuple | None: ... diff --git a/mypy/typeshed/stdlib/@python2/nis.pyi b/mypy/typeshed/stdlib/@python2/nis.pyi deleted file mode 100644 index 10eef2336a83..000000000000 --- a/mypy/typeshed/stdlib/@python2/nis.pyi +++ /dev/null @@ -1,9 +0,0 @@ -import sys - -if sys.platform != "win32": - def cat(map: str, domain: str = ...) -> dict[str, str]: ... - def get_default_domain() -> str: ... - def maps(domain: str = ...) -> list[str]: ... - def match(key: str, map: str, domain: str = ...) -> str: ... - - class error(Exception): ... diff --git a/mypy/typeshed/stdlib/@python2/nntplib.pyi b/mypy/typeshed/stdlib/@python2/nntplib.pyi deleted file mode 100644 index 7cacb07bdb77..000000000000 --- a/mypy/typeshed/stdlib/@python2/nntplib.pyi +++ /dev/null @@ -1,110 +0,0 @@ -import datetime -import socket -import ssl -from _typeshed import Self -from builtins import list as List # alias to avoid a name clash with a method named `list` in `_NNTPBase` -from typing import IO, Any, Iterable, NamedTuple - -_File = IO[bytes] | bytes | str | None - -class NNTPError(Exception): - response: str - -class NNTPReplyError(NNTPError): ... -class NNTPTemporaryError(NNTPError): ... -class NNTPPermanentError(NNTPError): ... -class NNTPProtocolError(NNTPError): ... -class NNTPDataError(NNTPError): ... - -NNTP_PORT: int -NNTP_SSL_PORT: int - -class GroupInfo(NamedTuple): - group: str - last: str - first: str - flag: str - -class ArticleInfo(NamedTuple): - number: int - message_id: str - lines: list[bytes] - -def decode_header(header_str: str) -> str: ... - -class _NNTPBase: - encoding: str - errors: str - - host: str - file: IO[bytes] - debugging: int - welcome: str - readermode_afterauth: bool - tls_on: bool - authenticated: bool - nntp_implementation: str - nntp_version: int - def __init__(self, file: IO[bytes], host: str, readermode: bool | None = ..., timeout: float = ...) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Any) -> None: ... - def getwelcome(self) -> str: ... - def getcapabilities(self) -> dict[str, List[str]]: ... - def set_debuglevel(self, level: int) -> None: ... - def debug(self, level: int) -> None: ... - def capabilities(self) -> tuple[str, dict[str, List[str]]]: ... - def newgroups(self, date: datetime.date | datetime.datetime, *, file: _File = ...) -> tuple[str, List[str]]: ... - def newnews(self, group: str, date: datetime.date | datetime.datetime, *, file: _File = ...) -> tuple[str, List[str]]: ... - def list(self, group_pattern: str | None = ..., *, file: _File = ...) -> tuple[str, List[str]]: ... - def description(self, group: str) -> str: ... - def descriptions(self, group_pattern: str) -> tuple[str, dict[str, str]]: ... - def group(self, name: str) -> tuple[str, int, int, int, str]: ... - def help(self, *, file: _File = ...) -> tuple[str, List[str]]: ... - def stat(self, message_spec: Any = ...) -> tuple[str, int, str]: ... - def next(self) -> tuple[str, int, str]: ... - def last(self) -> tuple[str, int, str]: ... - def head(self, message_spec: Any = ..., *, file: _File = ...) -> tuple[str, ArticleInfo]: ... - def body(self, message_spec: Any = ..., *, file: _File = ...) -> tuple[str, ArticleInfo]: ... - def article(self, message_spec: Any = ..., *, file: _File = ...) -> tuple[str, ArticleInfo]: ... - def slave(self) -> str: ... - def xhdr(self, hdr: str, str: Any, *, file: _File = ...) -> tuple[str, List[str]]: ... - def xover(self, start: int, end: int, *, file: _File = ...) -> tuple[str, List[tuple[int, dict[str, str]]]]: ... - def over( - self, message_spec: None | str | List[Any] | tuple[Any, ...], *, file: _File = ... - ) -> tuple[str, List[tuple[int, dict[str, str]]]]: ... - def xgtitle(self, group: str, *, file: _File = ...) -> tuple[str, List[tuple[str, str]]]: ... - def xpath(self, id: Any) -> tuple[str, str]: ... - def date(self) -> tuple[str, datetime.datetime]: ... - def post(self, data: bytes | Iterable[bytes]) -> str: ... - def ihave(self, message_id: Any, data: bytes | Iterable[bytes]) -> str: ... - def quit(self) -> str: ... - def login(self, user: str | None = ..., password: str | None = ..., usenetrc: bool = ...) -> None: ... - def starttls(self, context: ssl.SSLContext | None = ...) -> None: ... - -class NNTP(_NNTPBase): - port: int - sock: socket.socket - def __init__( - self, - host: str, - port: int = ..., - user: str | None = ..., - password: str | None = ..., - readermode: bool | None = ..., - usenetrc: bool = ..., - timeout: float = ..., - ) -> None: ... - -class NNTP_SSL(_NNTPBase): - sock: socket.socket - def __init__( - self, - host: str, - port: int = ..., - user: str | None = ..., - password: str | None = ..., - ssl_context: ssl.SSLContext | None = ..., - readermode: bool | None = ..., - usenetrc: bool = ..., - timeout: float = ..., - ) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/ntpath.pyi b/mypy/typeshed/stdlib/@python2/ntpath.pyi deleted file mode 100644 index 33732903cb4c..000000000000 --- a/mypy/typeshed/stdlib/@python2/ntpath.pyi +++ /dev/null @@ -1,84 +0,0 @@ -import os -import sys -from genericpath import exists as exists -from typing import Any, AnyStr, Callable, Sequence, Text, TypeVar, overload - -_T = TypeVar("_T") - -# ----- os.path variables ----- -supports_unicode_filenames: bool -# aliases (also in os) -curdir: str -pardir: str -sep: str -if sys.platform == "win32": - altsep: str -else: - altsep: str | None -extsep: str -pathsep: str -defpath: str -devnull: str - -# ----- os.path function stubs ----- -def abspath(path: AnyStr) -> AnyStr: ... -def basename(p: AnyStr) -> AnyStr: ... -def dirname(p: AnyStr) -> AnyStr: ... -def expanduser(path: AnyStr) -> AnyStr: ... -def expandvars(path: AnyStr) -> AnyStr: ... -def normcase(s: AnyStr) -> AnyStr: ... -def normpath(path: AnyStr) -> AnyStr: ... - -if sys.platform == "win32": - def realpath(path: AnyStr) -> AnyStr: ... - -else: - def realpath(filename: AnyStr) -> AnyStr: ... - -# NOTE: Empty lists results in '' (str) regardless of contained type. -# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes -# So, fall back to Any -def commonprefix(m: Sequence[Text]) -> Any: ... -def lexists(path: Text) -> bool: ... - -# These return float if os.stat_float_times() == True, -# but int is a subclass of float. -def getatime(filename: Text) -> float: ... -def getmtime(filename: Text) -> float: ... -def getctime(filename: Text) -> float: ... -def getsize(filename: Text) -> int: ... -def isabs(s: Text) -> bool: ... -def isfile(path: Text) -> bool: ... -def isdir(s: Text) -> bool: ... -def islink(path: Text) -> bool: ... -def ismount(path: Text) -> bool: ... - -# Make sure signatures are disjunct, and allow combinations of bytes and unicode. -# (Since Python 2 allows that, too) -# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in -# a type error. -@overload -def join(__p1: bytes, *p: bytes) -> bytes: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... -@overload -def join(__p1: Text, *p: Text) -> Text: ... -@overload -def relpath(path: str, start: str | None = ...) -> str: ... -@overload -def relpath(path: Text, start: Text | None = ...) -> Text: ... -def samefile(f1: Text, f2: Text) -> bool: ... -def sameopenfile(fp1: int, fp2: int) -> bool: ... -def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... -def split(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitdrive(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitext(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... - -if sys.platform == "win32": - def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated - -def walk(path: AnyStr, visit: Callable[[_T, AnyStr, list[AnyStr]], Any], arg: _T) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/nturl2path.pyi b/mypy/typeshed/stdlib/@python2/nturl2path.pyi deleted file mode 100644 index b87b008e4cec..000000000000 --- a/mypy/typeshed/stdlib/@python2/nturl2path.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from typing import AnyStr - -def url2pathname(url: AnyStr) -> AnyStr: ... -def pathname2url(p: AnyStr) -> AnyStr: ... diff --git a/mypy/typeshed/stdlib/@python2/numbers.pyi b/mypy/typeshed/stdlib/@python2/numbers.pyi deleted file mode 100644 index 73384a30803c..000000000000 --- a/mypy/typeshed/stdlib/@python2/numbers.pyi +++ /dev/null @@ -1,119 +0,0 @@ -# Note: these stubs are incomplete. The more complex type -# signatures are currently omitted. - -from abc import ABCMeta, abstractmethod -from typing import Any, SupportsFloat - -class Number(metaclass=ABCMeta): - @abstractmethod - def __hash__(self) -> int: ... - -class Complex(Number): - @abstractmethod - def __complex__(self) -> complex: ... - def __nonzero__(self) -> bool: ... - @property - @abstractmethod - def real(self) -> Any: ... - @property - @abstractmethod - def imag(self) -> Any: ... - @abstractmethod - def __add__(self, other: Any) -> Any: ... - @abstractmethod - def __radd__(self, other: Any) -> Any: ... - @abstractmethod - def __neg__(self) -> Any: ... - @abstractmethod - def __pos__(self) -> Any: ... - def __sub__(self, other: Any) -> Any: ... - def __rsub__(self, other: Any) -> Any: ... - @abstractmethod - def __mul__(self, other: Any) -> Any: ... - @abstractmethod - def __rmul__(self, other: Any) -> Any: ... - @abstractmethod - def __div__(self, other): ... - @abstractmethod - def __rdiv__(self, other): ... - @abstractmethod - def __truediv__(self, other: Any) -> Any: ... - @abstractmethod - def __rtruediv__(self, other: Any) -> Any: ... - @abstractmethod - def __pow__(self, exponent: Any) -> Any: ... - @abstractmethod - def __rpow__(self, base: Any) -> Any: ... - def __abs__(self) -> Real: ... - def conjugate(self) -> Any: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - -class Real(Complex, SupportsFloat): - @abstractmethod - def __float__(self) -> float: ... - @abstractmethod - def __trunc__(self) -> int: ... - def __divmod__(self, other: Any) -> Any: ... - def __rdivmod__(self, other: Any) -> Any: ... - @abstractmethod - def __floordiv__(self, other: Any) -> int: ... - @abstractmethod - def __rfloordiv__(self, other: Any) -> int: ... - @abstractmethod - def __mod__(self, other: Any) -> Any: ... - @abstractmethod - def __rmod__(self, other: Any) -> Any: ... - @abstractmethod - def __lt__(self, other: Any) -> bool: ... - @abstractmethod - def __le__(self, other: Any) -> bool: ... - def __complex__(self) -> complex: ... - @property - def real(self) -> Any: ... - @property - def imag(self) -> Any: ... - def conjugate(self) -> Any: ... - -class Rational(Real): - @property - @abstractmethod - def numerator(self) -> int: ... - @property - @abstractmethod - def denominator(self) -> int: ... - def __float__(self) -> float: ... - -class Integral(Rational): - @abstractmethod - def __long__(self) -> long: ... - def __index__(self) -> int: ... - @abstractmethod - def __pow__(self, exponent: Any, modulus: Any | None = ...) -> Any: ... - @abstractmethod - def __lshift__(self, other: Any) -> Any: ... - @abstractmethod - def __rlshift__(self, other: Any) -> Any: ... - @abstractmethod - def __rshift__(self, other: Any) -> Any: ... - @abstractmethod - def __rrshift__(self, other: Any) -> Any: ... - @abstractmethod - def __and__(self, other: Any) -> Any: ... - @abstractmethod - def __rand__(self, other: Any) -> Any: ... - @abstractmethod - def __xor__(self, other: Any) -> Any: ... - @abstractmethod - def __rxor__(self, other: Any) -> Any: ... - @abstractmethod - def __or__(self, other: Any) -> Any: ... - @abstractmethod - def __ror__(self, other: Any) -> Any: ... - @abstractmethod - def __invert__(self) -> Any: ... - def __float__(self) -> float: ... - @property - def numerator(self) -> int: ... - @property - def denominator(self) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/opcode.pyi b/mypy/typeshed/stdlib/@python2/opcode.pyi deleted file mode 100644 index be162da4e496..000000000000 --- a/mypy/typeshed/stdlib/@python2/opcode.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Sequence - -cmp_op: Sequence[str] -hasconst: list[int] -hasname: list[int] -hasjrel: list[int] -hasjabs: list[int] -haslocal: list[int] -hascompare: list[int] -hasfree: list[int] -opname: list[str] - -opmap: dict[str, int] -HAVE_ARGUMENT: int -EXTENDED_ARG: int diff --git a/mypy/typeshed/stdlib/@python2/operator.pyi b/mypy/typeshed/stdlib/@python2/operator.pyi deleted file mode 100644 index cff20b85898b..000000000000 --- a/mypy/typeshed/stdlib/@python2/operator.pyi +++ /dev/null @@ -1,178 +0,0 @@ -from typing import Any, Container, Generic, Mapping, MutableMapping, MutableSequence, Sequence, SupportsAbs, TypeVar, overload - -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) -_K = TypeVar("_K") -_V = TypeVar("_V") - -def lt(__a: Any, __b: Any) -> Any: ... -def le(__a: Any, __b: Any) -> Any: ... -def eq(__a: Any, __b: Any) -> Any: ... -def ne(__a: Any, __b: Any) -> Any: ... -def ge(__a: Any, __b: Any) -> Any: ... -def gt(__a: Any, __b: Any) -> Any: ... -def __lt__(a: Any, b: Any) -> Any: ... -def __le__(a: Any, b: Any) -> Any: ... -def __eq__(a: Any, b: Any) -> Any: ... -def __ne__(a: Any, b: Any) -> Any: ... -def __ge__(a: Any, b: Any) -> Any: ... -def __gt__(a: Any, b: Any) -> Any: ... -def not_(__a: Any) -> bool: ... -def __not__(a: Any) -> bool: ... -def truth(__a: Any) -> bool: ... -def is_(__a: Any, __b: Any) -> bool: ... -def is_not(__a: Any, __b: Any) -> bool: ... -def abs(__a: SupportsAbs[_T]) -> _T: ... -def __abs__(a: SupportsAbs[_T]) -> _T: ... -def add(__a: Any, __b: Any) -> Any: ... -def __add__(a: Any, b: Any) -> Any: ... -def and_(__a: Any, __b: Any) -> Any: ... -def __and__(a: Any, b: Any) -> Any: ... -def div(a: Any, b: Any) -> Any: ... -def __div__(a: Any, b: Any) -> Any: ... -def floordiv(__a: Any, __b: Any) -> Any: ... -def __floordiv__(a: Any, b: Any) -> Any: ... -def index(__a: Any) -> int: ... -def __index__(a: Any) -> int: ... -def inv(__a: Any) -> Any: ... -def invert(__a: Any) -> Any: ... -def __inv__(a: Any) -> Any: ... -def __invert__(a: Any) -> Any: ... -def lshift(__a: Any, __b: Any) -> Any: ... -def __lshift__(a: Any, b: Any) -> Any: ... -def mod(__a: Any, __b: Any) -> Any: ... -def __mod__(a: Any, b: Any) -> Any: ... -def mul(__a: Any, __b: Any) -> Any: ... -def __mul__(a: Any, b: Any) -> Any: ... -def neg(__a: Any) -> Any: ... -def __neg__(a: Any) -> Any: ... -def or_(__a: Any, __b: Any) -> Any: ... -def __or__(a: Any, b: Any) -> Any: ... -def pos(__a: Any) -> Any: ... -def __pos__(a: Any) -> Any: ... -def pow(__a: Any, __b: Any) -> Any: ... -def __pow__(a: Any, b: Any) -> Any: ... -def rshift(__a: Any, __b: Any) -> Any: ... -def __rshift__(a: Any, b: Any) -> Any: ... -def sub(__a: Any, __b: Any) -> Any: ... -def __sub__(a: Any, b: Any) -> Any: ... -def truediv(__a: Any, __b: Any) -> Any: ... -def __truediv__(a: Any, b: Any) -> Any: ... -def xor(__a: Any, __b: Any) -> Any: ... -def __xor__(a: Any, b: Any) -> Any: ... -def concat(__a: Sequence[_T], __b: Sequence[_T]) -> Sequence[_T]: ... -def __concat__(a: Sequence[_T], b: Sequence[_T]) -> Sequence[_T]: ... -def contains(__a: Container[Any], __b: Any) -> bool: ... -def __contains__(a: Container[Any], b: Any) -> bool: ... -def countOf(__a: Container[Any], __b: Any) -> int: ... -@overload -def delitem(__a: MutableSequence[Any], __b: int) -> None: ... -@overload -def delitem(__a: MutableSequence[Any], __b: slice) -> None: ... -@overload -def delitem(__a: MutableMapping[_K, Any], __b: _K) -> None: ... -@overload -def __delitem__(a: MutableSequence[Any], b: int) -> None: ... -@overload -def __delitem__(a: MutableSequence[Any], b: slice) -> None: ... -@overload -def __delitem__(a: MutableMapping[_K, Any], b: _K) -> None: ... -def delslice(a: MutableSequence[Any], b: int, c: int) -> None: ... -def __delslice__(a: MutableSequence[Any], b: int, c: int) -> None: ... -@overload -def getitem(__a: Sequence[_T], __b: int) -> _T: ... -@overload -def getitem(__a: Sequence[_T], __b: slice) -> Sequence[_T]: ... -@overload -def getitem(__a: Mapping[_K, _V], __b: _K) -> _V: ... -@overload -def __getitem__(a: Sequence[_T], b: int) -> _T: ... -@overload -def __getitem__(a: Sequence[_T], b: slice) -> Sequence[_T]: ... -@overload -def __getitem__(a: Mapping[_K, _V], b: _K) -> _V: ... -def getslice(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ... -def __getslice__(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ... -def indexOf(__a: Sequence[_T], __b: _T) -> int: ... -def repeat(a: Any, b: int) -> Any: ... -def __repeat__(a: Any, b: int) -> Any: ... -def sequenceIncludes(a: Container[Any], b: Any) -> bool: ... -@overload -def setitem(__a: MutableSequence[_T], __b: int, __c: _T) -> None: ... -@overload -def setitem(__a: MutableSequence[_T], __b: slice, __c: Sequence[_T]) -> None: ... -@overload -def setitem(__a: MutableMapping[_K, _V], __b: _K, __c: _V) -> None: ... -@overload -def __setitem__(a: MutableSequence[_T], b: int, c: _T) -> None: ... -@overload -def __setitem__(a: MutableSequence[_T], b: slice, c: Sequence[_T]) -> None: ... -@overload -def __setitem__(a: MutableMapping[_K, _V], b: _K, c: _V) -> None: ... -def setslice(a: MutableSequence[_T], b: int, c: int, v: Sequence[_T]) -> None: ... -def __setslice__(a: MutableSequence[_T], b: int, c: int, v: Sequence[_T]) -> None: ... - -class attrgetter(Generic[_T_co]): - @overload - def __new__(cls, attr: str) -> attrgetter[Any]: ... - @overload - def __new__(cls, attr: str, __attr2: str) -> attrgetter[tuple[Any, Any]]: ... - @overload - def __new__(cls, attr: str, __attr2: str, __attr3: str) -> attrgetter[tuple[Any, Any, Any]]: ... - @overload - def __new__(cls, attr: str, __attr2: str, __attr3: str, __attr4: str) -> attrgetter[tuple[Any, Any, Any, Any]]: ... - @overload - def __new__(cls, attr: str, *attrs: str) -> attrgetter[tuple[Any, ...]]: ... - def __call__(self, obj: Any) -> _T_co: ... - -class itemgetter(Generic[_T_co]): - @overload - def __new__(cls, item: Any) -> itemgetter[Any]: ... - @overload - def __new__(cls, item: Any, __item2: Any) -> itemgetter[tuple[Any, Any]]: ... - @overload - def __new__(cls, item: Any, __item2: Any, __item3: Any) -> itemgetter[tuple[Any, Any, Any]]: ... - @overload - def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[tuple[Any, Any, Any, Any]]: ... - @overload - def __new__(cls, item: Any, *items: Any) -> itemgetter[tuple[Any, ...]]: ... - def __call__(self, obj: Any) -> _T_co: ... - -class methodcaller: - def __init__(self, __name: str, *args: Any, **kwargs: Any) -> None: ... - def __call__(self, obj: Any) -> Any: ... - -def iadd(__a: Any, __b: Any) -> Any: ... -def __iadd__(a: Any, b: Any) -> Any: ... -def iand(__a: Any, __b: Any) -> Any: ... -def __iand__(a: Any, b: Any) -> Any: ... -def iconcat(__a: Any, __b: Any) -> Any: ... -def __iconcat__(a: Any, b: Any) -> Any: ... -def idiv(a: Any, b: Any) -> Any: ... -def __idiv__(a: Any, b: Any) -> Any: ... -def ifloordiv(__a: Any, __b: Any) -> Any: ... -def __ifloordiv__(a: Any, b: Any) -> Any: ... -def ilshift(__a: Any, __b: Any) -> Any: ... -def __ilshift__(a: Any, b: Any) -> Any: ... -def imod(__a: Any, __b: Any) -> Any: ... -def __imod__(a: Any, b: Any) -> Any: ... -def imul(__a: Any, __b: Any) -> Any: ... -def __imul__(a: Any, b: Any) -> Any: ... -def ior(__a: Any, __b: Any) -> Any: ... -def __ior__(a: Any, b: Any) -> Any: ... -def ipow(__a: Any, __b: Any) -> Any: ... -def __ipow__(a: Any, b: Any) -> Any: ... -def irepeat(a: Any, b: int) -> Any: ... -def __irepeat__(a: Any, b: int) -> Any: ... -def irshift(__a: Any, __b: Any) -> Any: ... -def __irshift__(a: Any, b: Any) -> Any: ... -def isub(__a: Any, __b: Any) -> Any: ... -def __isub__(a: Any, b: Any) -> Any: ... -def itruediv(__a: Any, __b: Any) -> Any: ... -def __itruediv__(a: Any, b: Any) -> Any: ... -def ixor(__a: Any, __b: Any) -> Any: ... -def __ixor__(a: Any, b: Any) -> Any: ... -def isCallable(x: Any) -> bool: ... -def isMappingType(x: Any) -> bool: ... -def isNumberType(x: Any) -> bool: ... -def isSequenceType(x: Any) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/optparse.pyi b/mypy/typeshed/stdlib/@python2/optparse.pyi deleted file mode 100644 index d033cb9a6da6..000000000000 --- a/mypy/typeshed/stdlib/@python2/optparse.pyi +++ /dev/null @@ -1,229 +0,0 @@ -from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, overload - -# See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g -_Text = str | unicode - -NO_DEFAULT: tuple[_Text, ...] -SUPPRESS_HELP: _Text -SUPPRESS_USAGE: _Text - -def check_builtin(option: Option, opt: Any, value: _Text) -> Any: ... -def check_choice(option: Option, opt: Any, value: _Text) -> Any: ... -def isbasestring(x: Any) -> bool: ... - -class OptParseError(Exception): - msg: _Text - def __init__(self, msg: _Text) -> None: ... - -class BadOptionError(OptParseError): - opt_str: _Text - def __init__(self, opt_str: _Text) -> None: ... - -class AmbiguousOptionError(BadOptionError): - possibilities: Iterable[_Text] - def __init__(self, opt_str: _Text, possibilities: Sequence[_Text]) -> None: ... - -class OptionError(OptParseError): - msg: _Text - option_id: _Text - def __init__(self, msg: _Text, option: Option) -> None: ... - -class OptionConflictError(OptionError): ... -class OptionValueError(OptParseError): ... - -class HelpFormatter: - NO_DEFAULT_VALUE: _Text - _long_opt_fmt: _Text - _short_opt_fmt: _Text - current_indent: int - default_tag: _Text - help_position: Any - help_width: Any - indent_increment: int - level: int - max_help_position: int - option_strings: dict[Option, _Text] - parser: OptionParser - short_first: Any - width: int - def __init__(self, indent_increment: int, max_help_position: int, width: int | None, short_first: int) -> None: ... - def dedent(self) -> None: ... - def expand_default(self, option: Option) -> _Text: ... - def format_description(self, description: _Text) -> _Text: ... - def format_epilog(self, epilog: _Text) -> _Text: ... - def format_heading(self, heading: Any) -> _Text: ... - def format_option(self, option: Option) -> _Text: ... - def format_option_strings(self, option: Option) -> _Text: ... - def format_usage(self, usage: Any) -> _Text: ... - def indent(self) -> None: ... - def set_long_opt_delimiter(self, delim: _Text) -> None: ... - def set_parser(self, parser: OptionParser) -> None: ... - def set_short_opt_delimiter(self, delim: _Text) -> None: ... - def store_option_strings(self, parser: OptionParser) -> None: ... - -class IndentedHelpFormatter(HelpFormatter): - def __init__( - self, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ..., short_first: int = ... - ) -> None: ... - def format_heading(self, heading: _Text) -> _Text: ... - def format_usage(self, usage: _Text) -> _Text: ... - -class TitledHelpFormatter(HelpFormatter): - def __init__( - self, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ..., short_first: int = ... - ) -> None: ... - def format_heading(self, heading: _Text) -> _Text: ... - def format_usage(self, usage: _Text) -> _Text: ... - -class Option: - ACTIONS: tuple[_Text, ...] - ALWAYS_TYPED_ACTIONS: tuple[_Text, ...] - ATTRS: list[_Text] - CHECK_METHODS: list[Callable[..., Any]] | None - CONST_ACTIONS: tuple[_Text, ...] - STORE_ACTIONS: tuple[_Text, ...] - TYPED_ACTIONS: tuple[_Text, ...] - TYPES: tuple[_Text, ...] - TYPE_CHECKER: dict[_Text, Callable[..., Any]] - _long_opts: list[_Text] - _short_opts: list[_Text] - action: _Text - dest: _Text | None - default: Any - nargs: int - type: Any - callback: Callable[..., Any] | None - callback_args: tuple[Any, ...] | None - callback_kwargs: dict[_Text, Any] | None - help: _Text | None - metavar: _Text | None - def __init__(self, *opts: _Text | None, **attrs: Any) -> None: ... - def _check_action(self) -> None: ... - def _check_callback(self) -> None: ... - def _check_choice(self) -> None: ... - def _check_const(self) -> None: ... - def _check_dest(self) -> None: ... - def _check_nargs(self) -> None: ... - def _check_opt_strings(self, opts: Iterable[_Text | None]) -> list[_Text]: ... - def _check_type(self) -> None: ... - def _set_attrs(self, attrs: dict[_Text, Any]) -> None: ... - def _set_opt_strings(self, opts: Iterable[_Text]) -> None: ... - def check_value(self, opt: _Text, value: Any) -> Any: ... - def convert_value(self, opt: _Text, value: Any) -> Any: ... - def get_opt_string(self) -> _Text: ... - def process(self, opt: Any, value: Any, values: Any, parser: OptionParser) -> int: ... - def take_action(self, action: _Text, dest: _Text, opt: Any, value: Any, values: Any, parser: OptionParser) -> int: ... - def takes_value(self) -> bool: ... - -make_option = Option - -class OptionContainer: - _long_opt: dict[_Text, Option] - _short_opt: dict[_Text, Option] - conflict_handler: _Text - defaults: dict[_Text, Any] - description: Any - option_class: type[Option] - def __init__(self, option_class: type[Option], conflict_handler: Any, description: Any) -> None: ... - def _check_conflict(self, option: Any) -> None: ... - def _create_option_mappings(self) -> None: ... - def _share_option_mappings(self, parser: OptionParser) -> None: ... - @overload - def add_option(self, opt: Option) -> Option: ... - @overload - def add_option(self, *args: _Text | None, **kwargs: Any) -> Any: ... - def add_options(self, option_list: Iterable[Option]) -> None: ... - def destroy(self) -> None: ... - def format_description(self, formatter: HelpFormatter | None) -> Any: ... - def format_help(self, formatter: HelpFormatter | None) -> _Text: ... - def format_option_help(self, formatter: HelpFormatter | None) -> _Text: ... - def get_description(self) -> Any: ... - def get_option(self, opt_str: _Text) -> Option | None: ... - def has_option(self, opt_str: _Text) -> bool: ... - def remove_option(self, opt_str: _Text) -> None: ... - def set_conflict_handler(self, handler: Any) -> None: ... - def set_description(self, description: Any) -> None: ... - -class OptionGroup(OptionContainer): - option_list: list[Option] - parser: OptionParser - title: _Text - def __init__(self, parser: OptionParser, title: _Text, description: _Text | None = ...) -> None: ... - def _create_option_list(self) -> None: ... - def set_title(self, title: _Text) -> None: ... - -class Values: - def __init__(self, defaults: Mapping[str, Any] | None = ...) -> None: ... - def _update(self, dict: Mapping[_Text, Any], mode: Any) -> None: ... - def _update_careful(self, dict: Mapping[_Text, Any]) -> None: ... - def _update_loose(self, dict: Mapping[_Text, Any]) -> None: ... - def ensure_value(self, attr: _Text, value: Any) -> Any: ... - def read_file(self, filename: _Text, mode: _Text = ...) -> None: ... - def read_module(self, modname: _Text, mode: _Text = ...) -> None: ... - def __getattr__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - -class OptionParser(OptionContainer): - allow_interspersed_args: bool - epilog: _Text | None - formatter: HelpFormatter - largs: list[_Text] | None - option_groups: list[OptionGroup] - option_list: list[Option] - process_default_values: Any - prog: _Text | None - rargs: list[Any] | None - standard_option_list: list[Option] - usage: _Text | None - values: Values | None - version: _Text - def __init__( - self, - usage: _Text | None = ..., - option_list: Iterable[Option] | None = ..., - option_class: type[Option] = ..., - version: _Text | None = ..., - conflict_handler: _Text = ..., - description: _Text | None = ..., - formatter: HelpFormatter | None = ..., - add_help_option: bool = ..., - prog: _Text | None = ..., - epilog: _Text | None = ..., - ) -> None: ... - def _add_help_option(self) -> None: ... - 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[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[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: ... - @overload - def add_option_group(self, __opt_group: OptionGroup) -> OptionGroup: ... - @overload - def add_option_group(self, *args: Any, **kwargs: Any) -> OptionGroup: ... - def check_values(self, values: Values, args: list[_Text]) -> tuple[Values, list[_Text]]: ... - def disable_interspersed_args(self) -> None: ... - def enable_interspersed_args(self) -> None: ... - def error(self, msg: _Text) -> None: ... - def exit(self, status: int = ..., msg: str | None = ...) -> None: ... - def expand_prog_name(self, s: _Text | None) -> Any: ... - def format_epilog(self, formatter: HelpFormatter) -> Any: ... - def format_help(self, formatter: HelpFormatter | None = ...) -> _Text: ... - def format_option_help(self, formatter: HelpFormatter | None = ...) -> _Text: ... - def get_default_values(self) -> Values: ... - def get_option_group(self, opt_str: _Text) -> Any: ... - def get_prog_name(self) -> _Text: ... - def get_usage(self) -> _Text: ... - def get_version(self) -> _Text: ... - def parse_args(self, args: Sequence[AnyStr] | None = ..., values: Values | None = ...) -> tuple[Values, list[AnyStr]]: ... - def print_usage(self, file: IO[str] | None = ...) -> None: ... - def print_help(self, file: IO[str] | None = ...) -> None: ... - def print_version(self, file: IO[str] | None = ...) -> None: ... - def set_default(self, dest: Any, value: Any) -> None: ... - def set_defaults(self, **kwargs: Any) -> None: ... - def set_process_default_values(self, process: Any) -> None: ... - def set_usage(self, usage: _Text) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/os/__init__.pyi b/mypy/typeshed/stdlib/@python2/os/__init__.pyi deleted file mode 100644 index c2e806ff0fb6..000000000000 --- a/mypy/typeshed/stdlib/@python2/os/__init__.pyi +++ /dev/null @@ -1,331 +0,0 @@ -import sys -from _typeshed import FileDescriptorLike -from builtins import OSError -from posix import listdir as listdir, stat_result as stat_result # TODO: use this, see https://github.com/python/mypy/issues/3078 -from typing import ( - IO, - Any, - AnyStr, - Callable, - Generic, - Iterator, - Mapping, - MutableMapping, - NamedTuple, - NoReturn, - Sequence, - Text, - TypeVar, - overload, -) - -from . import path as path - -# We need to use something from path, or flake8 and pytype get unhappy -_supports_unicode_filenames = path.supports_unicode_filenames - -_T = TypeVar("_T") - -# ----- os variables ----- - -error = OSError - -SEEK_SET: int -SEEK_CUR: int -SEEK_END: int - -O_RDONLY: int -O_WRONLY: int -O_RDWR: int -O_APPEND: int -O_CREAT: int -O_EXCL: int -O_TRUNC: int -# We don't use sys.platform for O_* flags to denote platform-dependent APIs because some codes, -# including tests for mypy, use a more finer way than sys.platform before using these APIs -# See https://github.com/python/typeshed/pull/2286 for discussions -O_DSYNC: int # Unix only -O_RSYNC: int # Unix only -O_SYNC: int # Unix only -O_NDELAY: int # Unix only -O_NONBLOCK: int # Unix only -O_NOCTTY: int # Unix only -O_SHLOCK: int # Unix only -O_EXLOCK: int # Unix only -O_BINARY: int # Windows only -O_NOINHERIT: int # Windows only -O_SHORT_LIVED: int # Windows only -O_TEMPORARY: int # Windows only -O_RANDOM: int # Windows only -O_SEQUENTIAL: int # Windows only -O_TEXT: int # Windows only -O_ASYNC: int # Gnu extension if in C library -O_DIRECT: int # Gnu extension if in C library -O_DIRECTORY: int # Gnu extension if in C library -O_NOFOLLOW: int # Gnu extension if in C library -O_NOATIME: int # Gnu extension if in C library -O_LARGEFILE: int # Gnu extension if in C library - -curdir: str -pardir: str -sep: str -if sys.platform == "win32": - altsep: str -else: - altsep: str | None -extsep: str -pathsep: str -defpath: str -linesep: str -devnull: str -name: str - -F_OK: int -R_OK: int -W_OK: int -X_OK: int - -class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): - def copy(self) -> dict[AnyStr, AnyStr]: ... - def __delitem__(self, key: AnyStr) -> None: ... - def __getitem__(self, key: AnyStr) -> AnyStr: ... - def __setitem__(self, key: AnyStr, value: AnyStr) -> None: ... - def __iter__(self) -> Iterator[AnyStr]: ... - def __len__(self) -> int: ... - -environ: _Environ[str] -if sys.platform != "win32": - # Unix only - confstr_names: dict[str, int] - pathconf_names: dict[str, int] - sysconf_names: dict[str, int] - - EX_OK: int - EX_USAGE: int - EX_DATAERR: int - EX_NOINPUT: int - EX_NOUSER: int - EX_NOHOST: int - EX_UNAVAILABLE: int - EX_SOFTWARE: int - EX_OSERR: int - EX_OSFILE: int - EX_CANTCREAT: int - EX_IOERR: int - EX_TEMPFAIL: int - EX_PROTOCOL: int - EX_NOPERM: int - EX_CONFIG: int - EX_NOTFOUND: int - -P_NOWAIT: int -P_NOWAITO: int -P_WAIT: int -if sys.platform == "win32": - P_DETACH: int - P_OVERLAY: int - -# wait()/waitpid() options -if sys.platform != "win32": - WNOHANG: int # Unix only - WCONTINUED: int # some Unix systems - WUNTRACED: int # Unix only - -TMP_MAX: int # Undocumented, but used by tempfile - -# ----- os classes (structures) ----- -class _StatVFS(NamedTuple): - f_bsize: int - f_frsize: int - f_blocks: int - f_bfree: int - f_bavail: int - f_files: int - f_ffree: int - f_favail: int - f_flag: int - f_namemax: int - -def getlogin() -> str: ... -def getpid() -> int: ... -def getppid() -> int: ... -def strerror(code: int) -> str: ... -def umask(mask: int) -> int: ... - -if sys.platform != "win32": - def ctermid() -> str: ... - def getegid() -> int: ... - def geteuid() -> int: ... - def getgid() -> int: ... - def getgroups() -> list[int]: ... # Unix only, behaves differently on Mac - def initgroups(username: str, gid: int) -> None: ... - def getpgid(pid: int) -> int: ... - def getpgrp() -> int: ... - def getresuid() -> tuple[int, int, int]: ... - def getresgid() -> tuple[int, int, int]: ... - def getuid() -> int: ... - def setegid(egid: int) -> None: ... - def seteuid(euid: int) -> None: ... - def setgid(gid: int) -> None: ... - def setgroups(groups: Sequence[int]) -> None: ... - def setpgrp() -> None: ... - def setpgid(pid: int, pgrp: int) -> None: ... - def setregid(rgid: int, egid: int) -> None: ... - def setresgid(rgid: int, egid: int, sgid: int) -> None: ... - def setresuid(ruid: int, euid: int, suid: int) -> None: ... - def setreuid(ruid: int, euid: int) -> None: ... - def getsid(pid: int) -> int: ... - def setsid() -> None: ... - def setuid(uid: int) -> None: ... - def uname() -> tuple[str, str, str, str, str]: ... - -@overload -def getenv(key: Text) -> str | None: ... -@overload -def getenv(key: Text, default: _T) -> str | _T: ... -def putenv(key: bytes | Text, value: bytes | Text) -> None: ... -def unsetenv(key: bytes | Text) -> None: ... -def fdopen(fd: int, *args, **kwargs) -> IO[Any]: ... -def close(fd: int) -> None: ... -def closerange(fd_low: int, fd_high: int) -> None: ... -def dup(fd: int) -> int: ... -def dup2(fd: int, fd2: int) -> None: ... -def fstat(fd: int) -> Any: ... -def fsync(fd: FileDescriptorLike) -> None: ... -def lseek(fd: int, pos: int, how: int) -> int: ... -def open(file: Text, flags: int, mode: int = ...) -> int: ... -def pipe() -> tuple[int, int]: ... -def read(fd: int, n: int) -> bytes: ... -def write(fd: int, string: bytes | buffer) -> int: ... -def access(path: Text, mode: int) -> bool: ... -def chdir(path: Text) -> None: ... -def fchdir(fd: FileDescriptorLike) -> None: ... -def getcwd() -> str: ... -def getcwdu() -> unicode: ... -def chmod(path: Text, mode: int) -> None: ... -def link(src: Text, link_name: Text) -> None: ... -def lstat(path: Text) -> Any: ... -def mknod(filename: Text, mode: int = ..., device: int = ...) -> None: ... -def major(device: int) -> int: ... -def minor(device: int) -> int: ... -def makedev(major: int, minor: int) -> int: ... -def mkdir(path: Text, mode: int = ...) -> None: ... -def makedirs(path: Text, mode: int = ...) -> None: ... -def readlink(path: AnyStr) -> AnyStr: ... -def remove(path: Text) -> None: ... -def removedirs(path: Text) -> None: ... -def rename(src: Text, dst: Text) -> None: ... -def renames(old: Text, new: Text) -> None: ... -def rmdir(path: Text) -> None: ... -def stat(path: Text) -> Any: ... -@overload -def stat_float_times() -> bool: ... -@overload -def stat_float_times(newvalue: bool) -> None: ... -def symlink(source: Text, link_name: Text) -> None: ... -def unlink(path: Text) -> None: ... - -# TODO: add ns, dir_fd, follow_symlinks argument -def utime(path: Text, times: tuple[float, float] | None) -> None: ... - -if sys.platform != "win32": - # Unix only - def fchmod(fd: int, mode: int) -> None: ... - def fchown(fd: int, uid: int, gid: int) -> None: ... - if sys.platform != "darwin": - def fdatasync(fd: FileDescriptorLike) -> None: ... # Unix only, not Mac - - def fpathconf(fd: int, name: str | int) -> int: ... - def fstatvfs(fd: int) -> _StatVFS: ... - def ftruncate(fd: int, length: int) -> None: ... - def isatty(fd: int) -> bool: ... - def openpty() -> tuple[int, int]: ... # some flavors of Unix - def tcgetpgrp(fd: int) -> int: ... - def tcsetpgrp(fd: int, pg: int) -> None: ... - def ttyname(fd: int) -> str: ... - def chflags(path: Text, flags: int) -> None: ... - def chroot(path: Text) -> None: ... - def chown(path: Text, uid: int, gid: int) -> None: ... - def lchflags(path: Text, flags: int) -> None: ... - def lchmod(path: Text, mode: int) -> None: ... - def lchown(path: Text, uid: int, gid: int) -> None: ... - def mkfifo(path: Text, mode: int = ...) -> None: ... - def pathconf(path: Text, name: str | int) -> int: ... - def statvfs(path: Text) -> _StatVFS: ... - -def walk( - top: AnyStr, topdown: bool = ..., onerror: Callable[[OSError], Any] | None = ..., followlinks: bool = ... -) -> Iterator[tuple[AnyStr, list[AnyStr], list[AnyStr]]]: ... -def abort() -> NoReturn: ... - -# These are defined as execl(file, *args) but the first *arg is mandatory. -def execl(file: Text, __arg0: bytes | Text, *args: bytes | Text) -> NoReturn: ... -def execlp(file: Text, __arg0: bytes | Text, *args: bytes | Text) -> NoReturn: ... - -# These are: execle(file, *args, env) but env is pulled from the last element of the args. -def execle(file: Text, __arg0: bytes | Text, *args: Any) -> NoReturn: ... -def execlpe(file: Text, __arg0: bytes | Text, *args: Any) -> NoReturn: ... - -# The docs say `args: tuple or list of strings` -# The implementation enforces tuple or list so we can't use Sequence. -_ExecVArgs = tuple[bytes | Text, ...] | list[bytes] | list[Text] | list[bytes | Text] - -def execv(path: Text, args: _ExecVArgs) -> NoReturn: ... -def execve(path: Text, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... -def execvp(file: Text, args: _ExecVArgs) -> NoReturn: ... -def execvpe(file: Text, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... -def _exit(n: int) -> NoReturn: ... -def kill(pid: int, sig: int) -> None: ... - -if sys.platform != "win32": - # Unix only - def fork() -> int: ... - def forkpty() -> tuple[int, int]: ... # some flavors of Unix - def killpg(__pgid: int, __signal: int) -> None: ... - def nice(increment: int) -> int: ... - def plock(op: int) -> None: ... # ???op is int? - -def popen(command: str, *args, **kwargs) -> IO[Any]: ... -def popen2(cmd: str, *args, **kwargs) -> tuple[IO[Any], IO[Any]]: ... -def popen3(cmd: str, *args, **kwargs) -> tuple[IO[Any], IO[Any], IO[Any]]: ... -def popen4(cmd: str, *args, **kwargs) -> tuple[IO[Any], IO[Any]]: ... -def spawnl(mode: int, path: Text, arg0: bytes | Text, *args: bytes | Text) -> int: ... -def spawnle(mode: int, path: Text, arg0: bytes | Text, *args: Any) -> int: ... # Imprecise sig -def spawnv(mode: int, path: Text, args: list[bytes | Text]) -> int: ... -def spawnve(mode: int, path: Text, args: list[bytes | Text], env: Mapping[str, str]) -> int: ... -def system(command: Text) -> int: ... -def times() -> tuple[float, float, float, float, float]: ... -def waitpid(pid: int, options: int) -> tuple[int, int]: ... -def urandom(n: int) -> bytes: ... - -if sys.platform == "win32": - def startfile(path: Text, operation: str | None = ...) -> None: ... - -else: - # Unix only - def spawnlp(mode: int, file: Text, arg0: bytes | Text, *args: bytes | Text) -> int: ... - def spawnlpe(mode: int, file: Text, arg0: bytes | Text, *args: Any) -> int: ... # Imprecise signature - def spawnvp(mode: int, file: Text, args: list[bytes | Text]) -> int: ... - def spawnvpe(mode: int, file: Text, args: list[bytes | Text], env: Mapping[str, str]) -> int: ... - def wait() -> tuple[int, int]: ... - def wait3(options: int) -> tuple[int, int, Any]: ... - def wait4(pid: int, options: int) -> tuple[int, int, Any]: ... - def WCOREDUMP(status: int) -> bool: ... - def WIFCONTINUED(status: int) -> bool: ... - def WIFSTOPPED(status: int) -> bool: ... - def WIFSIGNALED(status: int) -> bool: ... - def WIFEXITED(status: int) -> bool: ... - def WEXITSTATUS(status: int) -> int: ... - def WSTOPSIG(status: int) -> int: ... - def WTERMSIG(status: int) -> int: ... - def confstr(name: str | int) -> str | None: ... - def getloadavg() -> tuple[float, float, float]: ... - def sysconf(name: str | int) -> int: ... - -def tmpfile() -> IO[Any]: ... -def tmpnam() -> str: ... -def tempnam(dir: str = ..., prefix: str = ...) -> str: ... - -P_ALL: int -WEXITED: int -WNOWAIT: int diff --git a/mypy/typeshed/stdlib/@python2/os/path.pyi b/mypy/typeshed/stdlib/@python2/os/path.pyi deleted file mode 100644 index 4e484ce8a096..000000000000 --- a/mypy/typeshed/stdlib/@python2/os/path.pyi +++ /dev/null @@ -1,84 +0,0 @@ -import os -import sys -from typing import Any, AnyStr, Callable, Sequence, Text, TypeVar, overload - -_T = TypeVar("_T") - -# ----- os.path variables ----- -supports_unicode_filenames: bool -# aliases (also in os) -curdir: str -pardir: str -sep: str -if sys.platform == "win32": - altsep: str -else: - altsep: str | None -extsep: str -pathsep: str -defpath: str -devnull: str - -# ----- os.path function stubs ----- -def abspath(path: AnyStr) -> AnyStr: ... -def basename(p: AnyStr) -> AnyStr: ... -def dirname(p: AnyStr) -> AnyStr: ... -def expanduser(path: AnyStr) -> AnyStr: ... -def expandvars(path: AnyStr) -> AnyStr: ... -def normcase(s: AnyStr) -> AnyStr: ... -def normpath(path: AnyStr) -> AnyStr: ... - -if sys.platform == "win32": - def realpath(path: AnyStr) -> AnyStr: ... - -else: - def realpath(filename: AnyStr) -> AnyStr: ... - -# NOTE: Empty lists results in '' (str) regardless of contained type. -# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes -# So, fall back to Any -def commonprefix(m: Sequence[Text]) -> Any: ... -def exists(path: Text) -> bool: ... -def lexists(path: Text) -> bool: ... - -# These return float if os.stat_float_times() == True, -# but int is a subclass of float. -def getatime(filename: Text) -> float: ... -def getmtime(filename: Text) -> float: ... -def getctime(filename: Text) -> float: ... -def getsize(filename: Text) -> int: ... -def isabs(s: Text) -> bool: ... -def isfile(path: Text) -> bool: ... -def isdir(s: Text) -> bool: ... -def islink(path: Text) -> bool: ... -def ismount(path: Text) -> bool: ... - -# Make sure signatures are disjunct, and allow combinations of bytes and unicode. -# (Since Python 2 allows that, too) -# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in -# a type error. -@overload -def join(__p1: bytes, *p: bytes) -> bytes: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... -@overload -def join(__p1: Text, *p: Text) -> Text: ... -@overload -def relpath(path: str, start: str | None = ...) -> str: ... -@overload -def relpath(path: Text, start: Text | None = ...) -> Text: ... -def samefile(f1: Text, f2: Text) -> bool: ... -def sameopenfile(fp1: int, fp2: int) -> bool: ... -def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... -def split(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitdrive(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitext(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... - -if sys.platform == "win32": - def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated - -def walk(path: AnyStr, visit: Callable[[_T, AnyStr, list[AnyStr]], Any], arg: _T) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/os2emxpath.pyi b/mypy/typeshed/stdlib/@python2/os2emxpath.pyi deleted file mode 100644 index 33732903cb4c..000000000000 --- a/mypy/typeshed/stdlib/@python2/os2emxpath.pyi +++ /dev/null @@ -1,84 +0,0 @@ -import os -import sys -from genericpath import exists as exists -from typing import Any, AnyStr, Callable, Sequence, Text, TypeVar, overload - -_T = TypeVar("_T") - -# ----- os.path variables ----- -supports_unicode_filenames: bool -# aliases (also in os) -curdir: str -pardir: str -sep: str -if sys.platform == "win32": - altsep: str -else: - altsep: str | None -extsep: str -pathsep: str -defpath: str -devnull: str - -# ----- os.path function stubs ----- -def abspath(path: AnyStr) -> AnyStr: ... -def basename(p: AnyStr) -> AnyStr: ... -def dirname(p: AnyStr) -> AnyStr: ... -def expanduser(path: AnyStr) -> AnyStr: ... -def expandvars(path: AnyStr) -> AnyStr: ... -def normcase(s: AnyStr) -> AnyStr: ... -def normpath(path: AnyStr) -> AnyStr: ... - -if sys.platform == "win32": - def realpath(path: AnyStr) -> AnyStr: ... - -else: - def realpath(filename: AnyStr) -> AnyStr: ... - -# NOTE: Empty lists results in '' (str) regardless of contained type. -# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes -# So, fall back to Any -def commonprefix(m: Sequence[Text]) -> Any: ... -def lexists(path: Text) -> bool: ... - -# These return float if os.stat_float_times() == True, -# but int is a subclass of float. -def getatime(filename: Text) -> float: ... -def getmtime(filename: Text) -> float: ... -def getctime(filename: Text) -> float: ... -def getsize(filename: Text) -> int: ... -def isabs(s: Text) -> bool: ... -def isfile(path: Text) -> bool: ... -def isdir(s: Text) -> bool: ... -def islink(path: Text) -> bool: ... -def ismount(path: Text) -> bool: ... - -# Make sure signatures are disjunct, and allow combinations of bytes and unicode. -# (Since Python 2 allows that, too) -# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in -# a type error. -@overload -def join(__p1: bytes, *p: bytes) -> bytes: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... -@overload -def join(__p1: Text, *p: Text) -> Text: ... -@overload -def relpath(path: str, start: str | None = ...) -> str: ... -@overload -def relpath(path: Text, start: Text | None = ...) -> Text: ... -def samefile(f1: Text, f2: Text) -> bool: ... -def sameopenfile(fp1: int, fp2: int) -> bool: ... -def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... -def split(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitdrive(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitext(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... - -if sys.platform == "win32": - def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated - -def walk(path: AnyStr, visit: Callable[[_T, AnyStr, list[AnyStr]], Any], arg: _T) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/ossaudiodev.pyi b/mypy/typeshed/stdlib/@python2/ossaudiodev.pyi deleted file mode 100644 index d956a89729fd..000000000000 --- a/mypy/typeshed/stdlib/@python2/ossaudiodev.pyi +++ /dev/null @@ -1,132 +0,0 @@ -import sys -from typing import Any, overload -from typing_extensions import Literal - -if sys.platform != "win32" and sys.platform != "darwin": - AFMT_AC3: int - AFMT_A_LAW: int - AFMT_IMA_ADPCM: int - AFMT_MPEG: int - AFMT_MU_LAW: int - AFMT_QUERY: int - AFMT_S16_BE: int - AFMT_S16_LE: int - AFMT_S16_NE: int - AFMT_S8: int - AFMT_U16_BE: int - AFMT_U16_LE: int - AFMT_U8: int - SNDCTL_COPR_HALT: int - SNDCTL_COPR_LOAD: int - SNDCTL_COPR_RCODE: int - SNDCTL_COPR_RCVMSG: int - SNDCTL_COPR_RDATA: int - SNDCTL_COPR_RESET: int - SNDCTL_COPR_RUN: int - SNDCTL_COPR_SENDMSG: int - SNDCTL_COPR_WCODE: int - SNDCTL_COPR_WDATA: int - SNDCTL_DSP_BIND_CHANNEL: int - SNDCTL_DSP_CHANNELS: int - SNDCTL_DSP_GETBLKSIZE: int - SNDCTL_DSP_GETCAPS: int - SNDCTL_DSP_GETCHANNELMASK: int - SNDCTL_DSP_GETFMTS: int - SNDCTL_DSP_GETIPTR: int - SNDCTL_DSP_GETISPACE: int - SNDCTL_DSP_GETODELAY: int - SNDCTL_DSP_GETOPTR: int - SNDCTL_DSP_GETOSPACE: int - SNDCTL_DSP_GETSPDIF: int - SNDCTL_DSP_GETTRIGGER: int - SNDCTL_DSP_MAPINBUF: int - SNDCTL_DSP_MAPOUTBUF: int - SNDCTL_DSP_NONBLOCK: int - SNDCTL_DSP_POST: int - SNDCTL_DSP_PROFILE: int - SNDCTL_DSP_RESET: int - SNDCTL_DSP_SAMPLESIZE: int - SNDCTL_DSP_SETDUPLEX: int - SNDCTL_DSP_SETFMT: int - SNDCTL_DSP_SETFRAGMENT: int - SNDCTL_DSP_SETSPDIF: int - SNDCTL_DSP_SETSYNCRO: int - SNDCTL_DSP_SETTRIGGER: int - SNDCTL_DSP_SPEED: int - SNDCTL_DSP_STEREO: int - SNDCTL_DSP_SUBDIVIDE: int - SNDCTL_DSP_SYNC: int - SNDCTL_FM_4OP_ENABLE: int - SNDCTL_FM_LOAD_INSTR: int - SNDCTL_MIDI_INFO: int - SNDCTL_MIDI_MPUCMD: int - SNDCTL_MIDI_MPUMODE: int - SNDCTL_MIDI_PRETIME: int - SNDCTL_SEQ_CTRLRATE: int - SNDCTL_SEQ_GETINCOUNT: int - SNDCTL_SEQ_GETOUTCOUNT: int - SNDCTL_SEQ_GETTIME: int - SNDCTL_SEQ_NRMIDIS: int - SNDCTL_SEQ_NRSYNTHS: int - SNDCTL_SEQ_OUTOFBAND: int - SNDCTL_SEQ_PANIC: int - SNDCTL_SEQ_PERCMODE: int - SNDCTL_SEQ_RESET: int - SNDCTL_SEQ_RESETSAMPLES: int - SNDCTL_SEQ_SYNC: int - SNDCTL_SEQ_TESTMIDI: int - SNDCTL_SEQ_THRESHOLD: int - SNDCTL_SYNTH_CONTROL: int - SNDCTL_SYNTH_ID: int - SNDCTL_SYNTH_INFO: int - SNDCTL_SYNTH_MEMAVL: int - SNDCTL_SYNTH_REMOVESAMPLE: int - SNDCTL_TMR_CONTINUE: int - SNDCTL_TMR_METRONOME: int - SNDCTL_TMR_SELECT: int - SNDCTL_TMR_SOURCE: int - SNDCTL_TMR_START: int - SNDCTL_TMR_STOP: int - SNDCTL_TMR_TEMPO: int - SNDCTL_TMR_TIMEBASE: int - SOUND_MIXER_ALTPCM: int - SOUND_MIXER_BASS: int - SOUND_MIXER_CD: int - SOUND_MIXER_DIGITAL1: int - SOUND_MIXER_DIGITAL2: int - SOUND_MIXER_DIGITAL3: int - SOUND_MIXER_IGAIN: int - SOUND_MIXER_IMIX: int - SOUND_MIXER_LINE: int - SOUND_MIXER_LINE1: int - SOUND_MIXER_LINE2: int - SOUND_MIXER_LINE3: int - SOUND_MIXER_MIC: int - SOUND_MIXER_MONITOR: int - SOUND_MIXER_NRDEVICES: int - SOUND_MIXER_OGAIN: int - SOUND_MIXER_PCM: int - SOUND_MIXER_PHONEIN: int - SOUND_MIXER_PHONEOUT: int - SOUND_MIXER_RADIO: int - SOUND_MIXER_RECLEV: int - SOUND_MIXER_SPEAKER: int - SOUND_MIXER_SYNTH: int - SOUND_MIXER_TREBLE: int - SOUND_MIXER_VIDEO: int - SOUND_MIXER_VOLUME: int - - control_labels: list[str] - control_names: list[str] - - # TODO: oss_audio_device return type - @overload - def open(mode: Literal["r", "w", "rw"]) -> Any: ... - @overload - def open(device: str, mode: Literal["r", "w", "rw"]) -> Any: ... - - # TODO: oss_mixer_device return type - def openmixer(device: str = ...) -> Any: ... - - class OSSAudioError(Exception): ... - error = OSSAudioError diff --git a/mypy/typeshed/stdlib/@python2/parser.pyi b/mypy/typeshed/stdlib/@python2/parser.pyi deleted file mode 100644 index de88bc0ba056..000000000000 --- a/mypy/typeshed/stdlib/@python2/parser.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from types import CodeType -from typing import Any, Sequence, Text - -def expr(source: Text) -> STType: ... -def suite(source: Text) -> STType: ... -def sequence2st(sequence: Sequence[Any]) -> STType: ... -def tuple2st(sequence: Sequence[Any]) -> STType: ... -def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... -def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... -def compilest(st: STType, filename: Text = ...) -> CodeType: ... -def isexpr(st: STType) -> bool: ... -def issuite(st: STType) -> bool: ... - -class ParserError(Exception): ... - -class STType: - def compile(self, filename: Text = ...) -> CodeType: ... - def isexpr(self) -> bool: ... - def issuite(self) -> bool: ... - def tolist(self, line_info: bool = ..., col_info: bool = ...) -> list[Any]: ... - def totuple(self, line_info: bool = ..., col_info: bool = ...) -> tuple[Any, ...]: ... diff --git a/mypy/typeshed/stdlib/@python2/pdb.pyi b/mypy/typeshed/stdlib/@python2/pdb.pyi deleted file mode 100644 index 4600b5818eb3..000000000000 --- a/mypy/typeshed/stdlib/@python2/pdb.pyi +++ /dev/null @@ -1,167 +0,0 @@ -from bdb import Bdb -from cmd import Cmd -from types import FrameType, TracebackType -from typing import IO, Any, Callable, ClassVar, Iterable, Mapping, TypeVar -from typing_extensions import ParamSpec - -_T = TypeVar("_T") -_P = ParamSpec("_P") - -line_prefix: str # undocumented - -class Restart(Exception): ... - -def run(statement: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... -def runeval(expression: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> Any: ... -def runctx(statement: str, globals: dict[str, Any], locals: Mapping[str, Any]) -> None: ... -def runcall(func: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> _T | None: ... -def set_trace() -> None: ... -def post_mortem(t: TracebackType | None = ...) -> None: ... -def pm() -> None: ... - -class Pdb(Bdb, Cmd): - # Everything here is undocumented, except for __init__ - - commands_resuming: ClassVar[list[str]] - - aliases: dict[str, str] - mainpyfile: str - _wait_for_mainpyfile: bool - rcLines: list[str] - commands: dict[int, list[str]] - commands_doprompt: dict[int, bool] - commands_silent: dict[int, bool] - commands_defining: bool - commands_bnum: int | None - lineno: int | None - stack: list[tuple[FrameType, int]] - curindex: int - curframe: FrameType | None - curframe_locals: Mapping[str, Any] - def __init__( - self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ..., skip: Iterable[str] | None = ... - ) -> None: ... - def forget(self) -> None: ... - def setup(self, f: FrameType | None, tb: TracebackType | None) -> None: ... - def execRcLines(self) -> None: ... - def bp_commands(self, frame: FrameType) -> bool: ... - def interaction(self, frame: FrameType | None, traceback: TracebackType | None) -> None: ... - def displayhook(self, obj: object) -> None: ... - def handle_command_def(self, line: str) -> bool: ... - def defaultFile(self) -> str: ... - def lineinfo(self, identifier: str) -> tuple[None, None, None] | tuple[str, str, int]: ... - def checkline(self, filename: str, lineno: int) -> int: ... - def _getval(self, arg: str) -> object: ... - def print_stack_trace(self) -> None: ... - def print_stack_entry(self, frame_lineno: tuple[FrameType, int], prompt_prefix: str = ...) -> None: ... - def lookupmodule(self, filename: str) -> str | None: ... - def _runscript(self, filename: str) -> None: ... - def do_commands(self, arg: str) -> bool | None: ... - def do_break(self, arg: str, temporary: bool = ...) -> bool | None: ... - def do_tbreak(self, arg: str) -> bool | None: ... - def do_enable(self, arg: str) -> bool | None: ... - def do_disable(self, arg: str) -> bool | None: ... - def do_condition(self, arg: str) -> bool | None: ... - def do_ignore(self, arg: str) -> bool | None: ... - def do_clear(self, arg: str) -> bool | None: ... - def do_where(self, arg: str) -> bool | None: ... - def do_up(self, arg: str) -> bool | None: ... - def do_down(self, arg: str) -> bool | None: ... - def do_until(self, arg: str) -> bool | None: ... - def do_step(self, arg: str) -> bool | None: ... - def do_next(self, arg: str) -> bool | None: ... - def do_run(self, arg: str) -> bool | None: ... - def do_return(self, arg: str) -> bool | None: ... - def do_continue(self, arg: str) -> bool | None: ... - def do_jump(self, arg: str) -> bool | None: ... - def do_debug(self, arg: str) -> bool | None: ... - def do_quit(self, arg: str) -> bool | None: ... - def do_EOF(self, arg: str) -> bool | None: ... - def do_args(self, arg: str) -> bool | None: ... - def do_retval(self, arg: str) -> bool | None: ... - def do_p(self, arg: str) -> bool | None: ... - def do_pp(self, arg: str) -> bool | None: ... - def do_list(self, arg: str) -> bool | None: ... - def do_whatis(self, arg: str) -> bool | None: ... - def do_alias(self, arg: str) -> bool | None: ... - def do_unalias(self, arg: str) -> bool | None: ... - def do_help(self, arg: str) -> bool | None: ... - do_b = do_break - do_cl = do_clear - do_w = do_where - do_bt = do_where - do_u = do_up - do_d = do_down - do_unt = do_until - do_s = do_step - do_n = do_next - do_restart = do_run - do_r = do_return - do_c = do_continue - do_cont = do_continue - do_j = do_jump - do_q = do_quit - do_exit = do_quit - do_a = do_args - do_rv = do_retval - do_l = do_list - do_h = do_help - def help_exec(self) -> None: ... - def help_pdb(self) -> None: ... - def help_help(self) -> None: ... - def help_h(self) -> None: ... - def help_where(self) -> None: ... - def help_w(self) -> None: ... - def help_down(self) -> None: ... - def help_d(self) -> None: ... - def help_up(self) -> None: ... - def help_u(self) -> None: ... - def help_break(self) -> None: ... - def help_b(self) -> None: ... - def help_clear(self) -> None: ... - def help_cl(self) -> None: ... - def help_tbreak(self) -> None: ... - def help_enable(self) -> None: ... - def help_disable(self) -> None: ... - def help_ignore(self) -> None: ... - def help_condition(self) -> None: ... - def help_step(self) -> None: ... - def help_s(self) -> None: ... - def help_until(self) -> None: ... - def help_unt(self) -> None: ... - def help_next(self) -> None: ... - def help_n(self) -> None: ... - def help_return(self) -> None: ... - def help_r(self) -> None: ... - def help_continue(self) -> None: ... - def help_cont(self) -> None: ... - def help_c(self) -> None: ... - def help_jump(self) -> None: ... - def help_j(self) -> None: ... - def help_debug(self) -> None: ... - def help_list(self) -> None: ... - def help_l(self) -> None: ... - def help_args(self) -> None: ... - def help_a(self) -> None: ... - def help_p(self) -> None: ... - def help_pp(self) -> None: ... - def help_run(self) -> None: ... - def help_quit(self) -> None: ... - def help_q(self) -> None: ... - def help_whatis(self) -> None: ... - def help_EOF(self) -> None: ... - def help_alias(self) -> None: ... - def help_unalias(self) -> None: ... - def help_commands(self) -> None: ... - help_bt = help_w - help_restart = help_run - help_exit = help_q - -# undocumented - -def find_function(funcname: str, filename: str) -> tuple[str, str, int] | None: ... -def main() -> None: ... -def help() -> None: ... - -class _rstr(str): - def __repr__(self) -> _rstr: ... diff --git a/mypy/typeshed/stdlib/@python2/pickle.pyi b/mypy/typeshed/stdlib/@python2/pickle.pyi deleted file mode 100644 index c3052f5c3113..000000000000 --- a/mypy/typeshed/stdlib/@python2/pickle.pyi +++ /dev/null @@ -1,95 +0,0 @@ -from typing import IO, Any, Callable, Iterator, Union - -HIGHEST_PROTOCOL: int -bytes_types: tuple[type[Any], ...] # undocumented - -def dump(obj: Any, file: IO[bytes], protocol: int | None = ...) -> None: ... -def dumps(obj: Any, protocol: int | None = ...) -> bytes: ... -def load(file: IO[bytes]) -> Any: ... -def loads(string: bytes) -> Any: ... - -class PickleError(Exception): ... -class PicklingError(PickleError): ... -class UnpicklingError(PickleError): ... - -_reducedtype = Union[ - str, - tuple[Callable[..., Any], tuple[Any, ...]], - tuple[Callable[..., Any], tuple[Any, ...], Any], - tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None], - tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None], -] - -class Pickler: - fast: bool - def __init__(self, file: IO[bytes], protocol: int | None = ...) -> None: ... - def dump(self, __obj: Any) -> None: ... - def clear_memo(self) -> None: ... - def persistent_id(self, obj: Any) -> Any: ... - -class Unpickler: - def __init__(self, file: IO[bytes]) -> None: ... - def load(self) -> Any: ... - def find_class(self, __module_name: str, __global_name: str) -> Any: ... - -MARK: bytes -STOP: bytes -POP: bytes -POP_MARK: bytes -DUP: bytes -FLOAT: bytes -INT: bytes -BININT: bytes -BININT1: bytes -LONG: bytes -BININT2: bytes -NONE: bytes -PERSID: bytes -BINPERSID: bytes -REDUCE: bytes -STRING: bytes -BINSTRING: bytes -SHORT_BINSTRING: bytes -UNICODE: bytes -BINUNICODE: bytes -APPEND: bytes -BUILD: bytes -GLOBAL: bytes -DICT: bytes -EMPTY_DICT: bytes -APPENDS: bytes -GET: bytes -BINGET: bytes -INST: bytes -LONG_BINGET: bytes -LIST: bytes -EMPTY_LIST: bytes -OBJ: bytes -PUT: bytes -BINPUT: bytes -LONG_BINPUT: bytes -SETITEM: bytes -TUPLE: bytes -EMPTY_TUPLE: bytes -SETITEMS: bytes -BINFLOAT: bytes - -TRUE: bytes -FALSE: bytes - -# protocol 2 -PROTO: bytes -NEWOBJ: bytes -EXT1: bytes -EXT2: bytes -EXT4: bytes -TUPLE1: bytes -TUPLE2: bytes -TUPLE3: bytes -NEWTRUE: bytes -NEWFALSE: bytes -LONG1: bytes -LONG4: bytes - -def encode_long(x: int) -> bytes: ... # undocumented -def decode_long(data: bytes) -> int: ... # undocumented diff --git a/mypy/typeshed/stdlib/@python2/pickletools.pyi b/mypy/typeshed/stdlib/@python2/pickletools.pyi deleted file mode 100644 index 915b700dc8e5..000000000000 --- a/mypy/typeshed/stdlib/@python2/pickletools.pyi +++ /dev/null @@ -1,124 +0,0 @@ -from typing import IO, Any, Callable, Iterator, MutableMapping, Text - -_Reader = Callable[[IO[bytes]], Any] - -UP_TO_NEWLINE: int -TAKEN_FROM_ARGUMENT1: int -TAKEN_FROM_ARGUMENT4: int - -class ArgumentDescriptor(object): - name: str - n: int - reader: _Reader - doc: str - def __init__(self, name: str, n: int, reader: _Reader, doc: str) -> None: ... - -def read_uint1(f: IO[bytes]) -> int: ... - -uint1: ArgumentDescriptor - -def read_uint2(f: IO[bytes]) -> int: ... - -uint2: ArgumentDescriptor - -def read_int4(f: IO[bytes]) -> int: ... - -int4: ArgumentDescriptor - -def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> bytes | Text: ... - -stringnl: ArgumentDescriptor - -def read_stringnl_noescape(f: IO[bytes]) -> str: ... - -stringnl_noescape: ArgumentDescriptor - -def read_stringnl_noescape_pair(f: IO[bytes]) -> Text: ... - -stringnl_noescape_pair: ArgumentDescriptor - -def read_string1(f: IO[bytes]) -> str: ... - -string1: ArgumentDescriptor - -def read_string4(f: IO[bytes]) -> str: ... - -string4: ArgumentDescriptor - -def read_unicodestringnl(f: IO[bytes]) -> Text: ... - -unicodestringnl: ArgumentDescriptor - -def read_unicodestring4(f: IO[bytes]) -> Text: ... - -unicodestring4: ArgumentDescriptor - -def read_decimalnl_short(f: IO[bytes]) -> int: ... -def read_decimalnl_long(f: IO[bytes]) -> int: ... - -decimalnl_short: ArgumentDescriptor -decimalnl_long: ArgumentDescriptor - -def read_floatnl(f: IO[bytes]) -> float: ... - -floatnl: ArgumentDescriptor - -def read_float8(f: IO[bytes]) -> float: ... - -float8: ArgumentDescriptor - -def read_long1(f: IO[bytes]) -> int: ... - -long1: ArgumentDescriptor - -def read_long4(f: IO[bytes]) -> int: ... - -long4: ArgumentDescriptor - -class StackObject(object): - name: str - obtype: type[Any] | tuple[type[Any], ...] - doc: str - def __init__(self, name: str, obtype: type[Any] | tuple[type[Any], ...], doc: str) -> None: ... - -pyint: StackObject -pylong: StackObject -pyinteger_or_bool: StackObject -pybool: StackObject -pyfloat: StackObject -pystring: StackObject -pyunicode: StackObject -pynone: StackObject -pytuple: StackObject -pylist: StackObject -pydict: StackObject -anyobject: StackObject -markobject: StackObject -stackslice: StackObject - -class OpcodeInfo(object): - name: str - code: str - arg: ArgumentDescriptor | None - stack_before: list[StackObject] - stack_after: list[StackObject] - proto: int - doc: str - def __init__( - self, - name: str, - code: str, - arg: ArgumentDescriptor | None, - stack_before: list[StackObject], - stack_after: list[StackObject], - proto: int, - doc: str, - ) -> None: ... - -opcodes: list[OpcodeInfo] - -def genops(pickle: bytes | IO[bytes]) -> Iterator[tuple[OpcodeInfo, Any | None, int | None]]: ... -def optimize(p: bytes | IO[bytes]) -> bytes: ... -def dis( - pickle: bytes | IO[bytes], out: IO[str] | None = ..., memo: MutableMapping[int, Any] | None = ..., indentlevel: int = ... -) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/pipes.pyi b/mypy/typeshed/stdlib/@python2/pipes.pyi deleted file mode 100644 index 5249543425c6..000000000000 --- a/mypy/typeshed/stdlib/@python2/pipes.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import IO, Any, AnyStr - -class Template: - def __init__(self) -> None: ... - def reset(self) -> None: ... - def clone(self) -> Template: ... - def debug(self, flag: bool) -> None: ... - def append(self, cmd: str, kind: str) -> None: ... - def prepend(self, cmd: str, kind: str) -> None: ... - def open(self, file: str, mode: str) -> IO[Any]: ... - def copy(self, infile: str, outfile: str) -> None: ... - -def quote(s: AnyStr) -> AnyStr: ... diff --git a/mypy/typeshed/stdlib/@python2/pkgutil.pyi b/mypy/typeshed/stdlib/@python2/pkgutil.pyi deleted file mode 100644 index aa220bc3ae61..000000000000 --- a/mypy/typeshed/stdlib/@python2/pkgutil.pyi +++ /dev/null @@ -1,28 +0,0 @@ -from _typeshed import SupportsRead -from typing import IO, Any, Callable, Iterable, Iterator, TypeVar - -Loader = Any -MetaPathFinder = Any -PathEntryFinder = Any - -_PathT = TypeVar("_PathT", bound=Iterable[str]) -_ModuleInfoLike = tuple[MetaPathFinder | PathEntryFinder, str, bool] - -def extend_path(path: _PathT, name: str) -> _PathT: ... - -class ImpImporter: - def __init__(self, path: str | None = ...) -> None: ... - -class ImpLoader: - def __init__(self, fullname: str, file: IO[str], filename: str, etc: tuple[str, str, int]) -> None: ... - -def find_loader(fullname: str) -> Loader | None: ... -def get_importer(path_item: str) -> PathEntryFinder | None: ... -def get_loader(module_or_name: str) -> Loader: ... -def iter_importers(fullname: str = ...) -> Iterator[MetaPathFinder | PathEntryFinder]: ... -def iter_modules(path: Iterable[str] | None = ..., prefix: str = ...) -> Iterator[_ModuleInfoLike]: ... -def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented -def walk_packages( - path: Iterable[str] | None = ..., prefix: str = ..., onerror: Callable[[str], None] | None = ... -) -> Iterator[_ModuleInfoLike]: ... -def get_data(package: str, resource: str) -> bytes | None: ... diff --git a/mypy/typeshed/stdlib/@python2/platform.pyi b/mypy/typeshed/stdlib/@python2/platform.pyi deleted file mode 100644 index 7d71ee943da1..000000000000 --- a/mypy/typeshed/stdlib/@python2/platform.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from typing import Any - -__copyright__: Any -DEV_NULL: Any - -def libc_ver(executable=..., lib=..., version=..., chunksize: int = ...): ... -def linux_distribution(distname=..., version=..., id=..., supported_dists=..., full_distribution_name: int = ...): ... -def dist(distname=..., version=..., id=..., supported_dists=...): ... - -class _popen: - tmpfile: Any - pipe: Any - bufsize: Any - mode: Any - def __init__(self, cmd, mode=..., bufsize: Any | None = ...): ... - def read(self): ... - def readlines(self): ... - def close(self, remove=..., error=...): ... - __del__: Any - -def popen(cmd, mode=..., bufsize: Any | None = ...): ... -def win32_ver(release: str = ..., version: str = ..., csd: str = ..., ptype: str = ...) -> tuple[str, str, str, str]: ... -def mac_ver( - release: str = ..., versioninfo: tuple[str, str, str] = ..., machine: str = ... -) -> tuple[str, tuple[str, str, str], str]: ... -def java_ver( - release: str = ..., vendor: str = ..., vminfo: tuple[str, str, str] = ..., osinfo: tuple[str, str, str] = ... -) -> tuple[str, str, tuple[str, str, str], tuple[str, str, str]]: ... -def system_alias(system, release, version): ... -def architecture(executable=..., bits=..., linkage=...) -> tuple[str, str]: ... -def uname() -> tuple[str, str, str, str, str, str]: ... -def system() -> str: ... -def node() -> str: ... -def release() -> str: ... -def version() -> str: ... -def machine() -> str: ... -def processor() -> str: ... -def python_implementation() -> str: ... -def python_version() -> str: ... -def python_version_tuple() -> tuple[str, str, str]: ... -def python_branch() -> str: ... -def python_revision() -> str: ... -def python_build() -> tuple[str, str]: ... -def python_compiler() -> str: ... -def platform(aliased: int = ..., terse: int = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/plistlib.pyi b/mypy/typeshed/stdlib/@python2/plistlib.pyi deleted file mode 100644 index 488757b4c81e..000000000000 --- a/mypy/typeshed/stdlib/@python2/plistlib.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from typing import IO, Any, Mapping, Text - -_Path = str | Text - -def readPlist(pathOrFile: _Path | IO[bytes]) -> Any: ... -def writePlist(value: Mapping[str, Any], pathOrFile: _Path | IO[bytes]) -> None: ... -def readPlistFromBytes(data: bytes) -> Any: ... -def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... -def readPlistFromResource(path: _Path, restype: str = ..., resid: int = ...) -> Any: ... -def writePlistToResource(rootObject: Mapping[str, Any], path: _Path, restype: str = ..., resid: int = ...) -> None: ... -def readPlistFromString(data: str) -> Any: ... -def writePlistToString(rootObject: Mapping[str, Any]) -> str: ... - -class Dict(dict[str, Any]): - def __getattr__(self, attr: str) -> Any: ... - def __setattr__(self, attr: str, value: Any) -> None: ... - def __delattr__(self, attr: str) -> None: ... - -class Data: - data: bytes - def __init__(self, data: bytes) -> None: ... - -class InvalidFileException(ValueError): - def __init__(self, message: str = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/popen2.pyi b/mypy/typeshed/stdlib/@python2/popen2.pyi deleted file mode 100644 index 43f6804e0659..000000000000 --- a/mypy/typeshed/stdlib/@python2/popen2.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from typing import Any, Iterable, TextIO, TypeVar - -_T = TypeVar("_T") - -class Popen3: - sts: int - cmd: Iterable[Any] - pid: int - tochild: TextIO - fromchild: TextIO - childerr: TextIO | None - def __init__(self, cmd: Iterable[Any] = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ... - def __del__(self) -> None: ... - def poll(self, _deadstate: _T = ...) -> int | _T: ... - def wait(self) -> int: ... - -class Popen4(Popen3): - childerr: None - cmd: Iterable[Any] - pid: int - tochild: TextIO - fromchild: TextIO - def __init__(self, cmd: Iterable[Any] = ..., bufsize: int = ...) -> None: ... - -def popen2(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> tuple[TextIO, TextIO]: ... -def popen3(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> tuple[TextIO, TextIO, TextIO]: ... -def popen4(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> tuple[TextIO, TextIO]: ... diff --git a/mypy/typeshed/stdlib/@python2/poplib.pyi b/mypy/typeshed/stdlib/@python2/poplib.pyi deleted file mode 100644 index 4525cac1e687..000000000000 --- a/mypy/typeshed/stdlib/@python2/poplib.pyi +++ /dev/null @@ -1,45 +0,0 @@ -import socket -from typing import Any, BinaryIO, Pattern, Text, overload - -_LongResp = tuple[bytes, list[bytes], int] - -class error_proto(Exception): ... - -POP3_PORT: int -POP3_SSL_PORT: int -CR: bytes -LF: bytes -CRLF: bytes - -class POP3: - host: Text - port: int - sock: socket.socket - file: BinaryIO - welcome: bytes - def __init__(self, host: Text, port: int = ..., timeout: float = ...) -> None: ... - def getwelcome(self) -> bytes: ... - def set_debuglevel(self, level: int) -> None: ... - def user(self, user: Text) -> bytes: ... - def pass_(self, pswd: Text) -> bytes: ... - def stat(self) -> tuple[int, int]: ... - def list(self, which: Any | None = ...) -> _LongResp: ... - def retr(self, which: Any) -> _LongResp: ... - def dele(self, which: Any) -> bytes: ... - def noop(self) -> bytes: ... - def rset(self) -> bytes: ... - def quit(self) -> bytes: ... - def close(self) -> None: ... - def rpop(self, user: Text) -> bytes: ... - timestamp: Pattern[Text] - def apop(self, user: Text, secret: Text) -> bytes: ... - def top(self, which: Any, howmuch: int) -> _LongResp: ... - @overload - def uidl(self) -> _LongResp: ... - @overload - def uidl(self, which: Any) -> bytes: ... - -class POP3_SSL(POP3): - def __init__( - self, host: Text, port: int = ..., keyfile: Text | None = ..., certfile: Text | None = ..., timeout: float = ... - ) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/posix.pyi b/mypy/typeshed/stdlib/@python2/posix.pyi deleted file mode 100644 index 7ea9c0015ab0..000000000000 --- a/mypy/typeshed/stdlib/@python2/posix.pyi +++ /dev/null @@ -1,201 +0,0 @@ -from _typeshed import FileDescriptorLike -from typing import IO, AnyStr, Mapping, NamedTuple, Sequence, TypeVar - -error = OSError - -confstr_names: dict[str, int] -environ: dict[str, str] -pathconf_names: dict[str, int] -sysconf_names: dict[str, int] - -_T = TypeVar("_T") - -EX_CANTCREAT: int -EX_CONFIG: int -EX_DATAERR: int -EX_IOERR: int -EX_NOHOST: int -EX_NOINPUT: int -EX_NOPERM: int -EX_NOUSER: int -EX_OK: int -EX_OSERR: int -EX_OSFILE: int -EX_PROTOCOL: int -EX_SOFTWARE: int -EX_TEMPFAIL: int -EX_UNAVAILABLE: int -EX_USAGE: int -F_OK: int -NGROUPS_MAX: int -O_APPEND: int -O_ASYNC: int -O_CREAT: int -O_DIRECT: int -O_DIRECTORY: int -O_DSYNC: int -O_EXCL: int -O_LARGEFILE: int -O_NDELAY: int -O_NOATIME: int -O_NOCTTY: int -O_NOFOLLOW: int -O_NONBLOCK: int -O_RDONLY: int -O_RDWR: int -O_RSYNC: int -O_SYNC: int -O_TRUNC: int -O_WRONLY: int -R_OK: int -TMP_MAX: int -WCONTINUED: int -WNOHANG: int -WUNTRACED: int -W_OK: int -X_OK: int - -def WCOREDUMP(status: int) -> bool: ... -def WEXITSTATUS(status: int) -> bool: ... -def WIFCONTINUED(status: int) -> bool: ... -def WIFEXITED(status: int) -> bool: ... -def WIFSIGNALED(status: int) -> bool: ... -def WIFSTOPPED(status: int) -> bool: ... -def WSTOPSIG(status: int) -> bool: ... -def WTERMSIG(status: int) -> bool: ... - -class stat_result(object): - n_fields: int - n_sequence_fields: int - n_unnamed_fields: int - st_mode: int - st_ino: int - st_dev: int - st_nlink: int - st_uid: int - st_gid: int - st_size: int - st_atime: int - st_mtime: int - st_ctime: int - -class statvfs_result(NamedTuple): - f_bsize: int - f_frsize: int - f_blocks: int - f_bfree: int - f_bavail: int - f_files: int - f_ffree: int - f_favail: int - f_flag: int - f_namemax: int - -def _exit(status: int) -> None: ... -def abort() -> None: ... -def access(path: unicode, mode: int) -> bool: ... -def chdir(path: unicode) -> None: ... -def chmod(path: unicode, mode: int) -> None: ... -def chown(path: unicode, uid: int, gid: int) -> None: ... -def chroot(path: unicode) -> None: ... -def close(fd: int) -> None: ... -def closerange(fd_low: int, fd_high: int) -> None: ... -def confstr(name: str | int) -> str: ... -def ctermid() -> str: ... -def dup(fd: int) -> int: ... -def dup2(fd: int, fd2: int) -> None: ... -def execv(path: str, args: Sequence[str], env: Mapping[str, str]) -> None: ... -def execve(path: str, args: Sequence[str], env: Mapping[str, str]) -> None: ... -def fchdir(fd: FileDescriptorLike) -> None: ... -def fchmod(fd: int, mode: int) -> None: ... -def fchown(fd: int, uid: int, gid: int) -> None: ... -def fdatasync(fd: FileDescriptorLike) -> None: ... -def fdopen(fd: int, mode: str = ..., bufsize: int = ...) -> IO[str]: ... -def fork() -> int: ... -def forkpty() -> tuple[int, int]: ... -def fpathconf(fd: int, name: str) -> None: ... -def fstat(fd: int) -> stat_result: ... -def fstatvfs(fd: int) -> statvfs_result: ... -def fsync(fd: FileDescriptorLike) -> None: ... -def ftruncate(fd: int, length: int) -> None: ... -def getcwd() -> str: ... -def getcwdu() -> unicode: ... -def getegid() -> int: ... -def geteuid() -> int: ... -def getgid() -> int: ... -def getgroups() -> list[int]: ... -def getloadavg() -> tuple[float, float, float]: ... -def getlogin() -> str: ... -def getpgid(pid: int) -> int: ... -def getpgrp() -> int: ... -def getpid() -> int: ... -def getppid() -> int: ... -def getresgid() -> tuple[int, int, int]: ... -def getresuid() -> tuple[int, int, int]: ... -def getsid(pid: int) -> int: ... -def getuid() -> int: ... -def initgroups(username: str, gid: int) -> None: ... -def isatty(fd: int) -> bool: ... -def kill(pid: int, sig: int) -> None: ... -def killpg(pgid: int, sig: int) -> None: ... -def lchown(path: unicode, uid: int, gid: int) -> None: ... -def link(source: unicode, link_name: str) -> None: ... -def listdir(path: AnyStr) -> list[AnyStr]: ... -def lseek(fd: int, pos: int, how: int) -> None: ... -def lstat(path: unicode) -> stat_result: ... -def major(device: int) -> int: ... -def makedev(major: int, minor: int) -> int: ... -def minor(device: int) -> int: ... -def mkdir(path: unicode, mode: int = ...) -> None: ... -def mkfifo(path: unicode, mode: int = ...) -> None: ... -def mknod(filename: unicode, mode: int = ..., device: int = ...) -> None: ... -def nice(increment: int) -> int: ... -def open(file: unicode, flags: int, mode: int = ...) -> int: ... -def openpty() -> tuple[int, int]: ... -def pathconf(path: unicode, name: str) -> str: ... -def pipe() -> tuple[int, int]: ... -def popen(command: str, mode: str = ..., bufsize: int = ...) -> IO[str]: ... -def putenv(varname: str, value: str) -> None: ... -def read(fd: int, n: int) -> str: ... -def readlink(path: _T) -> _T: ... -def remove(path: unicode) -> None: ... -def rename(src: unicode, dst: unicode) -> None: ... -def rmdir(path: unicode) -> None: ... -def setegid(egid: int) -> None: ... -def seteuid(euid: int) -> None: ... -def setgid(gid: int) -> None: ... -def setgroups(groups: Sequence[int]) -> None: ... -def setpgid(pid: int, pgrp: int) -> None: ... -def setpgrp() -> None: ... -def setregid(rgid: int, egid: int) -> None: ... -def setresgid(rgid: int, egid: int, sgid: int) -> None: ... -def setresuid(ruid: int, euid: int, suid: int) -> None: ... -def setreuid(ruid: int, euid: int) -> None: ... -def setsid() -> None: ... -def setuid(pid: int) -> None: ... -def stat(path: unicode) -> stat_result: ... -def statvfs(path: unicode) -> statvfs_result: ... -def stat_float_times(fd: int) -> None: ... -def strerror(code: int) -> str: ... -def symlink(source: unicode, link_name: unicode) -> None: ... -def sysconf(name: str | int) -> int: ... -def system(command: unicode) -> int: ... -def tcgetpgrp(fd: int) -> int: ... -def tcsetpgrp(fd: int, pg: int) -> None: ... -def times() -> tuple[float, float, float, float, float]: ... -def tmpfile() -> IO[str]: ... -def ttyname(fd: int) -> str: ... -def umask(mask: int) -> int: ... -def uname() -> tuple[str, str, str, str, str]: ... -def unlink(path: unicode) -> None: ... -def unsetenv(varname: str) -> None: ... -def urandom(n: int) -> str: ... -def utime(path: unicode, times: tuple[int, int] | None) -> None: ... -def wait() -> int: ... - -_r = tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int] - -def wait3(options: int) -> tuple[int, int, _r]: ... -def wait4(pid: int, options: int) -> tuple[int, int, _r]: ... -def waitpid(pid: int, options: int) -> int: ... -def write(fd: int, str: str) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/posixpath.pyi b/mypy/typeshed/stdlib/@python2/posixpath.pyi deleted file mode 100644 index 33732903cb4c..000000000000 --- a/mypy/typeshed/stdlib/@python2/posixpath.pyi +++ /dev/null @@ -1,84 +0,0 @@ -import os -import sys -from genericpath import exists as exists -from typing import Any, AnyStr, Callable, Sequence, Text, TypeVar, overload - -_T = TypeVar("_T") - -# ----- os.path variables ----- -supports_unicode_filenames: bool -# aliases (also in os) -curdir: str -pardir: str -sep: str -if sys.platform == "win32": - altsep: str -else: - altsep: str | None -extsep: str -pathsep: str -defpath: str -devnull: str - -# ----- os.path function stubs ----- -def abspath(path: AnyStr) -> AnyStr: ... -def basename(p: AnyStr) -> AnyStr: ... -def dirname(p: AnyStr) -> AnyStr: ... -def expanduser(path: AnyStr) -> AnyStr: ... -def expandvars(path: AnyStr) -> AnyStr: ... -def normcase(s: AnyStr) -> AnyStr: ... -def normpath(path: AnyStr) -> AnyStr: ... - -if sys.platform == "win32": - def realpath(path: AnyStr) -> AnyStr: ... - -else: - def realpath(filename: AnyStr) -> AnyStr: ... - -# NOTE: Empty lists results in '' (str) regardless of contained type. -# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes -# So, fall back to Any -def commonprefix(m: Sequence[Text]) -> Any: ... -def lexists(path: Text) -> bool: ... - -# These return float if os.stat_float_times() == True, -# but int is a subclass of float. -def getatime(filename: Text) -> float: ... -def getmtime(filename: Text) -> float: ... -def getctime(filename: Text) -> float: ... -def getsize(filename: Text) -> int: ... -def isabs(s: Text) -> bool: ... -def isfile(path: Text) -> bool: ... -def isdir(s: Text) -> bool: ... -def islink(path: Text) -> bool: ... -def ismount(path: Text) -> bool: ... - -# Make sure signatures are disjunct, and allow combinations of bytes and unicode. -# (Since Python 2 allows that, too) -# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in -# a type error. -@overload -def join(__p1: bytes, *p: bytes) -> bytes: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... -@overload -def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... -@overload -def join(__p1: Text, *p: Text) -> Text: ... -@overload -def relpath(path: str, start: str | None = ...) -> str: ... -@overload -def relpath(path: Text, start: Text | None = ...) -> Text: ... -def samefile(f1: Text, f2: Text) -> bool: ... -def sameopenfile(fp1: int, fp2: int) -> bool: ... -def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... -def split(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitdrive(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def splitext(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... - -if sys.platform == "win32": - def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated - -def walk(path: AnyStr, visit: Callable[[_T, AnyStr, list[AnyStr]], Any], arg: _T) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/pprint.pyi b/mypy/typeshed/stdlib/@python2/pprint.pyi deleted file mode 100644 index e22c4464eb4d..000000000000 --- a/mypy/typeshed/stdlib/@python2/pprint.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from typing import IO, Any - -def pformat(object: object, indent: int = ..., width: int = ..., depth: int | None = ...) -> str: ... -def pprint( - object: object, stream: IO[str] | None = ..., indent: int = ..., width: int = ..., depth: int | None = ... -) -> None: ... -def isreadable(object: object) -> bool: ... -def isrecursive(object: object) -> bool: ... -def saferepr(object: object) -> str: ... - -class PrettyPrinter: - def __init__(self, indent: int = ..., width: int = ..., depth: int | None = ..., stream: IO[str] | None = ...) -> None: ... - def pformat(self, object: object) -> str: ... - def pprint(self, object: object) -> None: ... - def isreadable(self, object: object) -> bool: ... - def isrecursive(self, object: object) -> bool: ... - def format(self, object: object, context: dict[int, Any], maxlevels: int, level: int) -> tuple[str, bool, bool]: ... diff --git a/mypy/typeshed/stdlib/@python2/profile.pyi b/mypy/typeshed/stdlib/@python2/profile.pyi deleted file mode 100644 index d9884038e0e0..000000000000 --- a/mypy/typeshed/stdlib/@python2/profile.pyi +++ /dev/null @@ -1,28 +0,0 @@ -from _typeshed import Self -from typing import Any, Callable, Text, TypeVar -from typing_extensions import ParamSpec - -def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... -def runctx( - statement: str, globals: dict[str, Any], locals: dict[str, Any], filename: str | None = ..., sort: str | int = ... -) -> None: ... - -_T = TypeVar("_T") -_P = ParamSpec("_P") -_Label = tuple[str, int, str] - -class Profile: - bias: int - stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented - def __init__(self, timer: Callable[[], float] | None = ..., bias: int | None = ...) -> None: ... - def set_cmd(self, cmd: str) -> None: ... - def simulate_call(self, name: str) -> None: ... - def simulate_cmd_complete(self) -> None: ... - def print_stats(self, sort: str | int = ...) -> None: ... - def dump_stats(self, file: Text) -> None: ... - def create_stats(self) -> None: ... - def snapshot_stats(self) -> None: ... - def run(self: Self, cmd: str) -> Self: ... - def runctx(self: Self, cmd: str, globals: dict[str, Any], locals: dict[str, Any]) -> Self: ... - def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... - def calibrate(self, m: int, verbose: int = ...) -> float: ... diff --git a/mypy/typeshed/stdlib/@python2/pstats.pyi b/mypy/typeshed/stdlib/@python2/pstats.pyi deleted file mode 100644 index 6b956764efa9..000000000000 --- a/mypy/typeshed/stdlib/@python2/pstats.pyi +++ /dev/null @@ -1,38 +0,0 @@ -from _typeshed import Self -from cProfile import Profile as _cProfile -from profile import Profile -from typing import IO, Any, Iterable, Text, TypeVar, overload - -_Selector = str | float | int -_T = TypeVar("_T", bound=Stats) - -class Stats: - sort_arg_dict_default: dict[str, tuple[Any, str]] - def __init__( - self: _T, - __arg: None | str | Text | Profile | _cProfile = ..., - *args: None | str | Text | Profile | _cProfile | _T, - stream: IO[Any] | None = ..., - ) -> None: ... - def init(self, arg: None | str | Text | Profile | _cProfile) -> None: ... - def load_stats(self, arg: None | str | Text | Profile | _cProfile) -> None: ... - def get_top_level_stats(self) -> None: ... - def add(self: Self, *arg_list: None | str | Text | Profile | _cProfile | Self) -> Self: ... - def dump_stats(self, filename: Text) -> None: ... - def get_sort_arg_defs(self) -> dict[str, tuple[tuple[tuple[int, int], ...], str]]: ... - @overload - def sort_stats(self: Self, field: int) -> Self: ... - @overload - def sort_stats(self: Self, *field: str) -> Self: ... - def reverse_order(self: Self) -> Self: ... - def strip_dirs(self: Self) -> Self: ... - def calc_callees(self) -> None: ... - def eval_print_amount(self, sel: _Selector, list: list[str], msg: str) -> tuple[list[str], str]: ... - def get_print_list(self, sel_list: Iterable[_Selector]) -> tuple[int, list[str]]: ... - def print_stats(self: Self, *amount: _Selector) -> Self: ... - def print_callees(self: Self, *amount: _Selector) -> Self: ... - def print_callers(self: Self, *amount: _Selector) -> Self: ... - def print_call_heading(self, name_size: int, column_title: str) -> None: ... - def print_call_line(self, name_size: int, source: str, call_dict: dict[str, Any], arrow: str = ...) -> None: ... - def print_title(self) -> None: ... - def print_line(self, func: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/pty.pyi b/mypy/typeshed/stdlib/@python2/pty.pyi deleted file mode 100644 index 2c90faf18aa3..000000000000 --- a/mypy/typeshed/stdlib/@python2/pty.pyi +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from typing import Callable, Iterable - -if sys.platform != "win32": - _Reader = Callable[[int], bytes] - - STDIN_FILENO: int - STDOUT_FILENO: int - STDERR_FILENO: int - - CHILD: int - def openpty() -> tuple[int, int]: ... - def master_open() -> tuple[int, str]: ... - def slave_open(tty_name: str) -> int: ... - def fork() -> tuple[int, int]: ... - def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/pwd.pyi b/mypy/typeshed/stdlib/@python2/pwd.pyi deleted file mode 100644 index e64cbf6a1ac3..000000000000 --- a/mypy/typeshed/stdlib/@python2/pwd.pyi +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -if sys.platform != "win32": - class struct_passwd(tuple[str, str, int, int, str, str, str]): - pw_name: str - pw_passwd: str - pw_uid: int - pw_gid: int - pw_gecos: str - pw_dir: str - pw_shell: str - def getpwall() -> list[struct_passwd]: ... - def getpwuid(__uid: int) -> struct_passwd: ... - def getpwnam(__name: str) -> struct_passwd: ... diff --git a/mypy/typeshed/stdlib/@python2/py_compile.pyi b/mypy/typeshed/stdlib/@python2/py_compile.pyi deleted file mode 100644 index ccd05029fe0e..000000000000 --- a/mypy/typeshed/stdlib/@python2/py_compile.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Text - -_EitherStr = bytes | Text - -class PyCompileError(Exception): - exc_type_name: str - exc_value: BaseException - file: str - msg: str - def __init__(self, exc_type: type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... - -def compile(file: _EitherStr, cfile: _EitherStr | None = ..., dfile: _EitherStr | None = ..., doraise: bool = ...) -> None: ... -def main(args: list[Text] | None = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/pyclbr.pyi b/mypy/typeshed/stdlib/@python2/pyclbr.pyi deleted file mode 100644 index 317e934694c5..000000000000 --- a/mypy/typeshed/stdlib/@python2/pyclbr.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from typing import Sequence - -class Class: - module: str - name: str - super: list[Class | str] | None - methods: dict[str, int] - file: int - lineno: int - def __init__(self, module: str, name: str, super: list[Class | str] | None, file: str, lineno: int) -> None: ... - -class Function: - module: str - name: str - file: int - lineno: int - def __init__(self, module: str, name: str, file: str, lineno: int) -> None: ... - -def readmodule(module: str, path: Sequence[str] | None = ...) -> dict[str, Class]: ... -def readmodule_ex(module: str, path: Sequence[str] | None = ...) -> dict[str, Class | Function | list[str]]: ... diff --git a/mypy/typeshed/stdlib/@python2/pydoc.pyi b/mypy/typeshed/stdlib/@python2/pydoc.pyi deleted file mode 100644 index a43b7333c7b0..000000000000 --- a/mypy/typeshed/stdlib/@python2/pydoc.pyi +++ /dev/null @@ -1,243 +0,0 @@ -from _typeshed import SupportsWrite -from types import MethodType, ModuleType, TracebackType -from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional, Text - -from repr import Repr - -# the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]] - -__author__: str -__date__: str -__version__: str -__credits__: str - -def pathdirs() -> list[str]: ... -def getdoc(object: object) -> Text: ... -def splitdoc(doc: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def classname(object: object, modname: str) -> str: ... -def isdata(object: object) -> bool: ... -def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ... -def cram(text: str, maxlen: int) -> str: ... -def stripid(text: str) -> str: ... -def allmethods(cl: type) -> MutableMapping[str, MethodType]: ... -def visiblename(name: str, all: Container[str] | None = ..., obj: object | None = ...) -> bool: ... -def classify_class_attrs(object: object) -> list[tuple[str, str, type, str]]: ... -def ispackage(path: str) -> bool: ... -def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ... -def synopsis(filename: str, cache: MutableMapping[str, tuple[int, str]] = ...) -> str | None: ... - -class ErrorDuringImport(Exception): - filename: str - exc: type[BaseException] | None - value: BaseException | None - tb: TracebackType | None - def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... - -def importfile(path: str) -> ModuleType: ... -def safeimport(path: str, forceload: bool = ..., cache: MutableMapping[str, ModuleType] = ...) -> ModuleType: ... - -class Doc: - PYTHONDOCS: str - def document(self, object: object, name: str | None = ..., *args: Any) -> str: ... - def fail(self, object: object, name: str | None = ..., *args: Any) -> NoReturn: ... - def docmodule(self, object: object, name: str | None = ..., *args: Any) -> str: ... - def docclass(self, object: object, name: str | None = ..., *args: Any) -> str: ... - def docroutine(self, object: object, name: str | None = ..., *args: Any) -> str: ... - def docother(self, object: object, name: str | None = ..., *args: Any) -> str: ... - def docproperty(self, object: object, name: str | None = ..., *args: Any) -> str: ... - def docdata(self, object: object, name: str | None = ..., *args: Any) -> str: ... - def getdocloc(self, object: object, basedir: str = ...) -> str | None: ... - -class HTMLRepr(Repr): - maxlist: int - maxtuple: int - maxdict: int - maxstring: int - maxother: int - def __init__(self) -> None: ... - def escape(self, text: str) -> str: ... - def repr(self, object: object) -> str: ... - def repr1(self, x: object, level: complex) -> str: ... - def repr_string(self, x: Text, level: complex) -> str: ... - def repr_str(self, x: Text, level: complex) -> str: ... - def repr_instance(self, x: object, level: complex) -> str: ... - def repr_unicode(self, x: AnyStr, level: complex) -> str: ... - -class HTMLDoc(Doc): - repr: Callable[[object], str] - escape: Callable[[str], str] - def page(self, title: str, contents: str) -> str: ... - def heading(self, title: str, fgcol: str, bgcol: str, extras: str = ...) -> str: ... - def section( - self, - title: str, - fgcol: str, - bgcol: str, - contents: str, - width: int = ..., - prelude: str = ..., - marginalia: str | None = ..., - gap: str = ..., - ) -> 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: ... - def namelink(self, name: str, *dicts: MutableMapping[str, str]) -> str: ... - def classlink(self, object: object, modname: str) -> str: ... - def modulelink(self, object: object) -> str: ... - def modpkglink(self, modpkginfo: tuple[str, str, bool, bool]) -> str: ... - def markup( - self, - text: str, - escape: Callable[[str], str] | None = ..., - funcs: Mapping[str, str] = ..., - classes: Mapping[str, str] = ..., - methods: Mapping[str, str] = ..., - ) -> str: ... - def formattree( - self, tree: list[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ... - ) -> str: ... - def docmodule(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... - def docclass( - self, - object: object, - name: str | None = ..., - mod: str | None = ..., - funcs: Mapping[str, str] = ..., - classes: Mapping[str, str] = ..., - *ignored: Any, - ) -> str: ... - def formatvalue(self, object: object) -> str: ... - def docroutine( - self, - object: object, - name: str | None = ..., - mod: str | None = ..., - funcs: Mapping[str, str] = ..., - classes: Mapping[str, str] = ..., - methods: Mapping[str, str] = ..., - cl: type | None = ..., - *ignored: Any, - ) -> str: ... - def docproperty( - self, object: object, name: str | None = ..., mod: str | None = ..., cl: Any | None = ..., *ignored: Any - ) -> str: ... - def docother(self, object: object, name: str | None = ..., mod: Any | None = ..., *ignored: Any) -> str: ... - def docdata( - self, object: object, name: str | None = ..., mod: Any | None = ..., cl: Any | None = ..., *ignored: Any - ) -> str: ... - def index(self, dir: str, shadowed: MutableMapping[str, bool] | None = ...) -> str: ... - def filelink(self, url: str, path: str) -> str: ... - -class TextRepr(Repr): - maxlist: int - maxtuple: int - maxdict: int - maxstring: int - maxother: int - def __init__(self) -> None: ... - def repr1(self, x: object, level: complex) -> str: ... - def repr_string(self, x: str, level: complex) -> str: ... - def repr_str(self, x: str, level: complex) -> str: ... - def repr_instance(self, x: object, level: complex) -> str: ... - -class TextDoc(Doc): - repr: Callable[[object], str] - 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[tuple[type, tuple[type, ...]] | list[Any]], modname: str, parent: type | None = ..., prefix: str = ... - ) -> str: ... - def docmodule(self, object: object, name: str | None = ..., mod: Any | None = ..., *ignored: Any) -> str: ... - def docclass(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... - def formatvalue(self, object: object) -> str: ... - def docroutine( - self, object: object, name: str | None = ..., mod: str | None = ..., cl: Any | None = ..., *ignored: Any - ) -> str: ... - def docproperty( - self, object: object, name: str | None = ..., mod: Any | None = ..., cl: Any | None = ..., *ignored: Any - ) -> str: ... - def docdata( - self, object: object, name: str | None = ..., mod: str | None = ..., cl: Any | None = ..., *ignored: Any - ) -> str: ... - def docother( - self, - object: object, - name: str | None = ..., - mod: str | None = ..., - parent: str | None = ..., - maxlen: int | None = ..., - doc: Any | None = ..., - *ignored: Any, - ) -> str: ... - -def pager(text: str) -> None: ... -def getpager() -> Callable[[str], None]: ... -def plain(text: str) -> str: ... -def pipepager(text: str, cmd: str) -> None: ... -def tempfilepager(text: str, cmd: str) -> None: ... -def ttypager(text: str) -> None: ... -def plainpager(text: str) -> None: ... -def describe(thing: Any) -> str: ... -def locate(path: str, forceload: bool = ...) -> object: ... - -text: TextDoc -html: HTMLDoc - -class _OldStyleClass: ... - -def resolve(thing: str | object, forceload: bool = ...) -> tuple[object, str] | None: ... -def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Doc | None = ...) -> str: ... -def doc(thing: str | object, title: str = ..., forceload: bool = ..., output: SupportsWrite[str] | None = ...) -> None: ... -def writedoc(thing: str | object, forceload: bool = ...) -> None: ... -def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... - -class Helper: - keywords: dict[str, str | tuple[str, str]] - symbols: dict[str, str] - topics: dict[str, str | tuple[str, ...]] - def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... - input: IO[str] - output: IO[str] - def __call__(self, request: str | Helper | object = ...) -> None: ... - def interact(self) -> None: ... - def getline(self, prompt: str) -> str: ... - def help(self, request: Any) -> None: ... - def intro(self) -> None: ... - def list(self, items: list[str], columns: int = ..., width: int = ...) -> None: ... - def listkeywords(self) -> None: ... - def listsymbols(self) -> None: ... - def listtopics(self) -> None: ... - def showtopic(self, topic: str, more_xrefs: str = ...) -> None: ... - def showsymbol(self, symbol: str) -> None: ... - def listmodules(self, key: str = ...) -> None: ... - -help: Helper - -# See Python issue #11182: "remove the unused and undocumented pydoc.Scanner class" -# class Scanner: -# roots = ... # type: Any -# state = ... # type: Any -# children = ... # type: Any -# descendp = ... # type: Any -# def __init__(self, roots, children, descendp) -> None: ... -# def next(self): ... - -class ModuleScanner: - quit: bool - def run( - self, - callback: Callable[[str | None, str, str], None], - key: Any | None = ..., - completer: Callable[[], None] | None = ..., - onerror: Callable[[str], None] | None = ..., - ) -> None: ... - -def apropos(key: str) -> None: ... -def ispath(x: Any) -> bool: ... -def cli() -> None: ... -def serve(port: int, callback: Callable[[Any], None] | None = ..., completer: Callable[[], None] | None = ...) -> None: ... -def gui() -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/pydoc_data/__init__.pyi b/mypy/typeshed/stdlib/@python2/pydoc_data/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/pydoc_data/topics.pyi b/mypy/typeshed/stdlib/@python2/pydoc_data/topics.pyi deleted file mode 100644 index 091d34300106..000000000000 --- a/mypy/typeshed/stdlib/@python2/pydoc_data/topics.pyi +++ /dev/null @@ -1 +0,0 @@ -topics: dict[str, str] diff --git a/mypy/typeshed/stdlib/@python2/pyexpat/__init__.pyi b/mypy/typeshed/stdlib/@python2/pyexpat/__init__.pyi deleted file mode 100644 index 5c58a0a1fe73..000000000000 --- a/mypy/typeshed/stdlib/@python2/pyexpat/__init__.pyi +++ /dev/null @@ -1,75 +0,0 @@ -import pyexpat.errors as errors -import pyexpat.model as model -from _typeshed import SupportsRead -from typing import Any, Callable, Text - -EXPAT_VERSION: str # undocumented -version_info: tuple[int, int, int] # undocumented -native_encoding: str # undocumented -features: list[tuple[str, int]] # undocumented - -class ExpatError(Exception): - code: int - lineno: int - offset: int - -error = ExpatError - -XML_PARAM_ENTITY_PARSING_NEVER: int -XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int -XML_PARAM_ENTITY_PARSING_ALWAYS: int - -_Model = tuple[int, int, str | None, tuple[Any, ...]] - -class XMLParserType(object): - def Parse(self, __data: Text | bytes, __isfinal: bool = ...) -> int: ... - def ParseFile(self, __file: SupportsRead[bytes]) -> int: ... - def SetBase(self, __base: Text) -> None: ... - def GetBase(self) -> str | None: ... - def GetInputContext(self) -> bytes | None: ... - def ExternalEntityParserCreate(self, __context: Text | None, __encoding: Text = ...) -> XMLParserType: ... - def SetParamEntityParsing(self, __flag: int) -> int: ... - def UseForeignDTD(self, __flag: bool = ...) -> None: ... - buffer_size: int - buffer_text: bool - buffer_used: int - namespace_prefixes: bool # undocumented - ordered_attributes: bool - specified_attributes: bool - ErrorByteIndex: int - ErrorCode: int - ErrorColumnNumber: int - ErrorLineNumber: int - CurrentByteIndex: int - CurrentColumnNumber: int - CurrentLineNumber: int - XmlDeclHandler: Callable[[str, str | None, int], Any] | None - StartDoctypeDeclHandler: Callable[[str, str | None, str | None, bool], Any] | None - EndDoctypeDeclHandler: Callable[[], Any] | None - ElementDeclHandler: Callable[[str, _Model], Any] | None - AttlistDeclHandler: Callable[[str, str, str, str | None, bool], Any] | None - StartElementHandler: Callable[[str, dict[str, str]], Any] | Callable[[str, list[str]], Any] | Callable[ - [str, dict[str, str], list[str]], Any - ] | None - EndElementHandler: Callable[[str], Any] | None - ProcessingInstructionHandler: Callable[[str, str], Any] | None - CharacterDataHandler: Callable[[str], Any] | None - UnparsedEntityDeclHandler: Callable[[str, str | None, str, str | None, str], Any] | None - EntityDeclHandler: Callable[[str, bool, str | None, str | None, str, str | None, str | None], Any] | None - NotationDeclHandler: Callable[[str, str | None, str, str | None], Any] | None - StartNamespaceDeclHandler: Callable[[str, str], Any] | None - EndNamespaceDeclHandler: Callable[[str], Any] | None - CommentHandler: Callable[[str], Any] | None - StartCdataSectionHandler: Callable[[], Any] | None - EndCdataSectionHandler: Callable[[], Any] | None - DefaultHandler: Callable[[str], Any] | None - DefaultHandlerExpand: Callable[[str], Any] | None - NotStandaloneHandler: Callable[[], int] | None - ExternalEntityRefHandler: Callable[[str, str | None, str | None, str | None], int] | None - -def ErrorString(__code: int) -> str: ... - -# intern is undocumented -def ParserCreate( - encoding: Text | None = ..., namespace_separator: Text | None = ..., intern: dict[str, Any] | None = ... -) -> XMLParserType: ... diff --git a/mypy/typeshed/stdlib/@python2/pyexpat/errors.pyi b/mypy/typeshed/stdlib/@python2/pyexpat/errors.pyi deleted file mode 100644 index 498030fd695f..000000000000 --- a/mypy/typeshed/stdlib/@python2/pyexpat/errors.pyi +++ /dev/null @@ -1,37 +0,0 @@ -XML_ERROR_ABORTED: str -XML_ERROR_ASYNC_ENTITY: str -XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: str -XML_ERROR_BAD_CHAR_REF: str -XML_ERROR_BINARY_ENTITY_REF: str -XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING: str -XML_ERROR_DUPLICATE_ATTRIBUTE: str -XML_ERROR_ENTITY_DECLARED_IN_PE: str -XML_ERROR_EXTERNAL_ENTITY_HANDLING: str -XML_ERROR_FEATURE_REQUIRES_XML_DTD: str -XML_ERROR_FINISHED: str -XML_ERROR_INCOMPLETE_PE: str -XML_ERROR_INCORRECT_ENCODING: str -XML_ERROR_INVALID_TOKEN: str -XML_ERROR_JUNK_AFTER_DOC_ELEMENT: str -XML_ERROR_MISPLACED_XML_PI: str -XML_ERROR_NOT_STANDALONE: str -XML_ERROR_NOT_SUSPENDED: str -XML_ERROR_NO_ELEMENTS: str -XML_ERROR_NO_MEMORY: str -XML_ERROR_PARAM_ENTITY_REF: str -XML_ERROR_PARTIAL_CHAR: str -XML_ERROR_PUBLICID: str -XML_ERROR_RECURSIVE_ENTITY_REF: str -XML_ERROR_SUSPENDED: str -XML_ERROR_SUSPEND_PE: str -XML_ERROR_SYNTAX: str -XML_ERROR_TAG_MISMATCH: str -XML_ERROR_TEXT_DECL: str -XML_ERROR_UNBOUND_PREFIX: str -XML_ERROR_UNCLOSED_CDATA_SECTION: str -XML_ERROR_UNCLOSED_TOKEN: str -XML_ERROR_UNDECLARING_PREFIX: str -XML_ERROR_UNDEFINED_ENTITY: str -XML_ERROR_UNEXPECTED_STATE: str -XML_ERROR_UNKNOWN_ENCODING: str -XML_ERROR_XML_DECL: str diff --git a/mypy/typeshed/stdlib/@python2/pyexpat/model.pyi b/mypy/typeshed/stdlib/@python2/pyexpat/model.pyi deleted file mode 100644 index f357cf6511a2..000000000000 --- a/mypy/typeshed/stdlib/@python2/pyexpat/model.pyi +++ /dev/null @@ -1,11 +0,0 @@ -XML_CTYPE_ANY: int -XML_CTYPE_CHOICE: int -XML_CTYPE_EMPTY: int -XML_CTYPE_MIXED: int -XML_CTYPE_NAME: int -XML_CTYPE_SEQ: int - -XML_CQUANT_NONE: int -XML_CQUANT_OPT: int -XML_CQUANT_PLUS: int -XML_CQUANT_REP: int diff --git a/mypy/typeshed/stdlib/@python2/quopri.pyi b/mypy/typeshed/stdlib/@python2/quopri.pyi deleted file mode 100644 index c2ffabe7d531..000000000000 --- a/mypy/typeshed/stdlib/@python2/quopri.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import BinaryIO - -def encode(input: BinaryIO, output: BinaryIO, quotetabs: int, header: int = ...) -> None: ... -def encodestring(s: bytes, quotetabs: int = ..., header: int = ...) -> bytes: ... -def decode(input: BinaryIO, output: BinaryIO, header: int = ...) -> None: ... -def decodestring(s: bytes, header: int = ...) -> bytes: ... diff --git a/mypy/typeshed/stdlib/@python2/random.pyi b/mypy/typeshed/stdlib/@python2/random.pyi deleted file mode 100644 index df279a03c24a..000000000000 --- a/mypy/typeshed/stdlib/@python2/random.pyi +++ /dev/null @@ -1,67 +0,0 @@ -import _random -from typing import Any, Callable, Iterator, MutableSequence, Protocol, Sequence, TypeVar, overload - -_T = TypeVar("_T") -_T_co = TypeVar("_T_co", covariant=True) - -class _Sampleable(Protocol[_T_co]): - def __iter__(self) -> Iterator[_T_co]: ... - def __len__(self) -> int: ... - -class Random(_random.Random): - def __init__(self, x: object = ...) -> None: ... - def seed(self, x: object = ...) -> None: ... - def getstate(self) -> _random._State: ... - def setstate(self, state: _random._State) -> None: ... - def jumpahead(self, n: int) -> None: ... - def getrandbits(self, k: int) -> int: ... - @overload - def randrange(self, stop: int) -> int: ... - @overload - def randrange(self, start: int, stop: int, step: int = ...) -> int: ... - def randint(self, a: int, b: int) -> int: ... - def choice(self, seq: Sequence[_T]) -> _T: ... - def shuffle(self, x: MutableSequence[Any], random: Callable[[], None] = ...) -> None: ... - def sample(self, population: _Sampleable[_T], k: int) -> list[_T]: ... - def random(self) -> float: ... - def uniform(self, a: float, b: float) -> float: ... - def triangular(self, low: float = ..., high: float = ..., mode: float = ...) -> float: ... - def betavariate(self, alpha: float, beta: float) -> float: ... - def expovariate(self, lambd: float) -> float: ... - def gammavariate(self, alpha: float, beta: float) -> float: ... - def gauss(self, mu: float, sigma: float) -> float: ... - def lognormvariate(self, mu: float, sigma: float) -> float: ... - def normalvariate(self, mu: float, sigma: float) -> float: ... - def vonmisesvariate(self, mu: float, kappa: float) -> float: ... - def paretovariate(self, alpha: float) -> float: ... - def weibullvariate(self, alpha: float, beta: float) -> float: ... - -# SystemRandom is not implemented for all OS's; good on Windows & Linux -class SystemRandom(Random): ... - -# ----- random function stubs ----- -def seed(x: object = ...) -> None: ... -def getstate() -> object: ... -def setstate(state: object) -> None: ... -def jumpahead(n: int) -> None: ... -def getrandbits(k: int) -> int: ... -@overload -def randrange(stop: int) -> int: ... -@overload -def randrange(start: int, stop: int, step: int = ...) -> int: ... -def randint(a: int, b: int) -> int: ... -def choice(seq: Sequence[_T]) -> _T: ... -def shuffle(x: MutableSequence[Any], random: Callable[[], float] = ...) -> None: ... -def sample(population: _Sampleable[_T], k: int) -> list[_T]: ... -def random() -> float: ... -def uniform(a: float, b: float) -> float: ... -def triangular(low: float = ..., high: float = ..., mode: float = ...) -> float: ... -def betavariate(alpha: float, beta: float) -> float: ... -def expovariate(lambd: float) -> float: ... -def gammavariate(alpha: float, beta: float) -> float: ... -def gauss(mu: float, sigma: float) -> float: ... -def lognormvariate(mu: float, sigma: float) -> float: ... -def normalvariate(mu: float, sigma: float) -> float: ... -def vonmisesvariate(mu: float, kappa: float) -> float: ... -def paretovariate(alpha: float) -> float: ... -def weibullvariate(alpha: float, beta: float) -> float: ... diff --git a/mypy/typeshed/stdlib/@python2/re.pyi b/mypy/typeshed/stdlib/@python2/re.pyi deleted file mode 100644 index ba555968ad4b..000000000000 --- a/mypy/typeshed/stdlib/@python2/re.pyi +++ /dev/null @@ -1,87 +0,0 @@ -from typing import Any, AnyStr, Callable, Iterator, Match, Pattern, overload - -# ----- re variables and constants ----- -DEBUG: int -I: int -IGNORECASE: int -L: int -LOCALE: int -M: int -MULTILINE: int -S: int -DOTALL: int -X: int -VERBOSE: int -U: int -UNICODE: int -T: int -TEMPLATE: int - -class error(Exception): ... - -@overload -def compile(pattern: AnyStr, flags: int = ...) -> Pattern[AnyStr]: ... -@overload -def compile(pattern: Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... -@overload -def search(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... -@overload -def search(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... -@overload -def match(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... -@overload -def match(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... -@overload -def split(pattern: str | unicode, string: AnyStr, maxsplit: int = ..., flags: int = ...) -> list[AnyStr]: ... -@overload -def split(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, maxsplit: int = ..., flags: int = ...) -> list[AnyStr]: ... -@overload -def findall(pattern: str | unicode, string: AnyStr, flags: int = ...) -> list[Any]: ... -@overload -def findall(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> list[Any]: ... - -# Return an iterator yielding match objects over all non-overlapping matches -# for the RE pattern in string. The string is scanned left-to-right, and -# matches are returned in the order found. Empty matches are included in the -# result unless they touch the beginning of another match. -@overload -def finditer(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... -@overload -def finditer(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... -@overload -def sub(pattern: str | unicode, repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... -@overload -def sub( - pattern: str | unicode, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... -) -> AnyStr: ... -@overload -def sub(pattern: Pattern[str] | Pattern[unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... -@overload -def sub( - pattern: Pattern[str] | Pattern[unicode], - repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, - count: int = ..., - flags: int = ..., -) -> AnyStr: ... -@overload -def subn(pattern: str | unicode, repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> tuple[AnyStr, int]: ... -@overload -def subn( - pattern: str | unicode, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... -) -> tuple[AnyStr, int]: ... -@overload -def subn( - pattern: Pattern[str] | Pattern[unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... -) -> tuple[AnyStr, int]: ... -@overload -def subn( - pattern: Pattern[str] | Pattern[unicode], - repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, - count: int = ..., - flags: int = ..., -) -> tuple[AnyStr, int]: ... -def escape(string: AnyStr) -> AnyStr: ... -def purge() -> None: ... -def template(pattern: AnyStr | Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... diff --git a/mypy/typeshed/stdlib/@python2/readline.pyi b/mypy/typeshed/stdlib/@python2/readline.pyi deleted file mode 100644 index af642410b007..000000000000 --- a/mypy/typeshed/stdlib/@python2/readline.pyi +++ /dev/null @@ -1,31 +0,0 @@ -import sys -from typing import Callable, Optional, Sequence, Text - -if sys.platform != "win32": - _CompleterT = Optional[Callable[[str, int], str | None]] - _CompDispT = Callable[[str, Sequence[str], int], None] | None - def parse_and_bind(__string: str) -> None: ... - def read_init_file(__filename: Text | None = ...) -> None: ... - def get_line_buffer() -> str: ... - def insert_text(__string: str) -> None: ... - def redisplay() -> None: ... - def read_history_file(__filename: Text | None = ...) -> None: ... - def write_history_file(__filename: Text | None = ...) -> None: ... - def get_history_length() -> int: ... - def set_history_length(__length: int) -> None: ... - def clear_history() -> None: ... - def get_current_history_length() -> int: ... - def get_history_item(__index: int) -> str: ... - def remove_history_item(__pos: int) -> None: ... - def replace_history_item(__pos: int, __line: str) -> None: ... - def add_history(__string: str) -> None: ... - def set_startup_hook(__function: Callable[[], None] | None = ...) -> None: ... - def set_pre_input_hook(__function: Callable[[], None] | None = ...) -> None: ... - def set_completer(__function: _CompleterT = ...) -> None: ... - def get_completer() -> _CompleterT: ... - def get_completion_type() -> int: ... - def get_begidx() -> int: ... - def get_endidx() -> int: ... - def set_completer_delims(__string: str) -> None: ... - def get_completer_delims() -> str: ... - def set_completion_display_matches_hook(__function: _CompDispT = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/repr.pyi b/mypy/typeshed/stdlib/@python2/repr.pyi deleted file mode 100644 index 6b6f5ea9325e..000000000000 --- a/mypy/typeshed/stdlib/@python2/repr.pyi +++ /dev/null @@ -1,34 +0,0 @@ -from typing import Any - -class Repr: - maxarray: int - maxdeque: int - maxdict: int - maxfrozenset: int - maxlevel: int - maxlist: int - maxlong: int - maxother: int - maxset: int - maxstring: int - maxtuple: int - def __init__(self) -> None: ... - def _repr_iterable(self, x, level: complex, left, right, maxiter, trail=...) -> str: ... - def repr(self, x) -> str: ... - def repr1(self, x, level: complex) -> str: ... - def repr_array(self, x, level: complex) -> str: ... - def repr_deque(self, x, level: complex) -> str: ... - def repr_dict(self, x, level: complex) -> str: ... - def repr_frozenset(self, x, level: complex) -> str: ... - def repr_instance(self, x, level: complex) -> str: ... - def repr_list(self, x, level: complex) -> str: ... - def repr_long(self, x, level: complex) -> str: ... - def repr_set(self, x, level: complex) -> str: ... - def repr_str(self, x, level: complex) -> str: ... - def repr_tuple(self, x, level: complex) -> str: ... - -def _possibly_sorted(x) -> list[Any]: ... - -aRepr: Repr - -def repr(x) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/resource.pyi b/mypy/typeshed/stdlib/@python2/resource.pyi deleted file mode 100644 index 8deec4f67f51..000000000000 --- a/mypy/typeshed/stdlib/@python2/resource.pyi +++ /dev/null @@ -1,43 +0,0 @@ -import sys -from typing import NamedTuple - -if sys.platform != "win32": - class error(Exception): ... - RLIM_INFINITY: int - def getrlimit(resource: int) -> tuple[int, int]: ... - def setrlimit(resource: int, limits: tuple[int, int]) -> None: ... - RLIMIT_CORE: int - RLIMIT_CPU: int - RLIMIT_FSIZE: int - RLIMIT_DATA: int - RLIMIT_STACK: int - RLIMIT_RSS: int - RLIMIT_NPROC: int - RLIMIT_NOFILE: int - RLIMIT_OFILE: int - RLIMIT_MEMLOCK: int - RLIMIT_VMEM: int - RLIMIT_AS: int - - class _RUsage(NamedTuple): - ru_utime: float - ru_stime: float - ru_maxrss: int - ru_ixrss: int - ru_idrss: int - ru_isrss: int - ru_minflt: int - ru_majflt: int - ru_nswap: int - ru_inblock: int - ru_oublock: int - ru_msgsnd: int - ru_msgrcv: int - ru_nsignals: int - ru_nvcsw: int - ru_nivcsw: int - def getrusage(who: int) -> _RUsage: ... - def getpagesize() -> int: ... - RUSAGE_SELF: int - RUSAGE_CHILDREN: int - RUSAGE_BOTH: int diff --git a/mypy/typeshed/stdlib/@python2/rfc822.pyi b/mypy/typeshed/stdlib/@python2/rfc822.pyi deleted file mode 100644 index d6ae0031ffdf..000000000000 --- a/mypy/typeshed/stdlib/@python2/rfc822.pyi +++ /dev/null @@ -1,75 +0,0 @@ -from typing import Any - -class Message: - fp: Any - seekable: Any - startofheaders: Any - startofbody: Any - def __init__(self, fp, seekable: int = ...): ... - def rewindbody(self): ... - dict: Any - unixfrom: Any - headers: Any - status: Any - def readheaders(self): ... - def isheader(self, line): ... - def islast(self, line): ... - def iscomment(self, line): ... - def getallmatchingheaders(self, name): ... - def getfirstmatchingheader(self, name): ... - def getrawheader(self, name): ... - def getheader(self, name, default: Any | None = ...): ... - get: Any - def getheaders(self, name): ... - def getaddr(self, name): ... - def getaddrlist(self, name): ... - def getdate(self, name): ... - def getdate_tz(self, name): ... - def __len__(self): ... - def __getitem__(self, name): ... - def __setitem__(self, name, value): ... - def __delitem__(self, name): ... - def setdefault(self, name, default=...): ... - def has_key(self, name): ... - def __contains__(self, name): ... - def __iter__(self): ... - def keys(self): ... - def values(self): ... - def items(self): ... - -class AddrlistClass: - specials: Any - pos: Any - LWS: Any - CR: Any - atomends: Any - phraseends: Any - field: Any - commentlist: Any - def __init__(self, field): ... - def gotonext(self): ... - def getaddrlist(self): ... - def getaddress(self): ... - def getrouteaddr(self): ... - def getaddrspec(self): ... - def getdomain(self): ... - def getdelimited(self, beginchar, endchars, allowcomments: int = ...): ... - def getquote(self): ... - def getcomment(self): ... - def getdomainliteral(self): ... - def getatom(self, atomends: Any | None = ...): ... - def getphraselist(self): ... - -class AddressList(AddrlistClass): - addresslist: Any - def __init__(self, field): ... - def __len__(self): ... - def __add__(self, other): ... - def __iadd__(self, other): ... - def __sub__(self, other): ... - def __isub__(self, other): ... - def __getitem__(self, index): ... - -def parsedate_tz(data): ... -def parsedate(data): ... -def mktime_tz(data): ... diff --git a/mypy/typeshed/stdlib/@python2/rlcompleter.pyi b/mypy/typeshed/stdlib/@python2/rlcompleter.pyi deleted file mode 100644 index 6cf58fbf20cf..000000000000 --- a/mypy/typeshed/stdlib/@python2/rlcompleter.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Any - -_Text = str | unicode - -class Completer: - def __init__(self, namespace: dict[str, Any] | None = ...) -> None: ... - def complete(self, text: _Text, state: int) -> str | None: ... - def attr_matches(self, text: _Text) -> list[str]: ... - def global_matches(self, text: _Text) -> list[str]: ... diff --git a/mypy/typeshed/stdlib/@python2/robotparser.pyi b/mypy/typeshed/stdlib/@python2/robotparser.pyi deleted file mode 100644 index 403039ae91c9..000000000000 --- a/mypy/typeshed/stdlib/@python2/robotparser.pyi +++ /dev/null @@ -1,7 +0,0 @@ -class RobotFileParser: - def set_url(self, url: str): ... - def read(self): ... - def parse(self, lines: str): ... - def can_fetch(self, user_agent: str, url: str): ... - def mtime(self): ... - def modified(self): ... diff --git a/mypy/typeshed/stdlib/@python2/runpy.pyi b/mypy/typeshed/stdlib/@python2/runpy.pyi deleted file mode 100644 index 3d5f0500f2e0..000000000000 --- a/mypy/typeshed/stdlib/@python2/runpy.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from typing import Any - -class _TempModule: - mod_name: Any - module: Any - def __init__(self, mod_name): ... - def __enter__(self): ... - def __exit__(self, *args): ... - -class _ModifiedArgv0: - value: Any - def __init__(self, value): ... - def __enter__(self): ... - def __exit__(self, *args): ... - -def run_module(mod_name, init_globals: Any | None = ..., run_name: Any | None = ..., alter_sys: bool = ...): ... -def run_path(path_name, init_globals: Any | None = ..., run_name: Any | None = ...): ... diff --git a/mypy/typeshed/stdlib/@python2/sched.pyi b/mypy/typeshed/stdlib/@python2/sched.pyi deleted file mode 100644 index 9247a95da974..000000000000 --- a/mypy/typeshed/stdlib/@python2/sched.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from typing import Any, Callable, NamedTuple, Text - -class Event(NamedTuple): - time: float - priority: Any - action: Callable[..., Any] - argument: tuple[Any, ...] - kwargs: dict[Text, Any] - -class scheduler: - def __init__(self, timefunc: Callable[[], float], delayfunc: Callable[[float], None]) -> None: ... - def enterabs(self, time: float, priority: Any, action: Callable[..., Any], argument: tuple[Any, ...]) -> Event: ... - def enter(self, delay: float, priority: Any, action: Callable[..., Any], argument: tuple[Any, ...]) -> Event: ... - def run(self) -> None: ... - def cancel(self, event: Event) -> None: ... - def empty(self) -> bool: ... - @property - def queue(self) -> list[Event]: ... diff --git a/mypy/typeshed/stdlib/@python2/select.pyi b/mypy/typeshed/stdlib/@python2/select.pyi deleted file mode 100644 index cd799d75b5b1..000000000000 --- a/mypy/typeshed/stdlib/@python2/select.pyi +++ /dev/null @@ -1,124 +0,0 @@ -import sys -from _typeshed import FileDescriptorLike -from typing import Any, Iterable - -if sys.platform != "win32": - PIPE_BUF: int - POLLERR: int - POLLHUP: int - POLLIN: int - POLLMSG: int - POLLNVAL: int - POLLOUT: int - POLLPRI: int - POLLRDBAND: int - POLLRDNORM: int - POLLWRBAND: int - POLLWRNORM: int - -class poll: - def __init__(self) -> None: ... - def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... - def modify(self, fd: FileDescriptorLike, eventmask: int) -> None: ... - def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = ...) -> list[tuple[int, int]]: ... - -def select( - __rlist: Iterable[Any], __wlist: Iterable[Any], __xlist: Iterable[Any], __timeout: float | None = ... -) -> tuple[list[Any], list[Any], list[Any]]: ... - -class error(Exception): ... - -if sys.platform != "linux" and sys.platform != "win32": - # BSD only - class kevent(object): - data: Any - fflags: int - filter: int - flags: int - ident: int - udata: Any - def __init__( - self, - ident: FileDescriptorLike, - filter: int = ..., - flags: int = ..., - fflags: int = ..., - data: Any = ..., - udata: Any = ..., - ) -> None: ... - # BSD only - class kqueue(object): - closed: bool - def __init__(self) -> None: ... - def close(self) -> None: ... - def control( - self, __changelist: Iterable[kevent] | None, __maxevents: int, __timeout: float | None = ... - ) -> list[kevent]: ... - def fileno(self) -> int: ... - @classmethod - def fromfd(cls, __fd: FileDescriptorLike) -> kqueue: ... - KQ_EV_ADD: int - KQ_EV_CLEAR: int - KQ_EV_DELETE: int - KQ_EV_DISABLE: int - KQ_EV_ENABLE: int - KQ_EV_EOF: int - KQ_EV_ERROR: int - KQ_EV_FLAG1: int - KQ_EV_ONESHOT: int - KQ_EV_SYSFLAGS: int - KQ_FILTER_AIO: int - KQ_FILTER_NETDEV: int - KQ_FILTER_PROC: int - KQ_FILTER_READ: int - KQ_FILTER_SIGNAL: int - KQ_FILTER_TIMER: int - KQ_FILTER_VNODE: int - KQ_FILTER_WRITE: int - KQ_NOTE_ATTRIB: int - KQ_NOTE_CHILD: int - KQ_NOTE_DELETE: int - KQ_NOTE_EXEC: int - KQ_NOTE_EXIT: int - KQ_NOTE_EXTEND: int - KQ_NOTE_FORK: int - KQ_NOTE_LINK: int - if sys.platform != "darwin": - KQ_NOTE_LINKDOWN: int - KQ_NOTE_LINKINV: int - KQ_NOTE_LINKUP: int - KQ_NOTE_LOWAT: int - KQ_NOTE_PCTRLMASK: int - KQ_NOTE_PDATAMASK: int - KQ_NOTE_RENAME: int - KQ_NOTE_REVOKE: int - KQ_NOTE_TRACK: int - KQ_NOTE_TRACKERR: int - KQ_NOTE_WRITE: int - -if sys.platform == "linux": - class epoll(object): - def __init__(self, sizehint: int = ...) -> None: ... - def close(self) -> None: ... - closed: bool - def fileno(self) -> int: ... - def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... - def modify(self, fd: FileDescriptorLike, eventmask: int) -> None: ... - def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = ..., maxevents: int = ...) -> list[tuple[int, int]]: ... - @classmethod - def fromfd(cls, __fd: FileDescriptorLike) -> epoll: ... - EPOLLERR: int - EPOLLET: int - EPOLLHUP: int - EPOLLIN: int - EPOLLMSG: int - EPOLLONESHOT: int - EPOLLOUT: int - EPOLLPRI: int - EPOLLRDBAND: int - EPOLLRDNORM: int - EPOLLWRBAND: int - EPOLLWRNORM: int - EPOLL_RDHUP: int diff --git a/mypy/typeshed/stdlib/@python2/sets.pyi b/mypy/typeshed/stdlib/@python2/sets.pyi deleted file mode 100644 index 637bc879fa74..000000000000 --- a/mypy/typeshed/stdlib/@python2/sets.pyi +++ /dev/null @@ -1,58 +0,0 @@ -from _typeshed import Self -from typing import Any, Hashable, Iterable, Iterator, MutableMapping, TypeVar - -_T = TypeVar("_T") -_Setlike = BaseSet[_T] | Iterable[_T] - -class BaseSet(Iterable[_T]): - def __init__(self) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_T]: ... - def __cmp__(self, other: Any) -> int: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - def copy(self: Self) -> Self: ... - def __copy__(self: Self) -> Self: ... - def __deepcopy__(self: Self, memo: MutableMapping[int, BaseSet[_T]]) -> Self: ... - def __or__(self: Self, other: BaseSet[_T]) -> Self: ... - def union(self: Self, other: _Setlike[_T]) -> Self: ... - def __and__(self: Self, other: BaseSet[_T]) -> Self: ... - def intersection(self: Self, other: _Setlike[Any]) -> Self: ... - def __xor__(self: Self, other: BaseSet[_T]) -> Self: ... - def symmetric_difference(self: Self, other: _Setlike[_T]) -> Self: ... - def __sub__(self: Self, other: BaseSet[_T]) -> Self: ... - def difference(self: Self, other: _Setlike[Any]) -> Self: ... - def __contains__(self, element: Any) -> bool: ... - def issubset(self, other: BaseSet[_T]) -> bool: ... - def issuperset(self, other: BaseSet[_T]) -> bool: ... - def __le__(self, other: BaseSet[_T]) -> bool: ... - def __ge__(self, other: BaseSet[_T]) -> bool: ... - def __lt__(self, other: BaseSet[_T]) -> bool: ... - def __gt__(self, other: BaseSet[_T]) -> bool: ... - -class ImmutableSet(BaseSet[_T], Hashable): - def __init__(self, iterable: _Setlike[_T] | None = ...) -> None: ... - def __hash__(self) -> int: ... - -class Set(BaseSet[_T]): - def __init__(self, iterable: _Setlike[_T] | None = ...) -> None: ... - def __ior__(self: Self, other: BaseSet[_T]) -> Self: ... - def union_update(self, other: _Setlike[_T]) -> None: ... - def __iand__(self: Self, other: BaseSet[_T]) -> Self: ... - def intersection_update(self, other: _Setlike[Any]) -> None: ... - def __ixor__(self: Self, other: BaseSet[_T]) -> Self: ... - def symmetric_difference_update(self, other: _Setlike[_T]) -> None: ... - def __isub__(self: Self, other: BaseSet[_T]) -> Self: ... - def difference_update(self, other: _Setlike[Any]) -> None: ... - def update(self, iterable: _Setlike[_T]) -> None: ... - def clear(self) -> None: ... - def add(self, element: _T) -> None: ... - def remove(self, element: _T) -> None: ... - def discard(self, element: _T) -> None: ... - def pop(self) -> _T: ... - def __as_immutable__(self) -> ImmutableSet[_T]: ... - def __as_temporarily_immutable__(self) -> _TemporarilyImmutableSet[_T]: ... - -class _TemporarilyImmutableSet(BaseSet[_T]): - def __init__(self, set: BaseSet[_T]) -> None: ... - def __hash__(self) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/sha.pyi b/mypy/typeshed/stdlib/@python2/sha.pyi deleted file mode 100644 index aac8c8bc57bb..000000000000 --- a/mypy/typeshed/stdlib/@python2/sha.pyi +++ /dev/null @@ -1,10 +0,0 @@ -class sha(object): - def update(self, arg: str) -> None: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def copy(self) -> sha: ... - -def new(string: str = ...) -> sha: ... - -blocksize: int -digest_size: int diff --git a/mypy/typeshed/stdlib/@python2/shelve.pyi b/mypy/typeshed/stdlib/@python2/shelve.pyi deleted file mode 100644 index 011159792e60..000000000000 --- a/mypy/typeshed/stdlib/@python2/shelve.pyi +++ /dev/null @@ -1,37 +0,0 @@ -import collections -from _typeshed import Self -from typing import Any, Iterator - -class Shelf(collections.MutableMapping[Any, Any]): - def __init__( - self, dict: dict[Any, Any], protocol: int | None = ..., writeback: bool = ..., keyencoding: str = ... - ) -> None: ... - def __iter__(self) -> Iterator[str]: ... - def keys(self) -> list[Any]: ... - def __len__(self) -> int: ... - def has_key(self, key: Any) -> bool: ... - def __contains__(self, key: Any) -> bool: ... - def get(self, key: Any, default: Any = ...) -> Any: ... - def __getitem__(self, key: Any) -> Any: ... - def __setitem__(self, key: Any, value: Any) -> None: ... - def __delitem__(self, key: Any) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... - def close(self) -> None: ... - def __del__(self) -> None: ... - def sync(self) -> None: ... - -class BsdDbShelf(Shelf): - def __init__( - self, dict: dict[Any, Any], protocol: int | None = ..., writeback: bool = ..., keyencoding: str = ... - ) -> None: ... - def set_location(self, key: Any) -> tuple[str, Any]: ... - def next(self) -> tuple[str, Any]: ... - def previous(self) -> tuple[str, Any]: ... - def first(self) -> tuple[str, Any]: ... - def last(self) -> tuple[str, Any]: ... - -class DbfilenameShelf(Shelf): - def __init__(self, filename: str, flag: str = ..., protocol: int | None = ..., writeback: bool = ...) -> None: ... - -def open(filename: str, flag: str = ..., protocol: int | None = ..., writeback: bool = ...) -> DbfilenameShelf: ... diff --git a/mypy/typeshed/stdlib/@python2/shlex.pyi b/mypy/typeshed/stdlib/@python2/shlex.pyi deleted file mode 100644 index 6c4557a98036..000000000000 --- a/mypy/typeshed/stdlib/@python2/shlex.pyi +++ /dev/null @@ -1,29 +0,0 @@ -from _typeshed import Self -from typing import IO, Any, Text - -def split(s: str | None, comments: bool = ..., posix: bool = ...) -> list[str]: ... - -class shlex: - def __init__(self, instream: IO[Any] | Text = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ... - def __iter__(self: Self) -> Self: ... - def next(self) -> str: ... - def get_token(self) -> str | None: ... - def push_token(self, _str: str) -> None: ... - def read_token(self) -> str: ... - def sourcehook(self, filename: str) -> None: ... - def push_source(self, stream: IO[Any], filename: str = ...) -> None: ... - def pop_source(self) -> IO[Any]: ... - def error_leader(self, file: str = ..., line: int = ...) -> str: ... - commenters: str - wordchars: str - whitespace: str - escape: str - quotes: str - escapedquotes: str - whitespace_split: bool - infile: IO[Any] - source: str | None - debug: int - lineno: int - token: Any - eof: str | None diff --git a/mypy/typeshed/stdlib/@python2/shutil.pyi b/mypy/typeshed/stdlib/@python2/shutil.pyi deleted file mode 100644 index 173ce9c284af..000000000000 --- a/mypy/typeshed/stdlib/@python2/shutil.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from _typeshed import SupportsRead, SupportsWrite -from typing import Any, AnyStr, Callable, Iterable, Sequence, Text, TypeVar - -_AnyStr = TypeVar("_AnyStr", str, unicode) -_AnyPath = TypeVar("_AnyPath", str, unicode) -_PathReturn = type[None] - -class Error(EnvironmentError): ... -class SpecialFileError(EnvironmentError): ... -class ExecError(EnvironmentError): ... - -def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ... -def copyfile(src: Text, dst: Text) -> None: ... -def copymode(src: Text, dst: Text) -> None: ... -def copystat(src: Text, dst: Text) -> None: ... -def copy(src: Text, dst: Text) -> _PathReturn: ... -def copy2(src: Text, dst: Text) -> _PathReturn: ... -def ignore_patterns(*patterns: Text) -> Callable[[Any, list[_AnyStr]], set[_AnyStr]]: ... -def copytree( - src: AnyStr, dst: AnyStr, symlinks: bool = ..., ignore: None | Callable[[AnyStr, list[AnyStr]], Iterable[AnyStr]] = ... -) -> _PathReturn: ... -def rmtree(path: _AnyPath, ignore_errors: bool = ..., onerror: Callable[[Any, _AnyPath, Any], Any] | None = ...) -> None: ... - -_CopyFn = Callable[[str, str], None] | Callable[[Text, Text], None] - -def move(src: Text, dst: Text) -> _PathReturn: ... -def make_archive( - base_name: _AnyStr, - format: str, - root_dir: Text | None = ..., - base_dir: Text | None = ..., - verbose: bool = ..., - dry_run: bool = ..., - owner: str | None = ..., - group: str | None = ..., - logger: Any | None = ..., -) -> _AnyStr: ... -def get_archive_formats() -> list[tuple[str, str]]: ... -def register_archive_format( - name: str, - function: Callable[..., Any], - extra_args: Sequence[tuple[str, Any] | list[Any]] | None = ..., - description: str = ..., -) -> None: ... -def unregister_archive_format(name: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/signal.pyi b/mypy/typeshed/stdlib/@python2/signal.pyi deleted file mode 100644 index f39f38c41c8f..000000000000 --- a/mypy/typeshed/stdlib/@python2/signal.pyi +++ /dev/null @@ -1,68 +0,0 @@ -from types import FrameType -from typing import Callable - -SIG_DFL: int -SIG_IGN: int - -ITIMER_REAL: int -ITIMER_VIRTUAL: int -ITIMER_PROF: int - -NSIG: int - -SIGABRT: int -SIGALRM: int -SIGBREAK: int # Windows -SIGBUS: int -SIGCHLD: int -SIGCLD: int -SIGCONT: int -SIGEMT: int -SIGFPE: int -SIGHUP: int -SIGILL: int -SIGINFO: int -SIGINT: int -SIGIO: int -SIGIOT: int -SIGKILL: int -SIGPIPE: int -SIGPOLL: int -SIGPROF: int -SIGPWR: int -SIGQUIT: int -SIGRTMAX: int -SIGRTMIN: int -SIGSEGV: int -SIGSTOP: int -SIGSYS: int -SIGTERM: int -SIGTRAP: int -SIGTSTP: int -SIGTTIN: int -SIGTTOU: int -SIGURG: int -SIGUSR1: int -SIGUSR2: int -SIGVTALRM: int -SIGWINCH: int -SIGXCPU: int -SIGXFSZ: int - -# Windows -CTRL_C_EVENT: int -CTRL_BREAK_EVENT: int - -class ItimerError(IOError): ... - -_HANDLER = Callable[[int, FrameType], None] | int | None - -def alarm(time: int) -> int: ... -def getsignal(signalnum: int) -> _HANDLER: ... -def pause() -> None: ... -def setitimer(which: int, seconds: float, interval: float = ...) -> tuple[float, float]: ... -def getitimer(which: int) -> tuple[float, float]: ... -def set_wakeup_fd(fd: int) -> int: ... -def siginterrupt(signalnum: int, flag: bool) -> None: ... -def signal(signalnum: int, handler: _HANDLER) -> _HANDLER: ... -def default_int_handler(signum: int, frame: FrameType) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/site.pyi b/mypy/typeshed/stdlib/@python2/site.pyi deleted file mode 100644 index fc331c113163..000000000000 --- a/mypy/typeshed/stdlib/@python2/site.pyi +++ /dev/null @@ -1,12 +0,0 @@ -from typing import Iterable - -PREFIXES: list[str] -ENABLE_USER_SITE: bool | None -USER_SITE: str | None -USER_BASE: str | None - -def main() -> None: ... -def addsitedir(sitedir: str, known_paths: Iterable[str] | None = ...) -> None: ... -def getsitepackages(prefixes: Iterable[str] | None = ...) -> list[str]: ... -def getuserbase() -> str: ... -def getusersitepackages() -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/smtpd.pyi b/mypy/typeshed/stdlib/@python2/smtpd.pyi deleted file mode 100644 index c7741d183415..000000000000 --- a/mypy/typeshed/stdlib/@python2/smtpd.pyi +++ /dev/null @@ -1,40 +0,0 @@ -import asynchat -import asyncore -import socket -from typing import Any, Text - -_Address = tuple[str, int] # (host, port) - -class SMTPChannel(asynchat.async_chat): - COMMAND: int - DATA: int - def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... - def push(self, msg: Text) -> None: ... - def collect_incoming_data(self, data: bytes) -> None: ... - def found_terminator(self) -> None: ... - def smtp_HELO(self, arg: str) -> None: ... - def smtp_NOOP(self, arg: str) -> None: ... - def smtp_QUIT(self, arg: str) -> None: ... - def smtp_MAIL(self, arg: str) -> None: ... - def smtp_RCPT(self, arg: str) -> None: ... - def smtp_RSET(self, arg: str) -> None: ... - def smtp_DATA(self, arg: str) -> None: ... - -class SMTPServer(asyncore.dispatcher): - channel_class: type[SMTPChannel] - - data_size_limit: int - enable_SMTPUTF8: bool - def __init__(self, localaddr: _Address, remoteaddr: _Address, data_size_limit: int = ...) -> None: ... - def handle_accepted(self, conn: socket.socket, addr: Any) -> None: ... - def process_message( - self, peer: _Address, mailfrom: str, rcpttos: list[Text], data: bytes | str, **kwargs: Any - ) -> str | None: ... - -class DebuggingServer(SMTPServer): ... - -class PureProxy(SMTPServer): - def process_message(self, peer: _Address, mailfrom: str, rcpttos: list[Text], data: bytes | str) -> str | None: ... # type: ignore[override] - -class MailmanProxy(PureProxy): - def process_message(self, peer: _Address, mailfrom: str, rcpttos: list[Text], data: bytes | str) -> str | None: ... # type: ignore[override] diff --git a/mypy/typeshed/stdlib/@python2/smtplib.pyi b/mypy/typeshed/stdlib/@python2/smtplib.pyi deleted file mode 100644 index 438221a439b7..000000000000 --- a/mypy/typeshed/stdlib/@python2/smtplib.pyi +++ /dev/null @@ -1,86 +0,0 @@ -from typing import Any - -class SMTPException(Exception): ... -class SMTPServerDisconnected(SMTPException): ... - -class SMTPResponseException(SMTPException): - smtp_code: Any - smtp_error: Any - args: Any - def __init__(self, code, msg) -> None: ... - -class SMTPSenderRefused(SMTPResponseException): - smtp_code: Any - smtp_error: Any - sender: Any - args: Any - def __init__(self, code, msg, sender) -> None: ... - -class SMTPRecipientsRefused(SMTPException): - recipients: Any - args: Any - def __init__(self, recipients) -> None: ... - -class SMTPDataError(SMTPResponseException): ... -class SMTPConnectError(SMTPResponseException): ... -class SMTPHeloError(SMTPResponseException): ... -class SMTPAuthenticationError(SMTPResponseException): ... - -def quoteaddr(addr): ... -def quotedata(data): ... - -class SSLFakeFile: - sslobj: Any - def __init__(self, sslobj) -> None: ... - def readline(self, size=...): ... - def close(self): ... - -class SMTP: - debuglevel: Any - file: Any - helo_resp: Any - ehlo_msg: Any - ehlo_resp: Any - does_esmtp: Any - default_port: Any - timeout: Any - esmtp_features: Any - local_hostname: Any - def __init__(self, host: str = ..., port: int = ..., local_hostname=..., timeout=...) -> None: ... - def set_debuglevel(self, debuglevel): ... - sock: Any - def connect(self, host=..., port=...): ... - def send(self, str): ... - def putcmd(self, cmd, args=...): ... - def getreply(self): ... - def docmd(self, cmd, args=...): ... - def helo(self, name=...): ... - def ehlo(self, name=...): ... - def has_extn(self, opt): ... - def help(self, args=...): ... - def rset(self): ... - def noop(self): ... - def mail(self, sender, options=...): ... - def rcpt(self, recip, options=...): ... - def data(self, msg): ... - def verify(self, address): ... - vrfy: Any - def expn(self, address): ... - def ehlo_or_helo_if_needed(self): ... - def login(self, user, password): ... - def starttls(self, keyfile=..., certfile=...): ... - def sendmail(self, from_addr, to_addrs, msg, mail_options=..., rcpt_options=...): ... - def close(self): ... - def quit(self): ... - -class SMTP_SSL(SMTP): - default_port: Any - keyfile: Any - certfile: Any - def __init__(self, host=..., port=..., local_hostname=..., keyfile=..., certfile=..., timeout=...) -> None: ... - -class LMTP(SMTP): - ehlo_msg: Any - def __init__(self, host=..., port=..., local_hostname=...) -> None: ... - sock: Any - def connect(self, host=..., port=...): ... diff --git a/mypy/typeshed/stdlib/@python2/sndhdr.pyi b/mypy/typeshed/stdlib/@python2/sndhdr.pyi deleted file mode 100644 index fea65b28899c..000000000000 --- a/mypy/typeshed/stdlib/@python2/sndhdr.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import Text - -_SndHeaders = tuple[str, int, int, int, int | str] - -def what(filename: Text) -> _SndHeaders | None: ... -def whathdr(filename: Text) -> _SndHeaders | None: ... diff --git a/mypy/typeshed/stdlib/@python2/socket.pyi b/mypy/typeshed/stdlib/@python2/socket.pyi deleted file mode 100644 index 296a9fa5e5a5..000000000000 --- a/mypy/typeshed/stdlib/@python2/socket.pyi +++ /dev/null @@ -1,472 +0,0 @@ -import sys -from typing import Any, BinaryIO, Iterable, Text, overload - -# ----- Constants ----- -# Some socket families are listed in the "Socket families" section of the docs, -# but not the "Constants" section. These are listed at the end of the list of -# constants. -# -# Besides those and the first few constants listed, the constants are listed in -# documentation order. - -# Constants defined by Python (i.e. not OS constants re-exported from C) -has_ipv6: bool -SocketType: Any -# Re-exported errno -EAGAIN: int -EBADF: int -EINTR: int -EWOULDBLOCK: int - -# Constants re-exported from C - -# Per socketmodule.c, only these three families are portable -AF_UNIX: AddressFamily -AF_INET: AddressFamily -AF_INET6: AddressFamily - -SOCK_STREAM: SocketKind -SOCK_DGRAM: SocketKind -SOCK_RAW: SocketKind -SOCK_RDM: SocketKind -SOCK_SEQPACKET: SocketKind - -# Address families not mentioned in the docs -AF_AAL5: AddressFamily -AF_APPLETALK: AddressFamily -AF_ASH: AddressFamily -AF_ATMPVC: AddressFamily -AF_ATMSVC: AddressFamily -AF_AX25: AddressFamily -AF_BRIDGE: AddressFamily -AF_DECnet: AddressFamily -AF_ECONET: AddressFamily -AF_IPX: AddressFamily -AF_IRDA: AddressFamily -AF_KEY: AddressFamily -AF_LLC: AddressFamily -AF_NETBEUI: AddressFamily -AF_NETROM: AddressFamily -AF_PPPOX: AddressFamily -AF_ROSE: AddressFamily -AF_ROUTE: AddressFamily -AF_SECURITY: AddressFamily -AF_SNA: AddressFamily -AF_SYSTEM: AddressFamily -AF_UNSPEC: AddressFamily -AF_WANPIPE: AddressFamily -AF_X25: AddressFamily - -# The "many constants" referenced by the docs -SOMAXCONN: int -AI_ADDRCONFIG: AddressInfo -AI_ALL: AddressInfo -AI_CANONNAME: AddressInfo -AI_DEFAULT: AddressInfo -AI_MASK: AddressInfo -AI_NUMERICHOST: AddressInfo -AI_NUMERICSERV: AddressInfo -AI_PASSIVE: AddressInfo -AI_V4MAPPED: AddressInfo -AI_V4MAPPED_CFG: AddressInfo -EAI_ADDRFAMILY: int -EAI_AGAIN: int -EAI_BADFLAGS: int -EAI_BADHINTS: int -EAI_FAIL: int -EAI_FAMILY: int -EAI_MAX: int -EAI_MEMORY: int -EAI_NODATA: int -EAI_NONAME: int -EAI_OVERFLOW: int -EAI_PROTOCOL: int -EAI_SERVICE: int -EAI_SOCKTYPE: int -EAI_SYSTEM: int -INADDR_ALLHOSTS_GROUP: int -INADDR_ANY: int -INADDR_BROADCAST: int -INADDR_LOOPBACK: int -INADDR_MAX_LOCAL_GROUP: int -INADDR_NONE: int -INADDR_UNSPEC_GROUP: int -IPPORT_RESERVED: int -IPPORT_USERRESERVED: int -IPPROTO_AH: int -IPPROTO_BIP: int -IPPROTO_DSTOPTS: int -IPPROTO_EGP: int -IPPROTO_EON: int -IPPROTO_ESP: int -IPPROTO_FRAGMENT: int -IPPROTO_GGP: int -IPPROTO_GRE: int -IPPROTO_HELLO: int -IPPROTO_HOPOPTS: int -IPPROTO_ICMP: int -IPPROTO_ICMPV6: int -IPPROTO_IDP: int -IPPROTO_IGMP: int -IPPROTO_IP: int -IPPROTO_IPCOMP: int -IPPROTO_IPIP: int -IPPROTO_IPV4: int -IPPROTO_IPV6: int -IPPROTO_MAX: int -IPPROTO_MOBILE: int -IPPROTO_ND: int -IPPROTO_NONE: int -IPPROTO_PIM: int -IPPROTO_PUP: int -IPPROTO_RAW: int -IPPROTO_ROUTING: int -IPPROTO_RSVP: int -IPPROTO_SCTP: int -IPPROTO_TCP: int -IPPROTO_TP: int -IPPROTO_UDP: int -IPPROTO_VRRP: int -IPPROTO_XTP: int -IPV6_CHECKSUM: int -IPV6_DONTFRAG: int -IPV6_DSTOPTS: int -IPV6_HOPLIMIT: int -IPV6_HOPOPTS: int -IPV6_JOIN_GROUP: int -IPV6_LEAVE_GROUP: int -IPV6_MULTICAST_HOPS: int -IPV6_MULTICAST_IF: int -IPV6_MULTICAST_LOOP: int -IPV6_NEXTHOP: int -IPV6_PATHMTU: int -IPV6_PKTINFO: int -IPV6_RECVDSTOPTS: int -IPV6_RECVHOPLIMIT: int -IPV6_RECVHOPOPTS: int -IPV6_RECVPATHMTU: int -IPV6_RECVPKTINFO: int -IPV6_RECVRTHDR: int -IPV6_RECVTCLASS: int -IPV6_RTHDR: int -IPV6_RTHDRDSTOPTS: int -IPV6_RTHDR_TYPE_0: int -IPV6_TCLASS: int -IPV6_UNICAST_HOPS: int -IPV6_USE_MIN_MTU: int -IPV6_V6ONLY: int -IPX_TYPE: int -IP_ADD_MEMBERSHIP: int -IP_DEFAULT_MULTICAST_LOOP: int -IP_DEFAULT_MULTICAST_TTL: int -IP_DROP_MEMBERSHIP: int -IP_HDRINCL: int -IP_MAX_MEMBERSHIPS: int -IP_MULTICAST_IF: int -IP_MULTICAST_LOOP: int -IP_MULTICAST_TTL: int -IP_OPTIONS: int -IP_RECVDSTADDR: int -IP_RECVOPTS: int -IP_RECVRETOPTS: int -IP_RETOPTS: int -IP_TOS: int -IP_TRANSPARENT: int -IP_TTL: int -LOCAL_PEERCRED: int -MSG_BCAST: MsgFlag -MSG_BTAG: MsgFlag -MSG_CMSG_CLOEXEC: MsgFlag -MSG_CONFIRM: MsgFlag -MSG_CTRUNC: MsgFlag -MSG_DONTROUTE: MsgFlag -MSG_DONTWAIT: MsgFlag -MSG_EOF: MsgFlag -MSG_EOR: MsgFlag -MSG_ERRQUEUE: MsgFlag -MSG_ETAG: MsgFlag -MSG_FASTOPEN: MsgFlag -MSG_MCAST: MsgFlag -MSG_MORE: MsgFlag -MSG_NOSIGNAL: MsgFlag -MSG_NOTIFICATION: MsgFlag -MSG_OOB: MsgFlag -MSG_PEEK: MsgFlag -MSG_TRUNC: MsgFlag -MSG_WAITALL: MsgFlag -NI_DGRAM: int -NI_MAXHOST: int -NI_MAXSERV: int -NI_NAMEREQD: int -NI_NOFQDN: int -NI_NUMERICHOST: int -NI_NUMERICSERV: int -SCM_CREDENTIALS: int -SCM_CREDS: int -SCM_RIGHTS: int -SHUT_RD: int -SHUT_RDWR: int -SHUT_WR: int -SOL_ATALK: int -SOL_AX25: int -SOL_HCI: int -SOL_IP: int -SOL_IPX: int -SOL_NETROM: int -SOL_ROSE: int -SOL_SOCKET: int -SOL_TCP: int -SOL_UDP: int -SO_ACCEPTCONN: int -SO_BINDTODEVICE: int -SO_BROADCAST: int -SO_DEBUG: int -SO_DONTROUTE: int -SO_ERROR: int -SO_EXCLUSIVEADDRUSE: int -SO_KEEPALIVE: int -SO_LINGER: int -SO_MARK: int -SO_OOBINLINE: int -SO_PASSCRED: int -SO_PEERCRED: int -SO_PRIORITY: int -SO_RCVBUF: int -SO_RCVLOWAT: int -SO_RCVTIMEO: int -SO_REUSEADDR: int -SO_REUSEPORT: int -SO_SETFIB: int -SO_SNDBUF: int -SO_SNDLOWAT: int -SO_SNDTIMEO: int -SO_TYPE: int -SO_USELOOPBACK: int -TCP_CORK: int -TCP_DEFER_ACCEPT: int -TCP_FASTOPEN: int -TCP_INFO: int -TCP_KEEPCNT: int -TCP_KEEPIDLE: int -TCP_KEEPINTVL: int -TCP_LINGER2: int -TCP_MAXSEG: int -TCP_NODELAY: int -TCP_QUICKACK: int -TCP_SYNCNT: int -TCP_WINDOW_CLAMP: int -# Specifically-documented constants - -if sys.platform == "linux": - AF_PACKET: AddressFamily - PF_PACKET: int - PACKET_BROADCAST: int - PACKET_FASTROUTE: int - PACKET_HOST: int - PACKET_LOOPBACK: int - PACKET_MULTICAST: int - PACKET_OTHERHOST: int - PACKET_OUTGOING: int - -if sys.platform == "win32": - SIO_RCVALL: int - SIO_KEEPALIVE_VALS: int - RCVALL_IPLEVEL: int - RCVALL_MAX: int - RCVALL_OFF: int - RCVALL_ON: int - RCVALL_SOCKETLEVELONLY: int - -if sys.platform == "linux": - AF_TIPC: AddressFamily - SOL_TIPC: int - TIPC_ADDR_ID: int - TIPC_ADDR_NAME: int - TIPC_ADDR_NAMESEQ: int - TIPC_CFG_SRV: int - TIPC_CLUSTER_SCOPE: int - TIPC_CONN_TIMEOUT: int - TIPC_CRITICAL_IMPORTANCE: int - TIPC_DEST_DROPPABLE: int - TIPC_HIGH_IMPORTANCE: int - TIPC_IMPORTANCE: int - TIPC_LOW_IMPORTANCE: int - TIPC_MEDIUM_IMPORTANCE: int - TIPC_NODE_SCOPE: int - TIPC_PUBLISHED: int - TIPC_SRC_DROPPABLE: int - TIPC_SUBSCR_TIMEOUT: int - TIPC_SUB_CANCEL: int - TIPC_SUB_PORTS: int - TIPC_SUB_SERVICE: int - TIPC_TOP_SRV: int - TIPC_WAIT_FOREVER: int - TIPC_WITHDRAWN: int - TIPC_ZONE_SCOPE: int - -AF_LINK: AddressFamily # Availability: BSD, macOS - -# Semi-documented constants -# (Listed under "Socket families" in the docs, but not "Constants") - -if sys.platform == "linux": - # Netlink is defined by Linux - AF_NETLINK: AddressFamily - NETLINK_ARPD: int - NETLINK_CRYPTO: int - NETLINK_DNRTMSG: int - NETLINK_FIREWALL: int - NETLINK_IP6_FW: int - NETLINK_NFLOG: int - NETLINK_ROUTE6: int - NETLINK_ROUTE: int - NETLINK_SKIP: int - NETLINK_TAPBASE: int - NETLINK_TCPDIAG: int - NETLINK_USERSOCK: int - NETLINK_W1: int - NETLINK_XFRM: int - -if sys.platform != "win32" and sys.platform != "darwin": - # Linux and some BSD support is explicit in the docs - # Windows and macOS do not support in practice - AF_BLUETOOTH: AddressFamily - BTPROTO_HCI: int - BTPROTO_L2CAP: int - BTPROTO_RFCOMM: int - BTPROTO_SCO: int # not in FreeBSD - - BDADDR_ANY: str - BDADDR_LOCAL: str - - HCI_FILTER: int # not in NetBSD or DragonFlyBSD - # not in FreeBSD, NetBSD, or DragonFlyBSD - HCI_TIME_STAMP: int - HCI_DATA_DIR: int - -if sys.platform == "darwin": - # PF_SYSTEM is defined by macOS - PF_SYSTEM: int - SYSPROTO_CONTROL: int - -# enum versions of above flags -AddressFamily = int -SocketKind = int - -AddressInfo = int -MsgFlag = int - -# ----- Exceptions ----- - -class error(IOError): ... - -class herror(error): - def __init__(self, herror: int = ..., string: str = ...) -> None: ... - -class gaierror(error): - def __init__(self, error: int = ..., string: str = ...) -> None: ... - -class timeout(error): - def __init__(self, error: int = ..., string: str = ...) -> None: ... - -# ----- Classes ----- - -# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6, -# AF_NETLINK, AF_TIPC) or strings (AF_UNIX). -_Address = tuple[Any, ...] | str -_RetAddress = Any -# TODO Most methods allow bytes as address objects - -_WriteBuffer = bytearray | memoryview - -_CMSG = tuple[int, int, bytes] - -class socket: - family: int - type: int - proto: int - def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... - # --- methods --- - def accept(self) -> tuple[socket, _RetAddress]: ... - def bind(self, address: _Address | bytes) -> None: ... - def close(self) -> None: ... - def connect(self, address: _Address | bytes) -> None: ... - def connect_ex(self, address: _Address | bytes) -> int: ... - def detach(self) -> int: ... - def dup(self) -> socket: ... - def fileno(self) -> int: ... - def getpeername(self) -> _RetAddress: ... - def getsockname(self) -> _RetAddress: ... - @overload - def getsockopt(self, level: int, optname: int) -> int: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... - def gettimeout(self) -> float | None: ... - if sys.platform == "win32": - def ioctl(self, control: int, option: int | tuple[int, int, int]) -> None: ... - - def listen(self, __backlog: int) -> None: ... - # Note that the makefile's documented windows-specific behavior is not represented - def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... - def recv(self, bufsize: int, flags: int = ...) -> bytes: ... - def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ... - def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ... - def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ... - def send(self, data: bytes, flags: int = ...) -> int: ... - def sendall(self, data: bytes, flags: int = ...) -> None: ... # return type: None on success - @overload - def sendto(self, data: bytes, address: _Address) -> int: ... - @overload - def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... - def setblocking(self, flag: bool) -> None: ... - def settimeout(self, value: float | None) -> None: ... - def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ... - if sys.platform == "win32": - def share(self, process_id: int) -> bytes: ... - - def shutdown(self, how: int) -> None: ... - -# ----- Functions ----- - -def create_connection( - address: tuple[str | None, int], - timeout: float | None = ..., - source_address: tuple[bytearray | bytes | Text, int] | None = ..., -) -> socket: ... -def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... - -# the 5th tuple item is an address -def getaddrinfo( - host: bytearray | bytes | Text | None, - port: str | int | None, - family: int = ..., - socktype: int = ..., - proto: int = ..., - flags: int = ..., -) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[Any, ...]]]: ... -def getfqdn(name: str = ...) -> str: ... -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[str, int] | tuple[str, int, int, int], flags: int) -> tuple[str, str]: ... -def getprotobyname(protocolname: str) -> int: ... -def getservbyname(servicename: str, protocolname: str = ...) -> int: ... -def getservbyport(port: int, protocolname: str = ...) -> str: ... - -if sys.platform == "win32": - def socketpair(family: int = ..., type: int = ..., proto: int = ...) -> tuple[socket, socket]: ... - -else: - def socketpair(family: int | None = ..., type: int = ..., proto: int = ...) -> tuple[socket, socket]: ... - -def ntohl(x: int) -> int: ... # param & ret val are 32-bit ints -def ntohs(x: int) -> int: ... # param & ret val are 16-bit ints -def htonl(x: int) -> int: ... # param & ret val are 32-bit ints -def htons(x: int) -> int: ... # param & ret val are 16-bit ints -def inet_aton(ip_string: str) -> bytes: ... # ret val 4 bytes in length -def inet_ntoa(packed_ip: bytes) -> str: ... -def inet_pton(address_family: int, ip_string: str) -> bytes: ... -def inet_ntop(address_family: int, packed_ip: bytes) -> str: ... -def getdefaulttimeout() -> float | None: ... -def setdefaulttimeout(timeout: float | None) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/spwd.pyi b/mypy/typeshed/stdlib/@python2/spwd.pyi deleted file mode 100644 index b21242fc49e4..000000000000 --- a/mypy/typeshed/stdlib/@python2/spwd.pyi +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from typing import NamedTuple - -if sys.platform != "win32": - class struct_spwd(NamedTuple): - sp_nam: str - sp_pwd: str - sp_lstchg: int - sp_min: int - sp_max: int - sp_warn: int - sp_inact: int - sp_expire: int - sp_flag: int - def getspall() -> list[struct_spwd]: ... - def getspnam(name: str) -> struct_spwd: ... diff --git a/mypy/typeshed/stdlib/@python2/sqlite3/__init__.pyi b/mypy/typeshed/stdlib/@python2/sqlite3/__init__.pyi deleted file mode 100644 index d747be90fd0a..000000000000 --- a/mypy/typeshed/stdlib/@python2/sqlite3/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -from sqlite3.dbapi2 import * diff --git a/mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi b/mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi deleted file mode 100644 index 90740bcf90a1..000000000000 --- a/mypy/typeshed/stdlib/@python2/sqlite3/dbapi2.pyi +++ /dev/null @@ -1,252 +0,0 @@ -from _typeshed import Self -from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, Text, TypeVar - -_T = TypeVar("_T") - -paramstyle: str -threadsafety: int -apilevel: str -Date = date -Time = time -Timestamp = datetime - -def DateFromTicks(ticks: float) -> Date: ... -def TimeFromTicks(ticks: float) -> Time: ... -def TimestampFromTicks(ticks: float) -> Timestamp: ... - -version_info: tuple[int, int, int] -sqlite_version_info: tuple[int, int, int] -Binary = buffer - -# The remaining definitions are imported from _sqlite3. - -PARSE_COLNAMES: int -PARSE_DECLTYPES: int -SQLITE_ALTER_TABLE: int -SQLITE_ANALYZE: int -SQLITE_ATTACH: int -SQLITE_CREATE_INDEX: int -SQLITE_CREATE_TABLE: int -SQLITE_CREATE_TEMP_INDEX: int -SQLITE_CREATE_TEMP_TABLE: int -SQLITE_CREATE_TEMP_TRIGGER: int -SQLITE_CREATE_TEMP_VIEW: int -SQLITE_CREATE_TRIGGER: int -SQLITE_CREATE_VIEW: int -SQLITE_DELETE: int -SQLITE_DENY: int -SQLITE_DETACH: int -SQLITE_DROP_INDEX: int -SQLITE_DROP_TABLE: int -SQLITE_DROP_TEMP_INDEX: int -SQLITE_DROP_TEMP_TABLE: int -SQLITE_DROP_TEMP_TRIGGER: int -SQLITE_DROP_TEMP_VIEW: int -SQLITE_DROP_TRIGGER: int -SQLITE_DROP_VIEW: int -SQLITE_IGNORE: int -SQLITE_INSERT: int -SQLITE_OK: int -SQLITE_PRAGMA: int -SQLITE_READ: int -SQLITE_REINDEX: int -SQLITE_SELECT: int -SQLITE_TRANSACTION: int -SQLITE_UPDATE: int -adapters: Any -converters: Any -sqlite_version: str -version: str - -# TODO: adapt needs to get probed -def adapt(obj, protocol, alternate): ... -def complete_statement(sql: str) -> bool: ... -def connect( - database: bytes | Text, - timeout: float = ..., - detect_types: int = ..., - isolation_level: str | None = ..., - check_same_thread: bool = ..., - factory: type[Connection] | None = ..., - cached_statements: int = ..., -) -> Connection: ... -def enable_callback_tracebacks(__enable: bool) -> None: ... -def enable_shared_cache(enable: int) -> None: ... -def register_adapter(__type: type[_T], __caster: Callable[[_T], int | float | str | bytes]) -> None: ... -def register_converter(__name: str, __converter: Callable[[bytes], Any]) -> None: ... - -class Cache(object): - def __init__(self, *args, **kwargs) -> None: ... - def display(self, *args, **kwargs) -> None: ... - def get(self, *args, **kwargs) -> None: ... - -class _AggregateProtocol(Protocol): - def step(self, value: int) -> None: ... - def finalize(self) -> int: ... - -class Connection(object): - DataError: Any - DatabaseError: Any - Error: Any - IntegrityError: Any - InterfaceError: Any - InternalError: Any - NotSupportedError: Any - OperationalError: Any - ProgrammingError: Any - Warning: Any - in_transaction: Any - isolation_level: Any - row_factory: Any - text_factory: Any - total_changes: Any - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def close(self) -> None: ... - def commit(self) -> None: ... - def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ... - def create_collation(self, __name: str, __callback: Any) -> None: ... - def create_function(self, name: str, num_params: int, func: Any) -> None: ... - def cursor(self, cursorClass: type | None = ...) -> 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, __parameters: Iterable[Iterable[Any]]) -> Cursor: ... - def executescript(self, __sql_script: bytes | Text) -> Cursor: ... - 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: 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: 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: ... - def load_extension(self, path: str) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, t: type | None, exc: BaseException | None, tb: Any | None) -> None: ... - -class Cursor(Iterator[Any]): - arraysize: Any - connection: Any - description: Any - lastrowid: Any - row_factory: Any - rowcount: int - # 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: 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: bytes | Text) -> Cursor: ... - def fetchall(self) -> list[Any]: ... - def fetchmany(self, size: int | None = ...) -> list[Any]: ... - def fetchone(self) -> Any: ... - def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ... - def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ... - def __iter__(self) -> Cursor: ... - def next(self) -> Any: ... - -class DataError(DatabaseError): ... -class DatabaseError(Error): ... -class Error(Exception): ... -class IntegrityError(DatabaseError): ... -class InterfaceError(Error): ... -class InternalError(DatabaseError): ... -class NotSupportedError(DatabaseError): ... -class OperationalError(DatabaseError): ... - -class OptimizedUnicode(object): - maketrans: Any - def __init__(self, *args, **kwargs): ... - def capitalize(self, *args, **kwargs): ... - def casefold(self, *args, **kwargs): ... - def center(self, *args, **kwargs): ... - def count(self, *args, **kwargs): ... - def encode(self, *args, **kwargs): ... - def endswith(self, *args, **kwargs): ... - def expandtabs(self, *args, **kwargs): ... - def find(self, *args, **kwargs): ... - def format(self, *args, **kwargs): ... - def format_map(self, *args, **kwargs): ... - def index(self, *args, **kwargs): ... - def isalnum(self, *args, **kwargs): ... - def isalpha(self, *args, **kwargs): ... - def isdecimal(self, *args, **kwargs): ... - def isdigit(self, *args, **kwargs): ... - def isidentifier(self, *args, **kwargs): ... - def islower(self, *args, **kwargs): ... - def isnumeric(self, *args, **kwargs): ... - def isprintable(self, *args, **kwargs): ... - def isspace(self, *args, **kwargs): ... - def istitle(self, *args, **kwargs): ... - def isupper(self, *args, **kwargs): ... - def join(self, *args, **kwargs): ... - def ljust(self, *args, **kwargs): ... - def lower(self, *args, **kwargs): ... - def lstrip(self, *args, **kwargs): ... - def partition(self, *args, **kwargs): ... - def replace(self, *args, **kwargs): ... - def rfind(self, *args, **kwargs): ... - def rindex(self, *args, **kwargs): ... - def rjust(self, *args, **kwargs): ... - def rpartition(self, *args, **kwargs): ... - def rsplit(self, *args, **kwargs): ... - def rstrip(self, *args, **kwargs): ... - def split(self, *args, **kwargs): ... - def splitlines(self, *args, **kwargs): ... - def startswith(self, *args, **kwargs): ... - def strip(self, *args, **kwargs): ... - def swapcase(self, *args, **kwargs): ... - def title(self, *args, **kwargs): ... - def translate(self, *args, **kwargs): ... - def upper(self, *args, **kwargs): ... - def zfill(self, *args, **kwargs): ... - def __add__(self, other): ... - def __contains__(self, *args, **kwargs): ... - def __eq__(self, other): ... - def __format__(self, *args, **kwargs): ... - def __ge__(self, other): ... - def __getitem__(self, index): ... - def __getnewargs__(self, *args, **kwargs): ... - def __gt__(self, other): ... - def __hash__(self): ... - def __iter__(self): ... - def __le__(self, other): ... - def __len__(self, *args, **kwargs): ... - def __lt__(self, other): ... - def __mod__(self, other): ... - def __mul__(self, other): ... - def __ne__(self, other): ... - def __rmod__(self, other): ... - def __rmul__(self, other): ... - -class PrepareProtocol(object): - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - -class ProgrammingError(DatabaseError): ... - -class Row(object): - 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): ... - def __gt__(self, other): ... - def __hash__(self): ... - def __iter__(self): ... - def __le__(self, other): ... - def __len__(self): ... - def __lt__(self, other): ... - def __ne__(self, other): ... - -class Statement(object): - def __init__(self, *args, **kwargs): ... - -class Warning(Exception): ... diff --git a/mypy/typeshed/stdlib/@python2/sre_compile.pyi b/mypy/typeshed/stdlib/@python2/sre_compile.pyi deleted file mode 100644 index 30b4d2cb628c..000000000000 --- a/mypy/typeshed/stdlib/@python2/sre_compile.pyi +++ /dev/null @@ -1,22 +0,0 @@ -from sre_constants import ( - SRE_FLAG_DEBUG as SRE_FLAG_DEBUG, - SRE_FLAG_DOTALL as SRE_FLAG_DOTALL, - SRE_FLAG_IGNORECASE as SRE_FLAG_IGNORECASE, - SRE_FLAG_LOCALE as SRE_FLAG_LOCALE, - SRE_FLAG_MULTILINE as SRE_FLAG_MULTILINE, - SRE_FLAG_TEMPLATE as SRE_FLAG_TEMPLATE, - SRE_FLAG_UNICODE as SRE_FLAG_UNICODE, - SRE_FLAG_VERBOSE as SRE_FLAG_VERBOSE, - SRE_INFO_CHARSET as SRE_INFO_CHARSET, - SRE_INFO_LITERAL as SRE_INFO_LITERAL, - SRE_INFO_PREFIX as SRE_INFO_PREFIX, -) -from sre_parse import SubPattern -from typing import Any, Pattern - -MAXCODE: int -STRING_TYPES: tuple[type[str], type[unicode]] -_IsStringType = int - -def isstring(obj: Any) -> _IsStringType: ... -def compile(p: str | bytes | SubPattern, flags: int = ...) -> Pattern[Any]: ... diff --git a/mypy/typeshed/stdlib/@python2/sre_constants.pyi b/mypy/typeshed/stdlib/@python2/sre_constants.pyi deleted file mode 100644 index 09280512a7f4..000000000000 --- a/mypy/typeshed/stdlib/@python2/sre_constants.pyi +++ /dev/null @@ -1,93 +0,0 @@ -from typing import TypeVar - -MAGIC: int -MAXREPEAT: int - -class error(Exception): ... - -FAILURE: str -SUCCESS: str -ANY: str -ANY_ALL: str -ASSERT: str -ASSERT_NOT: str -AT: str -BIGCHARSET: str -BRANCH: str -CALL: str -CATEGORY: str -CHARSET: str -GROUPREF: str -GROUPREF_IGNORE: str -GROUPREF_EXISTS: str -IN: str -IN_IGNORE: str -INFO: str -JUMP: str -LITERAL: str -LITERAL_IGNORE: str -MARK: str -MAX_REPEAT: str -MAX_UNTIL: str -MIN_REPEAT: str -MIN_UNTIL: str -NEGATE: str -NOT_LITERAL: str -NOT_LITERAL_IGNORE: str -RANGE: str -REPEAT: str -REPEAT_ONE: str -SUBPATTERN: str -MIN_REPEAT_ONE: str -AT_BEGINNING: str -AT_BEGINNING_LINE: str -AT_BEGINNING_STRING: str -AT_BOUNDARY: str -AT_NON_BOUNDARY: str -AT_END: str -AT_END_LINE: str -AT_END_STRING: str -AT_LOC_BOUNDARY: str -AT_LOC_NON_BOUNDARY: str -AT_UNI_BOUNDARY: str -AT_UNI_NON_BOUNDARY: str -CATEGORY_DIGIT: str -CATEGORY_NOT_DIGIT: str -CATEGORY_SPACE: str -CATEGORY_NOT_SPACE: str -CATEGORY_WORD: str -CATEGORY_NOT_WORD: str -CATEGORY_LINEBREAK: str -CATEGORY_NOT_LINEBREAK: str -CATEGORY_LOC_WORD: str -CATEGORY_LOC_NOT_WORD: str -CATEGORY_UNI_DIGIT: str -CATEGORY_UNI_NOT_DIGIT: str -CATEGORY_UNI_SPACE: str -CATEGORY_UNI_NOT_SPACE: str -CATEGORY_UNI_WORD: str -CATEGORY_UNI_NOT_WORD: str -CATEGORY_UNI_LINEBREAK: str -CATEGORY_UNI_NOT_LINEBREAK: str - -_T = TypeVar("_T") - -def makedict(list: list[_T]) -> dict[_T, int]: ... - -OP_IGNORE: dict[str, str] -AT_MULTILINE: dict[str, str] -AT_LOCALE: dict[str, str] -AT_UNICODE: dict[str, str] -CH_LOCALE: dict[str, str] -CH_UNICODE: dict[str, str] -SRE_FLAG_TEMPLATE: int -SRE_FLAG_IGNORECASE: int -SRE_FLAG_LOCALE: int -SRE_FLAG_MULTILINE: int -SRE_FLAG_DOTALL: int -SRE_FLAG_UNICODE: int -SRE_FLAG_VERBOSE: int -SRE_FLAG_DEBUG: int -SRE_INFO_PREFIX: int -SRE_INFO_LITERAL: int -SRE_INFO_CHARSET: int diff --git a/mypy/typeshed/stdlib/@python2/sre_parse.pyi b/mypy/typeshed/stdlib/@python2/sre_parse.pyi deleted file mode 100644 index 9929b804126e..000000000000 --- a/mypy/typeshed/stdlib/@python2/sre_parse.pyi +++ /dev/null @@ -1,62 +0,0 @@ -from typing import Any, Iterable, Match, Pattern as _Pattern - -SPECIAL_CHARS: str -REPEAT_CHARS: str -DIGITS: set[Any] -OCTDIGITS: set[Any] -HEXDIGITS: set[Any] -WHITESPACE: set[Any] -ESCAPES: dict[str, tuple[str, int]] -CATEGORIES: dict[str, tuple[str, str] | tuple[str, list[tuple[str, str]]]] -FLAGS: dict[str, int] - -class Pattern: - flags: int - open: list[int] - groups: int - groupdict: dict[str, int] - lookbehind: int - def __init__(self) -> None: ... - def opengroup(self, name: str = ...) -> int: ... - def closegroup(self, gid: int) -> None: ... - def checkgroup(self, gid: int) -> bool: ... - -_OpSubpatternType = tuple[int | None, int, int, SubPattern] -_OpGroupRefExistsType = tuple[int, SubPattern, SubPattern] -_OpInType = list[tuple[str, int]] -_OpBranchType = tuple[None, list[SubPattern]] -_AvType = _OpInType | _OpBranchType | Iterable[SubPattern] | _OpGroupRefExistsType | _OpSubpatternType -_CodeType = str | _AvType - -class SubPattern: - pattern: str - data: list[_CodeType] - width: int | None - def __init__(self, pattern, data: list[_CodeType] = ...) -> None: ... - def dump(self, level: int = ...) -> None: ... - def __len__(self) -> int: ... - def __delitem__(self, index: int | slice) -> None: ... - def __getitem__(self, index: int | slice) -> SubPattern | _CodeType: ... - def __setitem__(self, index: int | slice, code: _CodeType): ... - def insert(self, index, code: _CodeType) -> None: ... - def append(self, code: _CodeType) -> None: ... - def getwidth(self) -> int: ... - -class Tokenizer: - string: str - index: int - def __init__(self, string: str) -> None: ... - def match(self, char: str, skip: int = ...) -> int: ... - def get(self) -> str | None: ... - def tell(self) -> tuple[int, str | None]: ... - def seek(self, index: int) -> None: ... - -def isident(char: str) -> bool: ... -def isdigit(char: str) -> bool: ... -def isname(name: str) -> bool: ... -def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ... - -_Template = tuple[list[tuple[int, int]], list[int | None]] - -def parse_template(source: str, pattern: _Pattern[Any]) -> _Template: ... -def expand_template(template: _Template, match: Match[Any]) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/ssl.pyi b/mypy/typeshed/stdlib/@python2/ssl.pyi deleted file mode 100644 index edc22ff1515a..000000000000 --- a/mypy/typeshed/stdlib/@python2/ssl.pyi +++ /dev/null @@ -1,270 +0,0 @@ -import socket -import sys -from _typeshed import Self, StrPath -from typing import Any, Callable, ClassVar, Iterable, NamedTuple, Text, Union, overload -from typing_extensions import Literal - -_PCTRTT = tuple[tuple[str, str], ...] -_PCTRTTT = tuple[_PCTRTT, ...] -_PeerCertRetDictType = dict[str, str | _PCTRTTT | _PCTRTT] -_PeerCertRetType = _PeerCertRetDictType | bytes | None -_EnumRetType = list[tuple[bytes, str, Union[set[str], bool]]] -_PasswordType = Union[Callable[[], str | bytes], str, bytes] - -_SC1ArgT = SSLSocket -_SrvnmeCbType = Callable[[_SC1ArgT, str | None, SSLSocket], int | None] - -class SSLError(OSError): - library: str - reason: str - -class SSLZeroReturnError(SSLError): ... -class SSLWantReadError(SSLError): ... -class SSLWantWriteError(SSLError): ... -class SSLSyscallError(SSLError): ... -class SSLEOFError(SSLError): ... -class CertificateError(ValueError): ... - -def wrap_socket( - sock: socket.socket, - keyfile: str | None = ..., - certfile: str | None = ..., - server_side: bool = ..., - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: str | None = ..., - do_handshake_on_connect: bool = ..., - suppress_ragged_eofs: bool = ..., - ciphers: str | None = ..., -) -> SSLSocket: ... -def create_default_context( - purpose: Any = ..., *, cafile: str | None = ..., capath: str | None = ..., cadata: Text | bytes | None = ... -) -> SSLContext: ... -def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: int | None = ..., - check_hostname: bool = ..., - purpose: Any = ..., - certfile: str | None = ..., - keyfile: str | None = ..., - cafile: str | None = ..., - capath: str | None = ..., - cadata: Text | bytes | None = ..., -) -> SSLContext: ... - -_create_default_https_context: Callable[..., SSLContext] - -def RAND_status() -> bool: ... -def RAND_egd(path: str) -> None: ... -def RAND_add(__s: bytes, __entropy: float) -> None: ... -def match_hostname(cert: _PeerCertRetType, hostname: str) -> None: ... -def cert_time_to_seconds(cert_time: str) -> int: ... -def get_server_certificate(addr: tuple[str, int], ssl_version: int = ..., ca_certs: str | None = ...) -> str: ... -def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ... -def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... - -class DefaultVerifyPaths(NamedTuple): - cafile: str - capath: str - openssl_cafile_env: str - openssl_cafile: str - openssl_capath_env: str - openssl_capath: str - -def get_default_verify_paths() -> DefaultVerifyPaths: ... - -if sys.platform == "win32": - def enum_certificates(store_name: str) -> _EnumRetType: ... - def enum_crls(store_name: str) -> _EnumRetType: ... - -CERT_NONE: int -CERT_OPTIONAL: int -CERT_REQUIRED: int - -VERIFY_DEFAULT: int -VERIFY_CRL_CHECK_LEAF: int -VERIFY_CRL_CHECK_CHAIN: int -VERIFY_X509_STRICT: int -VERIFY_X509_TRUSTED_FIRST: int - -PROTOCOL_SSLv23: int -PROTOCOL_SSLv2: int -PROTOCOL_SSLv3: int -PROTOCOL_TLSv1: int -PROTOCOL_TLSv1_1: int -PROTOCOL_TLSv1_2: int -PROTOCOL_TLS: int -OP_ALL: int -OP_NO_SSLv2: int -OP_NO_SSLv3: int -OP_NO_TLSv1: int -OP_NO_TLSv1_1: int -OP_NO_TLSv1_2: int -OP_CIPHER_SERVER_PREFERENCE: int -OP_SINGLE_DH_USE: int -OP_SINGLE_ECDH_USE: int -OP_NO_COMPRESSION: int - -HAS_ALPN: bool -HAS_ECDH: bool -HAS_SNI: bool -HAS_NPN: bool -CHANNEL_BINDING_TYPES: list[str] - -OPENSSL_VERSION: str -OPENSSL_VERSION_INFO: tuple[int, int, int, int, int] -OPENSSL_VERSION_NUMBER: int - -ALERT_DESCRIPTION_HANDSHAKE_FAILURE: int -ALERT_DESCRIPTION_INTERNAL_ERROR: int -ALERT_DESCRIPTION_ACCESS_DENIED: int -ALERT_DESCRIPTION_BAD_CERTIFICATE: int -ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: int -ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: int -ALERT_DESCRIPTION_BAD_RECORD_MAC: int -ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: int -ALERT_DESCRIPTION_CERTIFICATE_REVOKED: int -ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: int -ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: int -ALERT_DESCRIPTION_CLOSE_NOTIFY: int -ALERT_DESCRIPTION_DECODE_ERROR: int -ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: int -ALERT_DESCRIPTION_DECRYPT_ERROR: int -ALERT_DESCRIPTION_ILLEGAL_PARAMETER: int -ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: int -ALERT_DESCRIPTION_NO_RENEGOTIATION: int -ALERT_DESCRIPTION_PROTOCOL_VERSION: int -ALERT_DESCRIPTION_RECORD_OVERFLOW: int -ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: int -ALERT_DESCRIPTION_UNKNOWN_CA: int -ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: int -ALERT_DESCRIPTION_UNRECOGNIZED_NAME: int -ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: int -ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: int -ALERT_DESCRIPTION_USER_CANCELLED: int - -class _ASN1Object(NamedTuple): - nid: int - shortname: str - longname: str - oid: str - -class Purpose(_ASN1Object): - SERVER_AUTH: ClassVar[Purpose] - CLIENT_AUTH: ClassVar[Purpose] - -class SSLSocket(socket.socket): - context: SSLContext - server_side: bool - server_hostname: str | None - def __init__( - self, - sock: socket.socket | None = ..., - keyfile: str | None = ..., - certfile: str | None = ..., - server_side: bool = ..., - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: str | None = ..., - do_handshake_on_connect: bool = ..., - family: int = ..., - type: int = ..., - proto: int = ..., - fileno: int | None = ..., - suppress_ragged_eofs: bool = ..., - npn_protocols: Iterable[str] | None = ..., - ciphers: str | None = ..., - server_hostname: str | None = ..., - _context: SSLContext | None = ..., - _session: Any | None = ..., - ) -> None: ... - def connect(self, addr: socket._Address | bytes) -> None: ... - def connect_ex(self, addr: socket._Address | bytes) -> int: ... - def recv(self, buflen: int = ..., flags: int = ...) -> bytes: ... - def recv_into(self, buffer: socket._WriteBuffer, nbytes: int | None = ..., flags: int = ...) -> int: ... - def recvfrom(self, buflen: int = ..., flags: int = ...) -> tuple[bytes, socket._RetAddress]: ... - def recvfrom_into( - self, buffer: socket._WriteBuffer, nbytes: int | None = ..., flags: int = ... - ) -> tuple[int, socket._RetAddress]: ... - @overload - def sendto(self, data: bytes, flags_or_addr: socket._Address) -> int: ... - @overload - def sendto(self, data: bytes, flags_or_addr: int | socket._Address, addr: socket._Address | None = ...) -> int: ... - def read(self, len: int = ..., buffer: bytearray | None = ...) -> bytes: ... - def write(self, data: bytes) -> int: ... - def do_handshake(self, block: bool = ...) -> None: ... # block is undocumented - @overload - def getpeercert(self, binary_form: Literal[False] = ...) -> _PeerCertRetDictType | None: ... - @overload - def getpeercert(self, binary_form: Literal[True]) -> bytes | None: ... - @overload - def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... - def cipher(self) -> tuple[str, str, int] | None: ... - def compression(self) -> str | None: ... - def get_channel_binding(self, cb_type: str = ...) -> bytes | None: ... - def selected_alpn_protocol(self) -> str | None: ... - def selected_npn_protocol(self) -> str | None: ... - def accept(self) -> tuple[SSLSocket, socket._RetAddress]: ... - def unwrap(self) -> socket.socket: ... - def version(self) -> str | None: ... - def pending(self) -> int: ... - -class SSLContext: - check_hostname: bool - options: int - def __new__(cls: type[Self], protocol: int, *args: Any, **kwargs: Any) -> Self: ... - @property - def protocol(self) -> int: ... - verify_flags: int - verify_mode: int - def __init__(self, protocol: int) -> None: ... - def cert_store_stats(self) -> dict[str, int]: ... - def load_cert_chain(self, certfile: StrPath, keyfile: StrPath | None = ..., password: _PasswordType | None = ...) -> None: ... - def load_default_certs(self, purpose: Purpose = ...) -> None: ... - def load_verify_locations( - self, cafile: StrPath | None = ..., capath: StrPath | None = ..., cadata: Text | bytes | None = ... - ) -> None: ... - @overload - def get_ca_certs(self, binary_form: Literal[False] = ...) -> list[_PeerCertRetDictType]: ... - @overload - def get_ca_certs(self, binary_form: Literal[True]) -> list[bytes]: ... - @overload - def get_ca_certs(self, binary_form: bool = ...) -> Any: ... - def set_default_verify_paths(self) -> None: ... - def set_ciphers(self, __cipherlist: str) -> None: ... - def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... - def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - def set_servername_callback(self, __method: _SrvnmeCbType | None) -> None: ... - def load_dh_params(self, __path: str) -> None: ... - def set_ecdh_curve(self, __name: str) -> None: ... - def wrap_socket( - self, - sock: socket.socket, - server_side: bool = ..., - do_handshake_on_connect: bool = ..., - suppress_ragged_eofs: bool = ..., - server_hostname: str | None = ..., - ) -> SSLSocket: ... - def session_stats(self) -> dict[str, int]: ... - -# TODO below documented in cpython but not in docs.python.org -# taken from python 3.4 -SSL_ERROR_EOF: int -SSL_ERROR_INVALID_ERROR_CODE: int -SSL_ERROR_SSL: int -SSL_ERROR_SYSCALL: int -SSL_ERROR_WANT_CONNECT: int -SSL_ERROR_WANT_READ: int -SSL_ERROR_WANT_WRITE: int -SSL_ERROR_WANT_X509_LOOKUP: int -SSL_ERROR_ZERO_RETURN: int - -def get_protocol_name(protocol_code: int) -> str: ... - -AF_INET: int -PEM_FOOTER: str -PEM_HEADER: str -SOCK_STREAM: int -SOL_SOCKET: int -SO_TYPE: int diff --git a/mypy/typeshed/stdlib/@python2/stat.pyi b/mypy/typeshed/stdlib/@python2/stat.pyi deleted file mode 100644 index b75c955d7ed9..000000000000 --- a/mypy/typeshed/stdlib/@python2/stat.pyi +++ /dev/null @@ -1,58 +0,0 @@ -def S_ISDIR(mode: int) -> bool: ... -def S_ISCHR(mode: int) -> bool: ... -def S_ISBLK(mode: int) -> bool: ... -def S_ISREG(mode: int) -> bool: ... -def S_ISFIFO(mode: int) -> bool: ... -def S_ISLNK(mode: int) -> bool: ... -def S_ISSOCK(mode: int) -> bool: ... -def S_IMODE(mode: int) -> int: ... -def S_IFMT(mode: int) -> int: ... - -ST_MODE: int -ST_INO: int -ST_DEV: int -ST_NLINK: int -ST_UID: int -ST_GID: int -ST_SIZE: int -ST_ATIME: int -ST_MTIME: int -ST_CTIME: int -S_IFSOCK: int -S_IFLNK: int -S_IFREG: int -S_IFBLK: int -S_IFDIR: int -S_IFCHR: int -S_IFIFO: int -S_ISUID: int -S_ISGID: int -S_ISVTX: int -S_IRWXU: int -S_IRUSR: int -S_IWUSR: int -S_IXUSR: int -S_IRWXG: int -S_IRGRP: int -S_IWGRP: int -S_IXGRP: int -S_IRWXO: int -S_IROTH: int -S_IWOTH: int -S_IXOTH: int -S_ENFMT: int -S_IREAD: int -S_IWRITE: int -S_IEXEC: int -UF_NODUMP: int -UF_IMMUTABLE: int -UF_APPEND: int -UF_OPAQUE: int -UF_NOUNLINK: int -UF_COMPRESSED: int -UF_HIDDEN: int -SF_ARCHIVED: int -SF_IMMUTABLE: int -SF_APPEND: int -SF_NOUNLINK: int -SF_SNAPSHOT: int diff --git a/mypy/typeshed/stdlib/@python2/string.pyi b/mypy/typeshed/stdlib/@python2/string.pyi deleted file mode 100644 index 79fce4f893c7..000000000000 --- a/mypy/typeshed/stdlib/@python2/string.pyi +++ /dev/null @@ -1,68 +0,0 @@ -from typing import Any, AnyStr, Iterable, Mapping, Sequence, Text, overload - -ascii_letters: str -ascii_lowercase: str -ascii_uppercase: str -digits: str -hexdigits: str -letters: str -lowercase: str -octdigits: str -punctuation: str -printable: str -uppercase: str -whitespace: str - -def capwords(s: AnyStr, sep: AnyStr = ...) -> AnyStr: ... - -# TODO: originally named 'from' -def maketrans(_from: str, to: str) -> str: ... -def atof(s: unicode) -> float: ... -def atoi(s: unicode, base: int = ...) -> int: ... -def atol(s: unicode, base: int = ...) -> int: ... -def capitalize(word: AnyStr) -> AnyStr: ... -def find(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def rfind(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def index(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def rindex(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def count(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def lower(s: AnyStr) -> AnyStr: ... -def split(s: AnyStr, sep: AnyStr = ..., maxsplit: int = ...) -> list[AnyStr]: ... -def rsplit(s: AnyStr, sep: AnyStr = ..., maxsplit: int = ...) -> list[AnyStr]: ... -def splitfields(s: AnyStr, sep: AnyStr = ..., maxsplit: int = ...) -> list[AnyStr]: ... -def join(words: Iterable[AnyStr], sep: AnyStr = ...) -> AnyStr: ... -def joinfields(word: Iterable[AnyStr], sep: AnyStr = ...) -> AnyStr: ... -def lstrip(s: AnyStr, chars: AnyStr = ...) -> AnyStr: ... -def rstrip(s: AnyStr, chars: AnyStr = ...) -> AnyStr: ... -def strip(s: AnyStr, chars: AnyStr = ...) -> AnyStr: ... -def swapcase(s: AnyStr) -> AnyStr: ... -def translate(s: str, table: str, deletechars: str = ...) -> str: ... -def upper(s: AnyStr) -> AnyStr: ... -def ljust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... -def rjust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... -def center(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... -def zfill(s: AnyStr, width: int) -> AnyStr: ... -def replace(s: AnyStr, old: AnyStr, new: AnyStr, maxreplace: int = ...) -> AnyStr: ... - -class Template: - template: Text - def __init__(self, template: Text) -> None: ... - @overload - def substitute(self, mapping: Mapping[str, str] | Mapping[unicode, str] = ..., **kwds: str) -> str: ... - @overload - def substitute(self, mapping: Mapping[str, Text] | Mapping[unicode, Text] = ..., **kwds: Text) -> Text: ... - @overload - def safe_substitute(self, mapping: Mapping[str, str] | Mapping[unicode, str] = ..., **kwds: str) -> str: ... - @overload - def safe_substitute(self, mapping: Mapping[str, Text] | Mapping[unicode, Text], **kwds: Text) -> Text: ... - -# TODO(MichalPokorny): This is probably badly and/or loosely typed. -class Formatter(object): - def format(self, format_string: str, *args, **kwargs) -> str: ... - def vformat(self, format_string: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> str: ... - def parse(self, format_string: str) -> Iterable[tuple[str, str, str, str]]: ... - def get_field(self, field_name: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... - def get_value(self, key: int | str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... - def check_unused_args(self, used_args: Sequence[int | str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... - def format_field(self, value: Any, format_spec: str) -> Any: ... - def convert_field(self, value: Any, conversion: str) -> Any: ... diff --git a/mypy/typeshed/stdlib/@python2/stringold.pyi b/mypy/typeshed/stdlib/@python2/stringold.pyi deleted file mode 100644 index 80402b0069e3..000000000000 --- a/mypy/typeshed/stdlib/@python2/stringold.pyi +++ /dev/null @@ -1,44 +0,0 @@ -from typing import AnyStr, Iterable - -whitespace: str -lowercase: str -uppercase: str -letters: str -digits: str -hexdigits: str -octdigits: str -_idmap: str -_idmapL: list[str] | None -index_error = ValueError -atoi_error = ValueError -atof_error = ValueError -atol_error = ValueError - -def lower(s: AnyStr) -> AnyStr: ... -def upper(s: AnyStr) -> AnyStr: ... -def swapcase(s: AnyStr) -> AnyStr: ... -def strip(s: AnyStr) -> AnyStr: ... -def lstrip(s: AnyStr) -> AnyStr: ... -def rstrip(s: AnyStr) -> AnyStr: ... -def split(s: AnyStr, sep: AnyStr = ..., maxsplit: int = ...) -> list[AnyStr]: ... -def splitfields(s: AnyStr, sep: AnyStr = ..., maxsplit: int = ...) -> list[AnyStr]: ... -def join(words: Iterable[AnyStr], sep: AnyStr = ...) -> AnyStr: ... -def joinfields(words: Iterable[AnyStr], sep: AnyStr = ...) -> AnyStr: ... -def index(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def rindex(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def count(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def find(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def rfind(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... -def atof(s: unicode) -> float: ... -def atoi(s: unicode, base: int = ...) -> int: ... -def atol(s: unicode, base: int = ...) -> long: ... -def ljust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... -def rjust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... -def center(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... -def zfill(s: AnyStr, width: int) -> AnyStr: ... -def expandtabs(s: AnyStr, tabsize: int = ...) -> AnyStr: ... -def translate(s: str, table: str, deletions: str = ...) -> str: ... -def capitalize(s: AnyStr) -> AnyStr: ... -def capwords(s: AnyStr, sep: AnyStr = ...) -> AnyStr: ... -def maketrans(fromstr: str, tostr: str) -> str: ... -def replace(s: AnyStr, old: AnyStr, new: AnyStr, maxreplace: int = ...) -> AnyStr: ... diff --git a/mypy/typeshed/stdlib/@python2/stringprep.pyi b/mypy/typeshed/stdlib/@python2/stringprep.pyi deleted file mode 100644 index 604fd2f2cae7..000000000000 --- a/mypy/typeshed/stdlib/@python2/stringprep.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from typing import Text - -def in_table_a1(code: Text) -> bool: ... -def in_table_b1(code: Text) -> bool: ... -def map_table_b3(code: Text) -> Text: ... -def map_table_b2(a: Text) -> Text: ... -def in_table_c11(code: Text) -> bool: ... -def in_table_c12(code: Text) -> bool: ... -def in_table_c11_c12(code: Text) -> bool: ... -def in_table_c21(code: Text) -> bool: ... -def in_table_c22(code: Text) -> bool: ... -def in_table_c21_c22(code: Text) -> bool: ... -def in_table_c3(code: Text) -> bool: ... -def in_table_c4(code: Text) -> bool: ... -def in_table_c5(code: Text) -> bool: ... -def in_table_c6(code: Text) -> bool: ... -def in_table_c7(code: Text) -> bool: ... -def in_table_c8(code: Text) -> bool: ... -def in_table_c9(code: Text) -> bool: ... -def in_table_d1(code: Text) -> bool: ... -def in_table_d2(code: Text) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/strop.pyi b/mypy/typeshed/stdlib/@python2/strop.pyi deleted file mode 100644 index 9321bbe5bf5e..000000000000 --- a/mypy/typeshed/stdlib/@python2/strop.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from typing import Sequence - -lowercase: str -uppercase: str -whitespace: str - -def atof(a: str) -> float: ... -def atoi(a: str, base: int = ...) -> int: ... -def atol(a: str, base: int = ...) -> long: ... -def capitalize(s: str) -> str: ... -def count(s: str, sub: str, start: int = ..., end: int = ...) -> int: ... -def expandtabs(string: str, tabsize: int = ...) -> str: ... -def find(s: str, sub: str, start: int = ..., end: int = ...) -> int: ... -def join(list: Sequence[str], sep: str = ...) -> str: ... -def joinfields(list: Sequence[str], sep: str = ...) -> str: ... -def lower(s: str) -> str: ... -def lstrip(s: str) -> str: ... -def maketrans(frm: str, to: str) -> str: ... -def replace(s: str, old: str, new: str, maxsplit: int = ...) -> str: ... -def rfind(s: str, sub: str, start: int = ..., end: int = ...) -> int: ... -def rstrip(s: str) -> str: ... -def split(s: str, sep: str, maxsplit: int = ...) -> list[str]: ... -def splitfields(s: str, sep: str, maxsplit: int = ...) -> list[str]: ... -def strip(s: str) -> str: ... -def swapcase(s: str) -> str: ... -def translate(s: str, table: str, deletechars: str = ...) -> str: ... -def upper(s: str) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/struct.pyi b/mypy/typeshed/stdlib/@python2/struct.pyi deleted file mode 100644 index 0296c737089a..000000000000 --- a/mypy/typeshed/stdlib/@python2/struct.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from array import array -from mmap import mmap -from typing import Any, Text - -class error(Exception): ... - -_FmtType = bytes | Text -_BufferType = array[int] | bytes | bytearray | buffer | memoryview | mmap -_WriteBufferType = array[Any] | bytearray | buffer | memoryview | mmap - -def pack(fmt: _FmtType, *v: Any) -> bytes: ... -def pack_into(fmt: _FmtType, buffer: _WriteBufferType, offset: int, *v: Any) -> None: ... -def unpack(__format: _FmtType, __buffer: _BufferType) -> tuple[Any, ...]: ... -def unpack_from(__format: _FmtType, buffer: _BufferType, offset: int = ...) -> tuple[Any, ...]: ... -def calcsize(__format: _FmtType) -> int: ... - -class Struct: - format: bytes - size: int - def __init__(self, format: _FmtType) -> None: ... - def pack(self, *v: Any) -> bytes: ... - def pack_into(self, buffer: _WriteBufferType, offset: int, *v: Any) -> None: ... - def unpack(self, __buffer: _BufferType) -> tuple[Any, ...]: ... - def unpack_from(self, buffer: _BufferType, offset: int = ...) -> tuple[Any, ...]: ... diff --git a/mypy/typeshed/stdlib/@python2/subprocess.pyi b/mypy/typeshed/stdlib/@python2/subprocess.pyi deleted file mode 100644 index e6ab3dfcbb73..000000000000 --- a/mypy/typeshed/stdlib/@python2/subprocess.pyi +++ /dev/null @@ -1,115 +0,0 @@ -from typing import IO, Any, Callable, Generic, Mapping, Sequence, Text, TypeVar - -_FILE = None | int | IO[Any] -_TXT = bytes | Text -_CMD = _TXT | Sequence[_TXT] -_ENV = Mapping[bytes, _TXT] | Mapping[Text, _TXT] - -# Same args as Popen.__init__ -def call( - args: _CMD, - bufsize: int = ..., - executable: _TXT = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: _TXT | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., -) -> int: ... -def check_call( - args: _CMD, - bufsize: int = ..., - executable: _TXT = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: _TXT | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., -) -> int: ... - -# Same args as Popen.__init__ except for stdout -def check_output( - args: _CMD, - bufsize: int = ..., - executable: _TXT = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: _TXT | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., -) -> bytes: ... - -PIPE: int -STDOUT: int - -class CalledProcessError(Exception): - returncode: int - # morally: _CMD - cmd: Any - # morally: Optional[bytes] - output: bytes - def __init__(self, returncode: int, cmd: _CMD, output: bytes | None = ...) -> None: ... - -# We use a dummy type variable used to make Popen generic like it is in python 3 -_T = TypeVar("_T", bound=bytes) - -class Popen(Generic[_T]): - stdin: IO[bytes] | None - stdout: IO[bytes] | None - stderr: IO[bytes] | None - pid: int - returncode: int - def __new__( - cls, - args: _CMD, - bufsize: int = ..., - executable: _TXT | None = ..., - stdin: _FILE | None = ..., - stdout: _FILE | None = ..., - stderr: _FILE | None = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: _TXT | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any | None = ..., - creationflags: int = ..., - ) -> Popen[bytes]: ... - def poll(self) -> int | None: ... - def wait(self) -> int: ... - # morally: -> Tuple[Optional[bytes], Optional[bytes]] - def communicate(self, input: _TXT | None = ...) -> tuple[bytes, bytes]: ... - def send_signal(self, signal: int) -> None: ... - def terminate(self) -> None: ... - def kill(self) -> None: ... - -def list2cmdline(seq: Sequence[str]) -> str: ... # undocumented - -# Windows-only: STARTUPINFO etc. - -STD_INPUT_HANDLE: Any -STD_OUTPUT_HANDLE: Any -STD_ERROR_HANDLE: Any -SW_HIDE: Any -STARTF_USESTDHANDLES: Any -STARTF_USESHOWWINDOW: Any -CREATE_NEW_CONSOLE: Any -CREATE_NEW_PROCESS_GROUP: Any diff --git a/mypy/typeshed/stdlib/@python2/sunau.pyi b/mypy/typeshed/stdlib/@python2/sunau.pyi deleted file mode 100644 index 85b4d12b4d8a..000000000000 --- a/mypy/typeshed/stdlib/@python2/sunau.pyi +++ /dev/null @@ -1,66 +0,0 @@ -from typing import IO, Any, NoReturn, Text - -_File = Text | IO[bytes] - -class Error(Exception): ... - -AUDIO_FILE_MAGIC: int -AUDIO_FILE_ENCODING_MULAW_8: int -AUDIO_FILE_ENCODING_LINEAR_8: int -AUDIO_FILE_ENCODING_LINEAR_16: int -AUDIO_FILE_ENCODING_LINEAR_24: int -AUDIO_FILE_ENCODING_LINEAR_32: int -AUDIO_FILE_ENCODING_FLOAT: int -AUDIO_FILE_ENCODING_DOUBLE: int -AUDIO_FILE_ENCODING_ADPCM_G721: int -AUDIO_FILE_ENCODING_ADPCM_G722: int -AUDIO_FILE_ENCODING_ADPCM_G723_3: int -AUDIO_FILE_ENCODING_ADPCM_G723_5: int -AUDIO_FILE_ENCODING_ALAW_8: int -AUDIO_UNKNOWN_SIZE: int - -_sunau_params = tuple[int, int, int, int, str, str] - -class Au_read: - def __init__(self, f: _File) -> None: ... - def getfp(self) -> IO[bytes] | None: ... - def rewind(self) -> None: ... - def close(self) -> None: ... - def tell(self) -> int: ... - def getnchannels(self) -> int: ... - def getnframes(self) -> int: ... - def getsampwidth(self) -> int: ... - def getframerate(self) -> int: ... - def getcomptype(self) -> str: ... - def getcompname(self) -> str: ... - def getparams(self) -> _sunau_params: ... - def getmarkers(self) -> None: ... - def getmark(self, id: Any) -> NoReturn: ... - def setpos(self, pos: int) -> None: ... - def readframes(self, nframes: int) -> bytes | None: ... - -class Au_write: - def __init__(self, f: _File) -> None: ... - def setnchannels(self, nchannels: int) -> None: ... - def getnchannels(self) -> int: ... - def setsampwidth(self, sampwidth: int) -> None: ... - def getsampwidth(self) -> int: ... - def setframerate(self, framerate: float) -> None: ... - def getframerate(self) -> int: ... - def setnframes(self, nframes: int) -> None: ... - def getnframes(self) -> int: ... - def setcomptype(self, type: str, name: str) -> None: ... - def getcomptype(self) -> str: ... - def getcompname(self) -> str: ... - def setparams(self, params: _sunau_params) -> None: ... - def getparams(self) -> _sunau_params: ... - def tell(self) -> int: ... - # should be any bytes-like object after 3.4, but we don't have a type for that - def writeframesraw(self, data: bytes) -> None: ... - def writeframes(self, data: bytes) -> None: ... - def close(self) -> None: ... - -# Returns a Au_read if mode is rb and Au_write if mode is wb -def open(f: _File, mode: str | None = ...) -> Any: ... - -openfp = open diff --git a/mypy/typeshed/stdlib/@python2/symbol.pyi b/mypy/typeshed/stdlib/@python2/symbol.pyi deleted file mode 100644 index 052e3f1f8f42..000000000000 --- a/mypy/typeshed/stdlib/@python2/symbol.pyi +++ /dev/null @@ -1,87 +0,0 @@ -single_input: int -file_input: int -eval_input: int -decorator: int -decorators: int -decorated: int -funcdef: int -parameters: int -varargslist: int -fpdef: int -fplist: int -stmt: int -simple_stmt: int -small_stmt: int -expr_stmt: int -augassign: int -print_stmt: int -del_stmt: int -pass_stmt: int -flow_stmt: int -break_stmt: int -continue_stmt: int -return_stmt: int -yield_stmt: int -raise_stmt: int -import_stmt: int -import_name: int -import_from: int -import_as_name: int -dotted_as_name: int -import_as_names: int -dotted_as_names: int -dotted_name: int -global_stmt: int -exec_stmt: int -assert_stmt: int -compound_stmt: int -if_stmt: int -while_stmt: int -for_stmt: int -try_stmt: int -with_stmt: int -with_item: int -except_clause: int -suite: int -testlist_safe: int -old_test: int -old_lambdef: int -test: int -or_test: int -and_test: int -not_test: int -comparison: int -comp_op: int -expr: int -xor_expr: int -and_expr: int -shift_expr: int -arith_expr: int -term: int -factor: int -power: int -atom: int -listmaker: int -testlist_comp: int -lambdef: int -trailer: int -subscriptlist: int -subscript: int -sliceop: int -exprlist: int -testlist: int -dictorsetmaker: int -classdef: int -arglist: int -argument: int -list_iter: int -list_for: int -list_if: int -comp_iter: int -comp_for: int -comp_if: int -testlist1: int -encoding_decl: int -yield_expr: int - -sym_name: dict[int, str] diff --git a/mypy/typeshed/stdlib/@python2/symtable.pyi b/mypy/typeshed/stdlib/@python2/symtable.pyi deleted file mode 100644 index c0b701cc1df5..000000000000 --- a/mypy/typeshed/stdlib/@python2/symtable.pyi +++ /dev/null @@ -1,43 +0,0 @@ -from typing import Any, Sequence, Text - -def symtable(code: Text, filename: Text, compile_type: Text) -> SymbolTable: ... - -class SymbolTable(object): - def __init__(self, raw_table: Any, filename: str) -> None: ... - def get_type(self) -> str: ... - def get_id(self) -> int: ... - def get_name(self) -> str: ... - def get_lineno(self) -> int: ... - def is_optimized(self) -> bool: ... - def is_nested(self) -> bool: ... - def has_children(self) -> bool: ... - def has_exec(self) -> bool: ... - def has_import_star(self) -> bool: ... - def get_identifiers(self) -> Sequence[str]: ... - def lookup(self, name: str) -> Symbol: ... - def get_symbols(self) -> list[Symbol]: ... - def get_children(self) -> list[SymbolTable]: ... - -class Function(SymbolTable): - def get_parameters(self) -> tuple[str, ...]: ... - def get_locals(self) -> tuple[str, ...]: ... - def get_globals(self) -> tuple[str, ...]: ... - def get_frees(self) -> tuple[str, ...]: ... - -class Class(SymbolTable): - def get_methods(self) -> tuple[str, ...]: ... - -class Symbol(object): - def __init__(self, name: str, flags: int, namespaces: Sequence[SymbolTable] | None = ...) -> None: ... - def get_name(self) -> str: ... - def is_referenced(self) -> bool: ... - def is_parameter(self) -> bool: ... - def is_global(self) -> bool: ... - def is_declared_global(self) -> bool: ... - def is_local(self) -> bool: ... - def is_free(self) -> bool: ... - def is_imported(self) -> bool: ... - def is_assigned(self) -> bool: ... - def is_namespace(self) -> bool: ... - def get_namespaces(self) -> Sequence[SymbolTable]: ... - def get_namespace(self) -> SymbolTable: ... diff --git a/mypy/typeshed/stdlib/@python2/sys.pyi b/mypy/typeshed/stdlib/@python2/sys.pyi deleted file mode 100644 index 409b776cdcb0..000000000000 --- a/mypy/typeshed/stdlib/@python2/sys.pyi +++ /dev/null @@ -1,130 +0,0 @@ -from types import ClassType, FrameType, TracebackType -from typing import IO, Any, Callable, NoReturn, Text, Union - -# The following type alias are stub-only and do not exist during runtime -_ExcInfo = tuple[type[BaseException], BaseException, TracebackType] -_OptExcInfo = Union[_ExcInfo, tuple[None, None, None]] - -class _flags: - bytes_warning: int - debug: int - division_new: int - division_warning: int - dont_write_bytecode: int - hash_randomization: int - ignore_environment: int - inspect: int - interactive: int - no_site: int - no_user_site: int - optimize: int - py3k_warning: int - tabcheck: int - unicode: int - verbose: int - -class _float_info: - max: float - max_exp: int - max_10_exp: int - min: float - min_exp: int - min_10_exp: int - dig: int - mant_dig: int - epsilon: float - radix: int - rounds: int - -class _version_info(tuple[int, int, int, str, int]): - major: int - minor: int - micro: int - releaselevel: str - serial: int - -_mercurial: tuple[str, str, str] -api_version: int -argv: list[str] -builtin_module_names: tuple[str, ...] -byteorder: str -copyright: str -dont_write_bytecode: bool -exec_prefix: str -executable: str -flags: _flags -float_repr_style: str -hexversion: int -long_info: object -maxint: int -maxsize: int -maxunicode: int -modules: dict[str, Any] -path: list[str] -platform: str -prefix: str -py3kwarning: bool -__stderr__: IO[str] -__stdin__: IO[str] -__stdout__: IO[str] -stderr: IO[str] -stdin: IO[str] -stdout: IO[str] -subversion: tuple[str, str, str] -version: str -warnoptions: object -float_info: _float_info -version_info: _version_info -ps1: str -ps2: str -last_type: type -last_value: BaseException -last_traceback: TracebackType -# TODO precise types -meta_path: list[Any] -path_hooks: list[Any] -path_importer_cache: dict[str, Any] -displayhook: Callable[[object], Any] -excepthook: Callable[[type[BaseException], BaseException, TracebackType], Any] -exc_type: type | None -exc_value: BaseException | ClassType -exc_traceback: TracebackType - -class _WindowsVersionType: - major: Any - minor: Any - build: Any - platform: Any - service_pack: Any - service_pack_major: Any - service_pack_minor: Any - suite_mask: Any - product_type: Any - -def getwindowsversion() -> _WindowsVersionType: ... -def _clear_type_cache() -> None: ... -def _current_frames() -> dict[int, FrameType]: ... -def _getframe(depth: int = ...) -> FrameType: ... -def call_tracing(fn: Any, args: Any) -> Any: ... -def __displayhook__(value: object) -> None: ... -def __excepthook__(type_: type, value: BaseException, traceback: TracebackType) -> None: ... -def exc_clear() -> None: ... -def exc_info() -> _OptExcInfo: ... - -# sys.exit() accepts an optional argument of anything printable -def exit(arg: Any = ...) -> NoReturn: ... -def getcheckinterval() -> int: ... # deprecated -def getdefaultencoding() -> str: ... -def getdlopenflags() -> int: ... -def getfilesystemencoding() -> str: ... # In practice, never returns None -def getrefcount(arg: Any) -> int: ... -def getrecursionlimit() -> int: ... -def getsizeof(obj: object, default: int = ...) -> int: ... -def getprofile() -> Any | None: ... -def gettrace() -> Any | None: ... -def setcheckinterval(interval: int) -> None: ... # deprecated -def setdlopenflags(n: int) -> None: ... -def setdefaultencoding(encoding: Text) -> None: ... # only exists after reload(sys) -def setprofile(profilefunc: Any) -> None: ... # TODO type -def setrecursionlimit(limit: int) -> None: ... -def settrace(tracefunc: Any) -> None: ... # TODO type diff --git a/mypy/typeshed/stdlib/@python2/sysconfig.pyi b/mypy/typeshed/stdlib/@python2/sysconfig.pyi deleted file mode 100644 index 17077144f6e9..000000000000 --- a/mypy/typeshed/stdlib/@python2/sysconfig.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from typing import IO, Any, overload - -def get_config_var(name: str) -> str | None: ... -@overload -def get_config_vars() -> dict[str, Any]: ... -@overload -def get_config_vars(arg: str, *args: str) -> list[Any]: ... -def get_scheme_names() -> tuple[str, ...]: ... -def get_path_names() -> tuple[str, ...]: ... -def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> str: ... -def get_paths(scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> dict[str, str]: ... -def get_python_version() -> str: ... -def get_platform() -> str: ... -def is_python_build(check_home: bool = ...) -> bool: ... -def parse_config_h(fp: IO[Any], vars: dict[str, Any] | None = ...) -> dict[str, Any]: ... -def get_config_h_filename() -> str: ... -def get_makefile_filename() -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/syslog.pyi b/mypy/typeshed/stdlib/@python2/syslog.pyi deleted file mode 100644 index eaeeb7715e48..000000000000 --- a/mypy/typeshed/stdlib/@python2/syslog.pyi +++ /dev/null @@ -1,44 +0,0 @@ -import sys -from typing import overload - -if sys.platform != "win32": - LOG_ALERT: int - LOG_AUTH: int - LOG_CONS: int - LOG_CRIT: int - LOG_CRON: int - LOG_DAEMON: int - LOG_DEBUG: int - LOG_EMERG: int - LOG_ERR: int - LOG_INFO: int - LOG_KERN: int - LOG_LOCAL0: int - LOG_LOCAL1: int - LOG_LOCAL2: int - LOG_LOCAL3: int - LOG_LOCAL4: int - LOG_LOCAL5: int - LOG_LOCAL6: int - LOG_LOCAL7: int - LOG_LPR: int - LOG_MAIL: int - LOG_NDELAY: int - LOG_NEWS: int - LOG_NOTICE: int - LOG_NOWAIT: int - LOG_PERROR: int - LOG_PID: int - LOG_SYSLOG: int - LOG_USER: int - LOG_UUCP: int - LOG_WARNING: int - def LOG_MASK(a: int) -> int: ... - def LOG_UPTO(a: int) -> int: ... - def closelog() -> None: ... - def openlog(ident: str = ..., logoption: int = ..., facility: int = ...) -> None: ... - def setlogmask(x: int) -> int: ... - @overload - def syslog(priority: int, message: str) -> None: ... - @overload - def syslog(message: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/tabnanny.pyi b/mypy/typeshed/stdlib/@python2/tabnanny.pyi deleted file mode 100644 index cf6eefc2e15f..000000000000 --- a/mypy/typeshed/stdlib/@python2/tabnanny.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Iterable, Text - -verbose: int -filename_only: int - -class NannyNag(Exception): - def __init__(self, lineno: int, msg: str, line: str) -> None: ... - def get_lineno(self) -> int: ... - def get_msg(self) -> str: ... - def get_line(self) -> str: ... - -def check(file: Text) -> None: ... -def process_tokens(tokens: Iterable[tuple[int, str, tuple[int, int], tuple[int, int], str]]) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/tarfile.pyi b/mypy/typeshed/stdlib/@python2/tarfile.pyi deleted file mode 100644 index 571bb19632a8..000000000000 --- a/mypy/typeshed/stdlib/@python2/tarfile.pyi +++ /dev/null @@ -1,289 +0,0 @@ -import io -from _typeshed import Self -from types import TracebackType -from typing import IO, Callable, Iterable, Iterator, Mapping, Text - -# tar constants -NUL: bytes -BLOCKSIZE: int -RECORDSIZE: int -GNU_MAGIC: bytes -POSIX_MAGIC: bytes - -LENGTH_NAME: int -LENGTH_LINK: int -LENGTH_PREFIX: int - -REGTYPE: bytes -AREGTYPE: bytes -LNKTYPE: bytes -SYMTYPE: bytes -CONTTYPE: bytes -BLKTYPE: bytes -DIRTYPE: bytes -FIFOTYPE: bytes -CHRTYPE: bytes - -GNUTYPE_LONGNAME: bytes -GNUTYPE_LONGLINK: bytes -GNUTYPE_SPARSE: bytes - -XHDTYPE: bytes -XGLTYPE: bytes -SOLARIS_XHDTYPE: bytes - -USTAR_FORMAT: int -GNU_FORMAT: int -PAX_FORMAT: int -DEFAULT_FORMAT: int - -# tarfile constants - -SUPPORTED_TYPES: tuple[bytes, ...] -REGULAR_TYPES: tuple[bytes, ...] -GNU_TYPES: tuple[bytes, ...] -PAX_FIELDS: tuple[str, ...] -PAX_NUMBER_FIELDS: dict[str, type] - -ENCODING: str - -TAR_PLAIN: int -TAR_GZIPPED: int - -def open( - name: Text | None = ..., - mode: str = ..., - fileobj: IO[bytes] | None = ..., - bufsize: int = ..., - *, - format: int | None = ..., - tarinfo: type[TarInfo] | None = ..., - dereference: bool | None = ..., - ignore_zeros: bool | None = ..., - encoding: str | None = ..., - errors: str = ..., - pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., - compresslevel: int | None = ..., -) -> TarFile: ... - -class ExFileObject(io.BufferedReader): - def __init__(self, tarfile: TarFile, tarinfo: TarInfo) -> None: ... - -class TarFile(Iterable[TarInfo]): - OPEN_METH: Mapping[str, str] - name: Text | None - mode: str - fileobj: IO[bytes] | None - format: int | None - tarinfo: type[TarInfo] - dereference: bool | None - ignore_zeros: bool | None - encoding: str | None - errors: str - fileobject: type[ExFileObject] - pax_headers: Mapping[str, str] | None - debug: int | None - errorlevel: int | None - offset: int # undocumented - posix: bool - def __init__( - self, - name: Text | None = ..., - mode: str = ..., - fileobj: IO[bytes] | None = ..., - format: int | None = ..., - tarinfo: type[TarInfo] | None = ..., - dereference: bool | None = ..., - ignore_zeros: bool | None = ..., - encoding: str | None = ..., - errors: str = ..., - pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., - copybufsize: int | None = ..., # undocumented - ) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - def __iter__(self) -> Iterator[TarInfo]: ... - @classmethod - def open( - cls, - name: Text | None = ..., - mode: str = ..., - fileobj: IO[bytes] | None = ..., - bufsize: int = ..., - *, - format: int | None = ..., - tarinfo: type[TarInfo] | None = ..., - dereference: bool | None = ..., - ignore_zeros: bool | None = ..., - encoding: str | None = ..., - errors: str = ..., - pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., - ) -> TarFile: ... - @classmethod - def taropen( - cls, - name: Text | None, - mode: str = ..., - fileobj: IO[bytes] | None = ..., - *, - compresslevel: int = ..., - format: int | None = ..., - tarinfo: type[TarInfo] | None = ..., - dereference: bool | None = ..., - ignore_zeros: bool | None = ..., - encoding: str | None = ..., - pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., - ) -> TarFile: ... - @classmethod - def gzopen( - cls, - name: Text | None, - mode: str = ..., - fileobj: IO[bytes] | None = ..., - compresslevel: int = ..., - *, - format: int | None = ..., - tarinfo: type[TarInfo] | None = ..., - dereference: bool | None = ..., - ignore_zeros: bool | None = ..., - encoding: str | None = ..., - pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., - ) -> TarFile: ... - @classmethod - def bz2open( - cls, - name: Text | None, - mode: str = ..., - fileobj: IO[bytes] | None = ..., - compresslevel: int = ..., - *, - format: int | None = ..., - tarinfo: type[TarInfo] | None = ..., - dereference: bool | None = ..., - ignore_zeros: bool | None = ..., - encoding: str | None = ..., - pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., - ) -> TarFile: ... - @classmethod - def xzopen( - cls, - name: Text | None, - mode: str = ..., - fileobj: IO[bytes] | None = ..., - preset: int | None = ..., - *, - format: int | None = ..., - tarinfo: type[TarInfo] | None = ..., - dereference: bool | None = ..., - ignore_zeros: bool | None = ..., - encoding: str | None = ..., - pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., - ) -> TarFile: ... - def getmember(self, name: str) -> TarInfo: ... - def getmembers(self) -> list[TarInfo]: ... - def getnames(self) -> list[str]: ... - def list(self, verbose: bool = ...) -> None: ... - def next(self) -> TarInfo | None: ... - def extractall(self, path: Text = ..., members: Iterable[TarInfo] | None = ...) -> None: ... - def extract(self, member: str | TarInfo, path: Text = ...) -> None: ... - def extractfile(self, member: str | TarInfo) -> IO[bytes] | None: ... - def makedir(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def makefile(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def makeunknown(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def makefifo(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def makedev(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def makelink(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def chown(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def chmod(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def utime(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented - def add( - self, - name: str, - arcname: str | None = ..., - recursive: bool = ..., - exclude: Callable[[str], bool] | None = ..., - filter: Callable[[TarInfo], TarInfo | None] | None = ..., - ) -> None: ... - def addfile(self, tarinfo: TarInfo, fileobj: IO[bytes] | None = ...) -> None: ... - def gettarinfo(self, name: str | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ...) -> TarInfo: ... - def close(self) -> None: ... - -def is_tarfile(name: Text) -> bool: ... -def filemode(mode: int) -> str: ... # undocumented - -class TarFileCompat: - def __init__(self, filename: str, mode: str = ..., compression: int = ...) -> None: ... - -class TarError(Exception): ... -class ReadError(TarError): ... -class CompressionError(TarError): ... -class StreamError(TarError): ... -class ExtractError(TarError): ... -class HeaderError(TarError): ... - -class TarInfo: - name: str - path: str - size: int - mtime: int - chksum: int - devmajor: int - devminor: int - offset: int - offset_data: int - sparse: bytes | None - tarfile: TarFile | None - mode: int - type: bytes - linkname: str - uid: int - gid: int - uname: str - gname: str - pax_headers: Mapping[str, str] - def __init__(self, name: str = ...) -> None: ... - @classmethod - def frombuf(cls, buf: bytes) -> TarInfo: ... - @classmethod - def fromtarfile(cls, tarfile: TarFile) -> TarInfo: ... - @property - def linkpath(self) -> str: ... - @linkpath.setter - def linkpath(self, linkname: str) -> None: ... - def get_info(self) -> Mapping[str, str | int | bytes | Mapping[str, str]]: ... - def tobuf(self, format: int | None = ..., encoding: str | None = ..., errors: str = ...) -> bytes: ... - def create_ustar_header( - self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str - ) -> bytes: ... - def create_gnu_header( - self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str - ) -> bytes: ... - def create_pax_header(self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str) -> bytes: ... - @classmethod - def create_pax_global_header(cls, pax_headers: Mapping[str, str]) -> bytes: ... - def isfile(self) -> bool: ... - def isreg(self) -> bool: ... - def issparse(self) -> bool: ... - def isdir(self) -> bool: ... - def issym(self) -> bool: ... - def islnk(self) -> bool: ... - def ischr(self) -> bool: ... - def isblk(self) -> bool: ... - def isfifo(self) -> bool: ... - def isdev(self) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/telnetlib.pyi b/mypy/typeshed/stdlib/@python2/telnetlib.pyi deleted file mode 100644 index 5cd47e28a95c..000000000000 --- a/mypy/typeshed/stdlib/@python2/telnetlib.pyi +++ /dev/null @@ -1,111 +0,0 @@ -import socket -from typing import Any, Callable, Match, Pattern, Sequence - -DEBUGLEVEL: int -TELNET_PORT: int - -IAC: bytes -DONT: bytes -DO: bytes -WONT: bytes -WILL: bytes -theNULL: bytes - -SE: bytes -NOP: bytes -DM: bytes -BRK: bytes -IP: bytes -AO: bytes -AYT: bytes -EC: bytes -EL: bytes -GA: bytes -SB: bytes - -BINARY: bytes -ECHO: bytes -RCP: bytes -SGA: bytes -NAMS: bytes -STATUS: bytes -TM: bytes -RCTE: bytes -NAOL: bytes -NAOP: bytes -NAOCRD: bytes -NAOHTS: bytes -NAOHTD: bytes -NAOFFD: bytes -NAOVTS: bytes -NAOVTD: bytes -NAOLFD: bytes -XASCII: bytes -LOGOUT: bytes -BM: bytes -DET: bytes -SUPDUP: bytes -SUPDUPOUTPUT: bytes -SNDLOC: bytes -TTYPE: bytes -EOR: bytes -TUID: bytes -OUTMRK: bytes -TTYLOC: bytes -VT3270REGIME: bytes -X3PAD: bytes -NAWS: bytes -TSPEED: bytes -LFLOW: bytes -LINEMODE: bytes -XDISPLOC: bytes -OLD_ENVIRON: bytes -AUTHENTICATION: bytes -ENCRYPT: bytes -NEW_ENVIRON: bytes - -TN3270E: bytes -XAUTH: bytes -CHARSET: bytes -RSP: bytes -COM_PORT_OPTION: bytes -SUPPRESS_LOCAL_ECHO: bytes -TLS: bytes -KERMIT: bytes -SEND_URL: bytes -FORWARD_X: bytes -PRAGMA_LOGON: bytes -SSPI_LOGON: bytes -PRAGMA_HEARTBEAT: bytes -EXOPL: bytes -NOOPT: bytes - -class Telnet: - host: str | None # undocumented - def __init__(self, host: str | None = ..., port: int = ..., timeout: float = ...) -> None: ... - def open(self, host: str, port: int = ..., timeout: float = ...) -> None: ... - def msg(self, msg: str, *args: Any) -> None: ... - def set_debuglevel(self, debuglevel: int) -> None: ... - def close(self) -> None: ... - def get_socket(self) -> socket.socket: ... - def fileno(self) -> int: ... - def write(self, buffer: bytes) -> None: ... - def read_until(self, match: bytes, timeout: float | None = ...) -> bytes: ... - def read_all(self) -> bytes: ... - def read_some(self) -> bytes: ... - def read_very_eager(self) -> bytes: ... - def read_eager(self) -> bytes: ... - def read_lazy(self) -> bytes: ... - def read_very_lazy(self) -> bytes: ... - def read_sb_data(self) -> bytes: ... - def set_option_negotiation_callback(self, callback: Callable[[socket.socket, bytes, bytes], Any] | None) -> None: ... - def process_rawq(self) -> None: ... - def rawq_getchar(self) -> bytes: ... - def fill_rawq(self) -> None: ... - def sock_avail(self) -> bool: ... - def interact(self) -> None: ... - def mt_interact(self) -> None: ... - def listener(self) -> None: ... - def expect( - self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... - ) -> tuple[int, Match[bytes] | None, bytes]: ... diff --git a/mypy/typeshed/stdlib/@python2/tempfile.pyi b/mypy/typeshed/stdlib/@python2/tempfile.pyi deleted file mode 100644 index 3d94bdefeb74..000000000000 --- a/mypy/typeshed/stdlib/@python2/tempfile.pyi +++ /dev/null @@ -1,101 +0,0 @@ -from _typeshed import Self -from random import Random -from thread import LockType -from typing import IO, Any, AnyStr, Iterable, Iterator, Text, overload - -TMP_MAX: int -tempdir: str -template: str -_name_sequence: _RandomNameSequence | None - -class _RandomNameSequence: - characters: str = ... - mutex: LockType - @property - def rng(self) -> Random: ... - def __iter__(self) -> _RandomNameSequence: ... - def next(self) -> str: ... - # from os.path: - def normcase(self, path: AnyStr) -> AnyStr: ... - -class _TemporaryFileWrapper(IO[str]): - delete: bool - file: IO[str] - name: Any - def __init__(self, file: IO[str], name: Any, delete: bool = ...) -> None: ... - def __del__(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, exc, value, tb) -> bool | None: ... - def __getattr__(self, name: unicode) -> Any: ... - def close(self) -> None: ... - def unlink(self, path: unicode) -> None: ... - # These methods don't exist directly on this object, but - # are delegated to the underlying IO object through __getattr__. - # We need to add them here so that this class is concrete. - def __iter__(self) -> Iterator[str]: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def next(self) -> str: ... - def read(self, n: int = ...) -> str: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> list[str]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: int | None = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: Text) -> int: ... - def writelines(self, lines: Iterable[str]) -> None: ... - -# TODO text files - -def TemporaryFile( - mode: bytes | unicode = ..., - bufsize: int = ..., - suffix: bytes | unicode = ..., - prefix: bytes | unicode = ..., - dir: bytes | unicode | None = ..., -) -> _TemporaryFileWrapper: ... -def NamedTemporaryFile( - mode: bytes | unicode = ..., - bufsize: int = ..., - suffix: bytes | unicode = ..., - prefix: bytes | unicode = ..., - dir: bytes | unicode | None = ..., - delete: bool = ..., -) -> _TemporaryFileWrapper: ... -def SpooledTemporaryFile( - max_size: int = ..., - mode: bytes | unicode = ..., - buffering: int = ..., - suffix: bytes | unicode = ..., - prefix: bytes | unicode = ..., - dir: bytes | unicode | None = ..., -) -> _TemporaryFileWrapper: ... - -class TemporaryDirectory: - name: Any - def __init__(self, suffix: bytes | unicode = ..., prefix: bytes | unicode = ..., dir: bytes | unicode = ...) -> None: ... - def cleanup(self) -> None: ... - def __enter__(self) -> Any: ... # Can be str or unicode - def __exit__(self, type, value, traceback) -> None: ... - -@overload -def mkstemp() -> tuple[int, str]: ... -@overload -def mkstemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr | None = ..., text: bool = ...) -> tuple[int, AnyStr]: ... -@overload -def mkdtemp() -> str: ... -@overload -def mkdtemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr | None = ...) -> AnyStr: ... -@overload -def mktemp() -> str: ... -@overload -def mktemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr | None = ...) -> AnyStr: ... -def gettempdir() -> str: ... -def gettempprefix() -> str: ... -def _candidate_tempdir_list() -> list[str]: ... -def _get_candidate_names() -> _RandomNameSequence | None: ... -def _get_default_tempdir() -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/termios.pyi b/mypy/typeshed/stdlib/@python2/termios.pyi deleted file mode 100644 index c6a90df31b59..000000000000 --- a/mypy/typeshed/stdlib/@python2/termios.pyi +++ /dev/null @@ -1,247 +0,0 @@ -import sys -from _typeshed import FileDescriptorLike -from typing import Any - -if sys.platform != "win32": - _Attr = list[int | list[bytes | int]] - - # TODO constants not really documented - B0: int - B1000000: int - B110: int - B115200: int - B1152000: int - B1200: int - B134: int - B150: int - B1500000: int - B1800: int - B19200: int - B200: int - B2000000: int - B230400: int - B2400: int - B2500000: int - B300: int - B3000000: int - B3500000: int - B38400: int - B4000000: int - B460800: int - B4800: int - B50: int - B500000: int - B57600: int - B576000: int - B600: int - B75: int - B921600: int - B9600: int - BRKINT: int - BS0: int - BS1: int - BSDLY: int - CBAUD: int - CBAUDEX: int - CDSUSP: int - CEOF: int - CEOL: int - CEOT: int - CERASE: int - CFLUSH: int - CIBAUD: int - CINTR: int - CKILL: int - CLNEXT: int - CLOCAL: int - CQUIT: int - CR0: int - CR1: int - CR2: int - CR3: int - CRDLY: int - CREAD: int - CRPRNT: int - CRTSCTS: int - CS5: int - CS6: int - CS7: int - CS8: int - CSIZE: int - CSTART: int - CSTOP: int - CSTOPB: int - CSUSP: int - CWERASE: int - ECHO: int - ECHOCTL: int - ECHOE: int - ECHOK: int - ECHOKE: int - ECHONL: int - ECHOPRT: int - EXTA: int - EXTB: int - FF0: int - FF1: int - FFDLY: int - FIOASYNC: int - FIOCLEX: int - FIONBIO: int - FIONCLEX: int - FIONREAD: int - FLUSHO: int - HUPCL: int - ICANON: int - ICRNL: int - IEXTEN: int - IGNBRK: int - IGNCR: int - IGNPAR: int - IMAXBEL: int - INLCR: int - INPCK: int - IOCSIZE_MASK: int - IOCSIZE_SHIFT: int - ISIG: int - ISTRIP: int - IUCLC: int - IXANY: int - IXOFF: int - IXON: int - NCC: int - NCCS: int - NL0: int - NL1: int - NLDLY: int - NOFLSH: int - N_MOUSE: int - N_PPP: int - N_SLIP: int - N_STRIP: int - N_TTY: int - OCRNL: int - OFDEL: int - OFILL: int - OLCUC: int - ONLCR: int - ONLRET: int - ONOCR: int - OPOST: int - PARENB: int - PARMRK: int - PARODD: int - PENDIN: int - TAB0: int - TAB1: int - TAB2: int - TAB3: int - TABDLY: int - TCFLSH: int - TCGETA: int - TCGETS: int - TCIFLUSH: int - TCIOFF: int - TCIOFLUSH: int - TCION: int - TCOFLUSH: int - TCOOFF: int - TCOON: int - TCSADRAIN: int - TCSAFLUSH: int - TCSANOW: int - TCSBRK: int - TCSBRKP: int - TCSETA: int - TCSETAF: int - TCSETAW: int - TCSETS: int - TCSETSF: int - TCSETSW: int - TCXONC: int - TIOCCONS: int - TIOCEXCL: int - TIOCGETD: int - TIOCGICOUNT: int - TIOCGLCKTRMIOS: int - TIOCGPGRP: int - TIOCGSERIAL: int - TIOCGSOFTCAR: int - TIOCGWINSZ: int - TIOCINQ: int - TIOCLINUX: int - TIOCMBIC: int - TIOCMBIS: int - TIOCMGET: int - TIOCMIWAIT: int - TIOCMSET: int - TIOCM_CAR: int - TIOCM_CD: int - TIOCM_CTS: int - TIOCM_DSR: int - TIOCM_DTR: int - TIOCM_LE: int - TIOCM_RI: int - TIOCM_RNG: int - TIOCM_RTS: int - TIOCM_SR: int - TIOCM_ST: int - TIOCNOTTY: int - TIOCNXCL: int - TIOCOUTQ: int - TIOCPKT: int - TIOCPKT_DATA: int - TIOCPKT_DOSTOP: int - TIOCPKT_FLUSHREAD: int - TIOCPKT_FLUSHWRITE: int - TIOCPKT_NOSTOP: int - TIOCPKT_START: int - TIOCPKT_STOP: int - TIOCSCTTY: int - TIOCSERCONFIG: int - TIOCSERGETLSR: int - TIOCSERGETMULTI: int - TIOCSERGSTRUCT: int - TIOCSERGWILD: int - TIOCSERSETMULTI: int - TIOCSERSWILD: int - TIOCSER_TEMT: int - TIOCSETD: int - TIOCSLCKTRMIOS: int - TIOCSPGRP: int - TIOCSSERIAL: int - TIOCSSOFTCAR: int - TIOCSTI: int - TIOCSWINSZ: int - TOSTOP: int - VDISCARD: int - VEOF: int - VEOL: int - VEOL2: int - VERASE: int - VINTR: int - VKILL: int - VLNEXT: int - VMIN: int - VQUIT: int - VREPRINT: int - VSTART: int - VSTOP: int - VSUSP: int - VSWTC: int - VSWTCH: int - VT0: int - VT1: int - VTDLY: int - VTIME: int - VWERASE: int - XCASE: int - XTABS: int - def tcgetattr(__fd: FileDescriptorLike) -> list[Any]: ... - def tcsetattr(__fd: FileDescriptorLike, __when: int, __attributes: _Attr) -> None: ... - def tcsendbreak(__fd: FileDescriptorLike, __duration: int) -> None: ... - def tcdrain(__fd: FileDescriptorLike) -> None: ... - def tcflush(__fd: FileDescriptorLike, __queue: int) -> None: ... - def tcflow(__fd: FileDescriptorLike, __action: int) -> None: ... - - class error(Exception): ... diff --git a/mypy/typeshed/stdlib/@python2/textwrap.pyi b/mypy/typeshed/stdlib/@python2/textwrap.pyi deleted file mode 100644 index cb9c034cc4ba..000000000000 --- a/mypy/typeshed/stdlib/@python2/textwrap.pyi +++ /dev/null @@ -1,61 +0,0 @@ -from typing import AnyStr, Pattern - -class TextWrapper(object): - width: int = ... - initial_indent: str = ... - subsequent_indent: str = ... - expand_tabs: bool = ... - replace_whitespace: bool = ... - fix_sentence_endings: bool = ... - drop_whitespace: bool = ... - break_long_words: bool = ... - break_on_hyphens: bool = ... - - # Attributes not present in documentation - sentence_end_re: Pattern[str] = ... - wordsep_re: Pattern[str] = ... - wordsep_simple_re: Pattern[str] = ... - whitespace_trans: str = ... - unicode_whitespace_trans: dict[int, int] = ... - uspace: int = ... - x: int = ... - def __init__( - self, - width: int = ..., - initial_indent: str = ..., - subsequent_indent: str = ..., - expand_tabs: bool = ..., - replace_whitespace: bool = ..., - fix_sentence_endings: bool = ..., - break_long_words: bool = ..., - drop_whitespace: bool = ..., - break_on_hyphens: bool = ..., - ) -> None: ... - def wrap(self, text: AnyStr) -> list[AnyStr]: ... - def fill(self, text: AnyStr) -> AnyStr: ... - -def wrap( - text: AnyStr, - width: int = ..., - initial_indent: AnyStr = ..., - subsequent_indent: AnyStr = ..., - expand_tabs: bool = ..., - replace_whitespace: bool = ..., - fix_sentence_endings: bool = ..., - break_long_words: bool = ..., - drop_whitespace: bool = ..., - break_on_hyphens: bool = ..., -) -> list[AnyStr]: ... -def fill( - text: AnyStr, - width: int = ..., - initial_indent: AnyStr = ..., - subsequent_indent: AnyStr = ..., - expand_tabs: bool = ..., - replace_whitespace: bool = ..., - fix_sentence_endings: bool = ..., - break_long_words: bool = ..., - drop_whitespace: bool = ..., - break_on_hyphens: bool = ..., -) -> AnyStr: ... -def dedent(text: AnyStr) -> AnyStr: ... diff --git a/mypy/typeshed/stdlib/@python2/this.pyi b/mypy/typeshed/stdlib/@python2/this.pyi deleted file mode 100644 index 8de996b04aec..000000000000 --- a/mypy/typeshed/stdlib/@python2/this.pyi +++ /dev/null @@ -1,2 +0,0 @@ -s: str -d: dict[str, str] diff --git a/mypy/typeshed/stdlib/@python2/thread.pyi b/mypy/typeshed/stdlib/@python2/thread.pyi deleted file mode 100644 index 9823dddcbfd7..000000000000 --- a/mypy/typeshed/stdlib/@python2/thread.pyi +++ /dev/null @@ -1,29 +0,0 @@ -from typing import Any, Callable -from typing_extensions import final - -def _count() -> int: ... - -class error(Exception): ... - -@final -class LockType: - def acquire(self, waitflag: int = ...) -> bool: ... - def acquire_lock(self, waitflag: int = ...) -> bool: ... - def release(self) -> None: ... - def release_lock(self) -> None: ... - def locked(self) -> bool: ... - def locked_lock(self) -> bool: ... - def __enter__(self) -> LockType: ... - def __exit__(self, typ: Any, value: Any, traceback: Any) -> None: ... - -class _local(object): ... -class _localdummy(object): ... - -def start_new(function: Callable[..., Any], args: Any, kwargs: Any = ...) -> int: ... -def start_new_thread(function: Callable[..., Any], args: Any, kwargs: Any = ...) -> int: ... -def interrupt_main() -> None: ... -def exit() -> None: ... -def exit_thread() -> Any: ... -def allocate_lock() -> LockType: ... -def get_ident() -> int: ... -def stack_size(size: int = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/threading.pyi b/mypy/typeshed/stdlib/@python2/threading.pyi deleted file mode 100644 index b62b3a121b80..000000000000 --- a/mypy/typeshed/stdlib/@python2/threading.pyi +++ /dev/null @@ -1,126 +0,0 @@ -from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, Mapping, Text, TypeVar - -# TODO recursive type -_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] - -_PF = Callable[[FrameType, str, Any], None] - -__all__ = [ - "activeCount", - "active_count", - "Condition", - "currentThread", - "current_thread", - "enumerate", - "Event", - "Lock", - "RLock", - "Semaphore", - "BoundedSemaphore", - "Thread", - "Timer", - "setprofile", - "settrace", - "local", - "stack_size", -] - -def active_count() -> int: ... -def activeCount() -> int: ... -def current_thread() -> Thread: ... -def currentThread() -> Thread: ... -def enumerate() -> list[Thread]: ... -def settrace(func: _TF) -> None: ... -def setprofile(func: _PF | None) -> None: ... -def stack_size(size: int = ...) -> int: ... - -class ThreadError(Exception): ... - -class local(object): - def __getattribute__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __delattr__(self, name: str) -> None: ... - -class Thread: - name: str - ident: int | None - daemon: bool - def __init__( - self, - group: None = ..., - target: Callable[..., Any] | None = ..., - name: Text | None = ..., - args: Iterable[Any] = ..., - kwargs: Mapping[Text, Any] | None = ..., - ) -> None: ... - def start(self) -> None: ... - def run(self) -> None: ... - def join(self, timeout: float | None = ...) -> None: ... - def getName(self) -> str: ... - def setName(self, name: Text) -> None: ... - def is_alive(self) -> bool: ... - def isAlive(self) -> bool: ... - def isDaemon(self) -> bool: ... - def setDaemon(self, daemonic: bool) -> None: ... - -class _DummyThread(Thread): ... - -class Lock: - def __init__(self) -> None: ... - def __enter__(self) -> bool: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - def locked(self) -> bool: ... - -class _RLock: - def __init__(self) -> None: ... - def __enter__(self) -> bool: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - -RLock = _RLock - -class Condition: - def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... - def __enter__(self) -> bool: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - def wait(self, timeout: float | None = ...) -> bool: ... - def notify(self, n: int = ...) -> None: ... - def notify_all(self) -> None: ... - def notifyAll(self) -> None: ... - -class Semaphore: - def __init__(self, value: int = ...) -> None: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... - -class BoundedSemaphore(Semaphore): ... - -class Event: - def __init__(self) -> None: ... - def is_set(self) -> bool: ... - def isSet(self) -> bool: ... - def set(self) -> None: ... - def clear(self) -> None: ... - def wait(self, timeout: float | None = ...) -> bool: ... - -class Timer(Thread): - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... - def cancel(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/time.pyi b/mypy/typeshed/stdlib/@python2/time.pyi deleted file mode 100644 index 93cdafa7cafa..000000000000 --- a/mypy/typeshed/stdlib/@python2/time.pyi +++ /dev/null @@ -1,47 +0,0 @@ -import sys -from typing import Any, NamedTuple -from typing_extensions import final - -_TimeTuple = tuple[int, int, int, int, int, int, int, int, int] - -accept2dyear: bool -altzone: int -daylight: int -timezone: int -tzname: tuple[str, str] - -class _struct_time(NamedTuple): - tm_year: int - tm_mon: int - tm_mday: int - tm_hour: int - tm_min: int - tm_sec: int - tm_wday: int - tm_yday: int - tm_isdst: int - @property - def n_fields(self) -> int: ... - @property - def n_sequence_fields(self) -> int: ... - @property - def n_unnamed_fields(self) -> int: ... - -@final -class struct_time(_struct_time): - def __init__(self, o: _TimeTuple, _arg: Any = ...) -> None: ... - def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ... - -def asctime(t: _TimeTuple | struct_time = ...) -> str: ... -def clock() -> float: ... -def ctime(secs: float | None = ...) -> str: ... -def gmtime(secs: float | None = ...) -> struct_time: ... -def localtime(secs: float | None = ...) -> struct_time: ... -def mktime(t: _TimeTuple | struct_time) -> float: ... -def sleep(secs: float) -> None: ... -def strftime(format: str, t: _TimeTuple | struct_time = ...) -> str: ... -def strptime(string: str, format: str = ...) -> struct_time: ... -def time() -> float: ... - -if sys.platform != "win32": - def tzset() -> None: ... # Unix only diff --git a/mypy/typeshed/stdlib/@python2/timeit.pyi b/mypy/typeshed/stdlib/@python2/timeit.pyi deleted file mode 100644 index b95c89fa312d..000000000000 --- a/mypy/typeshed/stdlib/@python2/timeit.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from typing import IO, Any, Callable, Sequence, Text - -_str = str | Text -_Timer = Callable[[], float] -_stmt = _str | Callable[[], Any] - -default_timer: _Timer - -class Timer: - def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> None: ... - def print_exc(self, file: IO[str] | None = ...) -> None: ... - def timeit(self, number: int = ...) -> float: ... - def repeat(self, repeat: int = ..., number: int = ...) -> list[float]: ... - -def timeit(stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., number: int = ...) -> float: ... -def repeat(stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., repeat: int = ..., number: int = ...) -> list[float]: ... - -_timerFunc = Callable[[], float] - -def main(args: Sequence[str] | None = ..., *, _wrap_timer: Callable[[_timerFunc], _timerFunc] | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/toaiff.pyi b/mypy/typeshed/stdlib/@python2/toaiff.pyi deleted file mode 100644 index d4b86f9bb756..000000000000 --- a/mypy/typeshed/stdlib/@python2/toaiff.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from pipes import Template - -table: dict[str, Template] -t: Template -uncompress: Template - -class error(Exception): ... - -def toaiff(filename: str) -> str: ... -def _toaiff(filename: str, temps: list[str]) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/token.pyi b/mypy/typeshed/stdlib/@python2/token.pyi deleted file mode 100644 index d88aba8678a0..000000000000 --- a/mypy/typeshed/stdlib/@python2/token.pyi +++ /dev/null @@ -1,60 +0,0 @@ -ENDMARKER: int -NAME: int -NUMBER: int -STRING: int -NEWLINE: int -INDENT: int -DEDENT: int -LPAR: int -RPAR: int -LSQB: int -RSQB: int -COLON: int -COMMA: int -SEMI: int -PLUS: int -MINUS: int -STAR: int -SLASH: int -VBAR: int -AMPER: int -LESS: int -GREATER: int -EQUAL: int -DOT: int -PERCENT: int -BACKQUOTE: int -LBRACE: int -RBRACE: int -EQEQUAL: int -NOTEQUAL: int -LESSEQUAL: int -GREATEREQUAL: int -TILDE: int -CIRCUMFLEX: int -LEFTSHIFT: int -RIGHTSHIFT: int -DOUBLESTAR: int -PLUSEQUAL: int -MINEQUAL: int -STAREQUAL: int -SLASHEQUAL: int -PERCENTEQUAL: int -AMPEREQUAL: int -VBAREQUAL: int -CIRCUMFLEXEQUAL: int -LEFTSHIFTEQUAL: int -RIGHTSHIFTEQUAL: int -DOUBLESTAREQUAL: int -DOUBLESLASH: int -DOUBLESLASHEQUAL: int -AT: int -OP: int -ERRORTOKEN: int -N_TOKENS: int -NT_OFFSET: int -tok_name: dict[int, str] - -def ISTERMINAL(x: int) -> bool: ... -def ISNONTERMINAL(x: int) -> bool: ... -def ISEOF(x: int) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/tokenize.pyi b/mypy/typeshed/stdlib/@python2/tokenize.pyi deleted file mode 100644 index f045f76cc39e..000000000000 --- a/mypy/typeshed/stdlib/@python2/tokenize.pyi +++ /dev/null @@ -1,133 +0,0 @@ -from typing import Any, Callable, Generator, Iterable, Iterator - -__author__: str -__credits__: str - -AMPER: int -AMPEREQUAL: int -AT: int -BACKQUOTE: int -Binnumber: str -Bracket: str -CIRCUMFLEX: int -CIRCUMFLEXEQUAL: int -COLON: int -COMMA: int -COMMENT: int -Comment: str -ContStr: str -DEDENT: int -DOT: int -DOUBLESLASH: int -DOUBLESLASHEQUAL: int -DOUBLESTAR: int -DOUBLESTAREQUAL: int -Decnumber: str -Double: str -Double3: str -ENDMARKER: int -EQEQUAL: int -EQUAL: int -ERRORTOKEN: int -Expfloat: str -Exponent: str -Floatnumber: str -Funny: str -GREATER: int -GREATEREQUAL: int -Hexnumber: str -INDENT: int - -def ISEOF(x: int) -> bool: ... -def ISNONTERMINAL(x: int) -> bool: ... -def ISTERMINAL(x: int) -> bool: ... - -Ignore: str -Imagnumber: str -Intnumber: str -LBRACE: int -LEFTSHIFT: int -LEFTSHIFTEQUAL: int -LESS: int -LESSEQUAL: int -LPAR: int -LSQB: int -MINEQUAL: int -MINUS: int -NAME: int -NEWLINE: int -NL: int -NOTEQUAL: int -NT_OFFSET: int -NUMBER: int -N_TOKENS: int -Name: str -Number: str -OP: int -Octnumber: str -Operator: str -PERCENT: int -PERCENTEQUAL: int -PLUS: int -PLUSEQUAL: int -PlainToken: str -Pointfloat: str -PseudoExtras: str -PseudoToken: str -RBRACE: int -RIGHTSHIFT: int -RIGHTSHIFTEQUAL: int -RPAR: int -RSQB: int -SEMI: int -SLASH: int -SLASHEQUAL: int -STAR: int -STAREQUAL: int -STRING: int -Single: str -Single3: str -Special: str -String: str -TILDE: int -Token: str -Triple: str -VBAR: int -VBAREQUAL: int -Whitespace: str -chain: type -double3prog: type -endprogs: dict[str, Any] -pseudoprog: type -single3prog: type -single_quoted: dict[str, str] -t: str -tabsize: int -tok_name: dict[int, str] -tokenprog: type -triple_quoted: dict[str, str] -x: str - -_Pos = tuple[int, int] -_TokenType = tuple[int, str, _Pos, _Pos, str] - -def any(*args, **kwargs) -> str: ... -def generate_tokens(readline: Callable[[], str]) -> Generator[_TokenType, None, None]: ... -def group(*args: str) -> str: ... -def maybe(*args: str) -> str: ... -def printtoken(type: int, token: str, srow_scol: _Pos, erow_ecol: _Pos, line: str) -> None: ... -def tokenize(readline: Callable[[], str], tokeneater: Callable[[tuple[int, str, _Pos, _Pos, str]], None]) -> None: ... -def tokenize_loop(readline: Callable[[], str], tokeneater: Callable[[tuple[int, str, _Pos, _Pos, str]], None]) -> None: ... -def untokenize(iterable: Iterable[_TokenType]) -> str: ... - -class StopTokenizing(Exception): ... -class TokenError(Exception): ... - -class Untokenizer: - prev_col: int - prev_row: int - tokens: list[str] - def __init__(self) -> None: ... - def add_whitespace(self, _Pos) -> None: ... - def compat(self, token: tuple[int, Any], iterable: Iterator[_TokenType]) -> None: ... - def untokenize(self, iterable: Iterable[_TokenType]) -> str: ... diff --git a/mypy/typeshed/stdlib/@python2/trace.pyi b/mypy/typeshed/stdlib/@python2/trace.pyi deleted file mode 100644 index ea9dfba5bb83..000000000000 --- a/mypy/typeshed/stdlib/@python2/trace.pyi +++ /dev/null @@ -1,51 +0,0 @@ -import types -from _typeshed import StrPath -from typing import Any, Callable, Mapping, Sequence, TypeVar -from typing_extensions import ParamSpec - -_T = TypeVar("_T") -_P = ParamSpec("_P") -_localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = tuple[str, str | None, str] - -class CoverageResults: - def __init__( - self, - counts: dict[tuple[str, int], int] | None = ..., - calledfuncs: dict[_fileModuleFunction, int] | None = ..., - infile: StrPath | None = ..., - callers: dict[tuple[_fileModuleFunction, _fileModuleFunction], int] | None = ..., - outfile: StrPath | None = ..., - ) -> None: ... # undocumented - def update(self, other: CoverageResults) -> None: ... - def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: StrPath | None = ...) -> None: ... - def write_results_file( - self, path: StrPath, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: str | None = ... - ) -> tuple[int, int]: ... - -class Trace: - def __init__( - self, - count: int = ..., - trace: int = ..., - countfuncs: int = ..., - countcallers: int = ..., - ignoremods: Sequence[str] = ..., - ignoredirs: Sequence[str] = ..., - infile: StrPath | None = ..., - outfile: StrPath | None = ..., - timing: bool = ..., - ) -> None: ... - def run(self, cmd: str | types.CodeType) -> None: ... - def runctx( - self, cmd: str | types.CodeType, globals: Mapping[str, Any] | None = ..., locals: Mapping[str, Any] | None = ... - ) -> None: ... - def runfunc(self, func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... - def file_module_function_of(self, frame: types.FrameType) -> _fileModuleFunction: ... - def globaltrace_trackcallers(self, frame: types.FrameType, why: str, arg: Any) -> None: ... - def globaltrace_countfuncs(self, frame: types.FrameType, why: str, arg: Any) -> None: ... - def globaltrace_lt(self, frame: types.FrameType, why: str, arg: Any) -> None: ... - def localtrace_trace_and_count(self, frame: types.FrameType, why: str, arg: Any) -> _localtrace: ... - def localtrace_trace(self, frame: types.FrameType, why: str, arg: Any) -> _localtrace: ... - def localtrace_count(self, frame: types.FrameType, why: str, arg: Any) -> _localtrace: ... - def results(self) -> CoverageResults: ... diff --git a/mypy/typeshed/stdlib/@python2/traceback.pyi b/mypy/typeshed/stdlib/@python2/traceback.pyi deleted file mode 100644 index 34fc00ed7daa..000000000000 --- a/mypy/typeshed/stdlib/@python2/traceback.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from types import FrameType, TracebackType -from typing import IO - -_PT = tuple[str, int, str, str | None] - -def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ... -def print_exception( - etype: type[BaseException] | None, - value: BaseException | None, - tb: TracebackType | None, - limit: int | None = ..., - file: IO[str] | None = ..., -) -> None: ... -def print_exc(limit: int | None = ..., file: IO[str] | None = ...) -> None: ... -def print_last(limit: int | None = ..., file: IO[str] | None = ...) -> None: ... -def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: IO[str] | None = ...) -> None: ... -def extract_tb(tb: TracebackType | None, limit: int | None = ...) -> list[_PT]: ... -def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> list[_PT]: ... -def format_list(extracted_list: list[_PT]) -> list[str]: ... -def format_exception_only(etype: type[BaseException] | None, value: BaseException | None) -> list[str]: ... -def format_exception( - etype: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ... -) -> list[str]: ... -def format_exc(limit: int | None = ...) -> str: ... -def format_tb(tb: TracebackType | None, limit: int | None = ...) -> list[str]: ... -def format_stack(f: FrameType | None = ..., limit: int | None = ...) -> list[str]: ... -def tb_lineno(tb: TracebackType) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/tty.pyi b/mypy/typeshed/stdlib/@python2/tty.pyi deleted file mode 100644 index fc7e90bc0ff9..000000000000 --- a/mypy/typeshed/stdlib/@python2/tty.pyi +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from typing import IO - -_FD = int | IO[str] - -if sys.platform != "win32": - # XXX: Undocumented integer constants - IFLAG: int - OFLAG: int - CFLAG: int - LFLAG: int - ISPEED: int - OSPEED: int - CC: int - def setraw(fd: _FD, when: int = ...) -> None: ... - def setcbreak(fd: _FD, when: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/turtle.pyi b/mypy/typeshed/stdlib/@python2/turtle.pyi deleted file mode 100644 index 037b9851381f..000000000000 --- a/mypy/typeshed/stdlib/@python2/turtle.pyi +++ /dev/null @@ -1,503 +0,0 @@ -from _typeshed import Self -from typing import Any, Callable, Sequence, Text, Union, overload - -# TODO: Replace these aliases once we have Python 2 stubs for the Tkinter module. -Canvas = Any -PhotoImage = Any - -# Note: '_Color' is the alias we use for arguments and _AnyColor is the -# alias we use for return types. Really, these two aliases should be the -# same, but as per the "no union returns" typeshed policy, we'll return -# Any instead. -_Color = Union[Text, tuple[float, float, float]] -_AnyColor = Any - -# TODO: Replace this with a TypedDict once it becomes standardized. -_PenState = dict[str, Any] - -_Speed = str | float -_PolygonCoords = Sequence[tuple[float, float]] - -# TODO: Type this more accurately -# Vec2D is actually a custom subclass of 'tuple'. -Vec2D = tuple[float, float] - -class TurtleScreenBase(object): - cv: Canvas = ... - canvwidth: int = ... - canvheight: int = ... - xscale: float = ... - yscale: float = ... - def __init__(self, cv: Canvas) -> None: ... - -class Terminator(Exception): ... -class TurtleGraphicsError(Exception): ... - -class Shape(object): - def __init__(self, type_: str, data: _PolygonCoords | PhotoImage | None = ...) -> None: ... - def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: _Color | None = ...) -> None: ... - -class TurtleScreen(TurtleScreenBase): - def __init__(self, cv: Canvas, mode: str = ..., colormode: float = ..., delay: int = ...) -> None: ... - def clear(self) -> None: ... - @overload - def mode(self, mode: None = ...) -> str: ... - @overload - def mode(self, mode: str) -> None: ... - def setworldcoordinates(self, llx: float, lly: float, urx: float, ury: float) -> None: ... - def register_shape(self, name: str, shape: _PolygonCoords | Shape | None = ...) -> None: ... - @overload - def colormode(self, cmode: None = ...) -> float: ... - @overload - def colormode(self, cmode: float) -> None: ... - def reset(self) -> None: ... - def turtles(self) -> list[Turtle]: ... - @overload - def bgcolor(self) -> _AnyColor: ... - @overload - def bgcolor(self, color: _Color) -> None: ... - @overload - def bgcolor(self, r: float, g: float, b: float) -> None: ... - @overload - def tracer(self, n: None = ...) -> int: ... - @overload - def tracer(self, n: int, delay: int | None = ...) -> None: ... - @overload - def delay(self, delay: None = ...) -> int: ... - @overload - def delay(self, delay: int) -> None: ... - def update(self) -> None: ... - def window_width(self) -> int: ... - def window_height(self) -> int: ... - def getcanvas(self) -> Canvas: ... - def getshapes(self) -> list[str]: ... - def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... - def onkey(self, fun: Callable[[], Any], key: str) -> None: ... - def listen(self, xdummy: float | None = ..., ydummy: float | None = ...) -> None: ... - def ontimer(self, fun: Callable[[], Any], t: int = ...) -> None: ... - @overload - def bgpic(self, picname: None = ...) -> str: ... - @overload - def bgpic(self, picname: str) -> None: ... - @overload - def screensize(self, canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> tuple[int, int]: ... - # Looks like if self.cv is not a ScrolledCanvas, this could return a tuple as well - @overload - def screensize(self, canvwidth: int, canvheight: int, bg: _Color | None = ...) -> None: ... - onscreenclick = onclick - resetscreen = reset - clearscreen = clear - addshape = register_shape - -class TNavigator(object): - START_ORIENTATION: dict[str, Vec2D] = ... - DEFAULT_MODE: str = ... - DEFAULT_ANGLEOFFSET: int = ... - DEFAULT_ANGLEORIENT: int = ... - def __init__(self, mode: str = ...) -> None: ... - def reset(self) -> None: ... - def degrees(self, fullcircle: float = ...) -> None: ... - def radians(self) -> None: ... - def forward(self, distance: float) -> None: ... - def back(self, distance: float) -> None: ... - def right(self, angle: float) -> None: ... - def left(self, angle: float) -> None: ... - def pos(self) -> Vec2D: ... - def xcor(self) -> float: ... - def ycor(self) -> float: ... - @overload - def goto(self, x: tuple[float, float], y: None = ...) -> None: ... - @overload - def goto(self, x: float, y: float) -> None: ... - def home(self) -> None: ... - def setx(self, x: float) -> None: ... - def sety(self, y: float) -> None: ... - @overload - def distance(self, x: TNavigator | tuple[float, float], y: None = ...) -> float: ... - @overload - def distance(self, x: float, y: float) -> float: ... - @overload - def towards(self, x: TNavigator | tuple[float, float], y: None = ...) -> float: ... - @overload - def towards(self, x: float, y: float) -> float: ... - def heading(self) -> float: ... - def setheading(self, to_angle: float) -> None: ... - def circle(self, radius: float, extent: float | None = ..., steps: int | None = ...) -> None: ... - fd = forward - bk = back - backward = back - rt = right - lt = left - position = pos - setpos = goto - setposition = goto - seth = setheading - -class TPen(object): - def __init__(self, resizemode: str = ...) -> None: ... - @overload - def resizemode(self, rmode: None = ...) -> str: ... - @overload - def resizemode(self, rmode: str) -> None: ... - @overload - def pensize(self, width: None = ...) -> int: ... - @overload - def pensize(self, width: int) -> None: ... - def penup(self) -> None: ... - def pendown(self) -> None: ... - def isdown(self) -> bool: ... - @overload - def speed(self, speed: None = ...) -> int: ... - @overload - def speed(self, speed: _Speed) -> None: ... - @overload - def pencolor(self) -> _AnyColor: ... - @overload - def pencolor(self, color: _Color) -> None: ... - @overload - def pencolor(self, r: float, g: float, b: float) -> None: ... - @overload - def fillcolor(self) -> _AnyColor: ... - @overload - def fillcolor(self, color: _Color) -> None: ... - @overload - def fillcolor(self, r: float, g: float, b: float) -> None: ... - @overload - def color(self) -> tuple[_AnyColor, _AnyColor]: ... - @overload - def color(self, color: _Color) -> None: ... - @overload - def color(self, r: float, g: float, b: float) -> None: ... - @overload - def color(self, color1: _Color, color2: _Color) -> None: ... - def showturtle(self) -> None: ... - def hideturtle(self) -> None: ... - def isvisible(self) -> bool: ... - # Note: signatures 1 and 2 overlap unsafely when no arguments are provided - @overload - def pen(self) -> _PenState: ... # type: ignore[misc] - @overload - def pen( - self, - pen: _PenState | None = ..., - *, - shown: bool = ..., - pendown: bool = ..., - pencolor: _Color = ..., - fillcolor: _Color = ..., - pensize: int = ..., - speed: int = ..., - resizemode: str = ..., - stretchfactor: tuple[float, float] = ..., - outline: int = ..., - tilt: float = ..., - ) -> None: ... - width = pensize - up = penup - pu = penup - pd = pendown - down = pendown - st = showturtle - ht = hideturtle - -class RawTurtle(TPen, TNavigator): - def __init__( - self, canvas: Canvas | TurtleScreen | None = ..., shape: str = ..., undobuffersize: int = ..., visible: bool = ... - ) -> None: ... - def reset(self) -> None: ... - def setundobuffer(self, size: int | None) -> None: ... - def undobufferentries(self) -> int: ... - def clear(self) -> None: ... - def clone(self: Self) -> Self: ... - @overload - def shape(self, name: None = ...) -> str: ... - @overload - def shape(self, name: str) -> None: ... - # Unsafely overlaps when no arguments are provided - @overload - def shapesize(self) -> tuple[float, float, float]: ... # type: ignore[misc] - @overload - def shapesize( - self, stretch_wid: float | None = ..., stretch_len: float | None = ..., outline: float | None = ... - ) -> None: ... - def settiltangle(self, angle: float) -> None: ... - @overload - def tiltangle(self, angle: None = ...) -> float: ... - @overload - def tiltangle(self, angle: float) -> None: ... - def tilt(self, angle: float) -> None: ... - # Can return either 'int' or Tuple[int, ...] based on if the stamp is - # a compound stamp or not. So, as per the "no Union return" policy, - # we return Any. - def stamp(self) -> Any: ... - def clearstamp(self, stampid: int | tuple[int, ...]) -> None: ... - def clearstamps(self, n: int | None = ...) -> None: ... - def filling(self) -> bool: ... - def begin_fill(self) -> None: ... - def end_fill(self) -> None: ... - def dot(self, size: int | None = ..., *color: _Color) -> None: ... - def write(self, arg: object, move: bool = ..., align: str = ..., font: tuple[str, int, str] = ...) -> None: ... - def begin_poly(self) -> None: ... - def end_poly(self) -> None: ... - def get_poly(self) -> _PolygonCoords | None: ... - def getscreen(self) -> TurtleScreen: ... - def getturtle(self: Self) -> Self: ... - getpen = getturtle - def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... - def onrelease(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... - def ondrag(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... - def undo(self) -> None: ... - turtlesize = shapesize - -class _Screen(TurtleScreen): - def __init__(self) -> None: ... - # Note int and float are interpreted differently, hence the Union instead of just float - def setup( - self, width: int | float = ..., height: int | float = ..., startx: int | None = ..., starty: int | None = ... - ) -> None: ... - def title(self, titlestring: str) -> None: ... - def bye(self) -> None: ... - def exitonclick(self) -> None: ... - -class Turtle(RawTurtle): - def __init__(self, shape: str = ..., undobuffersize: int = ..., visible: bool = ...) -> None: ... - -RawPen = RawTurtle -Pen = Turtle - -def write_docstringdict(filename: str = ...) -> None: ... - -# Note: it's somewhat unfortunate that we have to copy the function signatures. -# It would be nice if we could partially reduce the redundancy by doing something -# like the following: -# -# _screen: Screen -# clear = _screen.clear -# -# However, it seems pytype does not support this type of syntax in pyi files. - -# Functions copied from TurtleScreenBase: - -# Note: mainloop() was always present in the global scope, but was added to -# TurtleScreenBase in Python 3.0 -def mainloop() -> None: ... - -# Functions copied from TurtleScreen: - -def clear() -> None: ... -@overload -def mode(mode: None = ...) -> str: ... -@overload -def mode(mode: str) -> None: ... -def setworldcoordinates(llx: float, lly: float, urx: float, ury: float) -> None: ... -def register_shape(name: str, shape: _PolygonCoords | Shape | None = ...) -> None: ... -@overload -def colormode(cmode: None = ...) -> float: ... -@overload -def colormode(cmode: float) -> None: ... -def reset() -> None: ... -def turtles() -> list[Turtle]: ... -@overload -def bgcolor() -> _AnyColor: ... -@overload -def bgcolor(color: _Color) -> None: ... -@overload -def bgcolor(r: float, g: float, b: float) -> None: ... -@overload -def tracer(n: None = ...) -> int: ... -@overload -def tracer(n: int, delay: int | None = ...) -> None: ... -@overload -def delay(delay: None = ...) -> int: ... -@overload -def delay(delay: int) -> None: ... -def update() -> None: ... -def window_width() -> int: ... -def window_height() -> int: ... -def getcanvas() -> Canvas: ... -def getshapes() -> list[str]: ... -def onclick(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... -def onkey(fun: Callable[[], Any], key: str) -> None: ... -def listen(xdummy: float | None = ..., ydummy: float | None = ...) -> None: ... -def ontimer(fun: Callable[[], Any], t: int = ...) -> None: ... -@overload -def bgpic(picname: None = ...) -> str: ... -@overload -def bgpic(picname: str) -> None: ... -@overload -def screensize(canvwidth: None = ..., canvheight: None = ..., bg: None = ...) -> tuple[int, int]: ... -@overload -def screensize(canvwidth: int, canvheight: int, bg: _Color | None = ...) -> None: ... - -onscreenclick = onclick -resetscreen = reset -clearscreen = clear -addshape = register_shape -# Functions copied from _Screen: - -def setup(width: float = ..., height: float = ..., startx: int | None = ..., starty: int | None = ...) -> None: ... -def title(titlestring: str) -> None: ... -def bye() -> None: ... -def exitonclick() -> None: ... -def Screen() -> _Screen: ... - -# Functions copied from TNavigator: - -def degrees(fullcircle: float = ...) -> None: ... -def radians() -> None: ... -def forward(distance: float) -> None: ... -def back(distance: float) -> None: ... -def right(angle: float) -> None: ... -def left(angle: float) -> None: ... -def pos() -> Vec2D: ... -def xcor() -> float: ... -def ycor() -> float: ... -@overload -def goto(x: tuple[float, float], y: None = ...) -> None: ... -@overload -def goto(x: float, y: float) -> None: ... -def home() -> None: ... -def setx(x: float) -> None: ... -def sety(y: float) -> None: ... -@overload -def distance(x: TNavigator | tuple[float, float], y: None = ...) -> float: ... -@overload -def distance(x: float, y: float) -> float: ... -@overload -def towards(x: TNavigator | tuple[float, float], y: None = ...) -> float: ... -@overload -def towards(x: float, y: float) -> float: ... -def heading() -> float: ... -def setheading(to_angle: float) -> None: ... -def circle(radius: float, extent: float | None = ..., steps: int | None = ...) -> None: ... - -fd = forward -bk = back -backward = back -rt = right -lt = left -position = pos -setpos = goto -setposition = goto -seth = setheading - -# Functions copied from TPen: -@overload -def resizemode(rmode: None = ...) -> str: ... -@overload -def resizemode(rmode: str) -> None: ... -@overload -def pensize(width: None = ...) -> int: ... -@overload -def pensize(width: int) -> None: ... -def penup() -> None: ... -def pendown() -> None: ... -def isdown() -> bool: ... -@overload -def speed(speed: None = ...) -> int: ... -@overload -def speed(speed: _Speed) -> None: ... -@overload -def pencolor() -> _AnyColor: ... -@overload -def pencolor(color: _Color) -> None: ... -@overload -def pencolor(r: float, g: float, b: float) -> None: ... -@overload -def fillcolor() -> _AnyColor: ... -@overload -def fillcolor(color: _Color) -> None: ... -@overload -def fillcolor(r: float, g: float, b: float) -> None: ... -@overload -def color() -> tuple[_AnyColor, _AnyColor]: ... -@overload -def color(color: _Color) -> None: ... -@overload -def color(r: float, g: float, b: float) -> None: ... -@overload -def color(color1: _Color, color2: _Color) -> None: ... -def showturtle() -> None: ... -def hideturtle() -> None: ... -def isvisible() -> bool: ... - -# Note: signatures 1 and 2 overlap unsafely when no arguments are provided -@overload -def pen() -> _PenState: ... # type: ignore[misc] -@overload -def pen( - pen: _PenState | None = ..., - *, - shown: bool = ..., - pendown: bool = ..., - pencolor: _Color = ..., - fillcolor: _Color = ..., - pensize: int = ..., - speed: int = ..., - resizemode: str = ..., - stretchfactor: tuple[float, float] = ..., - outline: int = ..., - tilt: float = ..., -) -> None: ... - -width = pensize -up = penup -pu = penup -pd = pendown -down = pendown -st = showturtle -ht = hideturtle - -# Functions copied from RawTurtle: - -def setundobuffer(size: int | None) -> None: ... -def undobufferentries() -> int: ... -@overload -def shape(name: None = ...) -> str: ... -@overload -def shape(name: str) -> None: ... - -# Unsafely overlaps when no arguments are provided -@overload -def shapesize() -> tuple[float, float, float]: ... # type: ignore[misc] -@overload -def shapesize(stretch_wid: float | None = ..., stretch_len: float | None = ..., outline: float | None = ...) -> None: ... -def settiltangle(angle: float) -> None: ... -@overload -def tiltangle(angle: None = ...) -> float: ... -@overload -def tiltangle(angle: float) -> None: ... -def tilt(angle: float) -> None: ... - -# Can return either 'int' or Tuple[int, ...] based on if the stamp is -# a compound stamp or not. So, as per the "no Union return" policy, -# we return Any. -def stamp() -> Any: ... -def clearstamp(stampid: int | tuple[int, ...]) -> None: ... -def clearstamps(n: int | None = ...) -> None: ... -def filling() -> bool: ... -def begin_fill() -> None: ... -def end_fill() -> None: ... -def dot(size: int | None = ..., *color: _Color) -> None: ... -def write(arg: object, move: bool = ..., align: str = ..., font: tuple[str, int, str] = ...) -> None: ... -def begin_poly() -> None: ... -def end_poly() -> None: ... -def get_poly() -> _PolygonCoords | None: ... -def getscreen() -> TurtleScreen: ... -def getturtle() -> Turtle: ... - -getpen = getturtle - -def onrelease(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... -def ondrag(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... -def undo() -> None: ... - -turtlesize = shapesize - -# Functions copied from RawTurtle with a few tweaks: - -def clone() -> Turtle: ... - -# Extra functions present only in the global scope: - -done = mainloop diff --git a/mypy/typeshed/stdlib/@python2/types.pyi b/mypy/typeshed/stdlib/@python2/types.pyi deleted file mode 100644 index d2194296aa17..000000000000 --- a/mypy/typeshed/stdlib/@python2/types.pyi +++ /dev/null @@ -1,193 +0,0 @@ -from typing import Any, Callable, Iterable, Iterator, TypeVar, overload - -_T = TypeVar("_T") - -# Note, all classes "defined" here require special handling. - -class NoneType: ... - -TypeType = type -ObjectType = object - -IntType = int -LongType = int # Really long, but can't reference that due to a mypy import cycle -FloatType = float -BooleanType = bool -ComplexType = complex -StringType = str -UnicodeType = unicode -StringTypes: tuple[type[StringType], type[UnicodeType]] -BufferType = buffer -TupleType = tuple -ListType = list -DictType = dict -DictionaryType = dict - -class _Cell: - cell_contents: Any - -class FunctionType: - func_closure: tuple[_Cell, ...] | None = ... - func_code: CodeType = ... - func_defaults: tuple[Any, ...] | None = ... - func_dict: dict[str, Any] = ... - func_doc: str | None = ... - func_globals: dict[str, Any] = ... - func_name: str = ... - __closure__ = func_closure - __code__ = func_code - __defaults__ = func_defaults - __dict__ = func_dict - __globals__ = func_globals - __name__ = func_name - def __init__( - self, - code: CodeType, - globals: dict[str, Any], - name: str | None = ..., - argdefs: tuple[object, ...] | None = ..., - closure: tuple[_Cell, ...] | None = ..., - ) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, obj: object | None, type: type | None) -> UnboundMethodType: ... - -LambdaType = FunctionType - -class CodeType: - co_argcount: int - co_cellvars: tuple[str, ...] - co_code: str - co_consts: tuple[Any, ...] - co_filename: str - co_firstlineno: int - co_flags: int - co_freevars: tuple[str, ...] - co_lnotab: str - co_name: str - co_names: tuple[str, ...] - co_nlocals: int - co_stacksize: int - co_varnames: tuple[str, ...] - def __init__( - self, - argcount: int, - nlocals: int, - stacksize: int, - flags: int, - codestring: str, - constants: tuple[Any, ...], - names: tuple[str, ...], - varnames: tuple[str, ...], - filename: str, - name: str, - firstlineno: int, - lnotab: str, - freevars: tuple[str, ...] = ..., - cellvars: tuple[str, ...] = ..., - ) -> None: ... - -class GeneratorType: - gi_code: CodeType - gi_frame: FrameType - gi_running: int - def __iter__(self) -> GeneratorType: ... - def close(self) -> None: ... - def next(self) -> Any: ... - def send(self, __arg: Any) -> Any: ... - @overload - def throw(self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...) -> Any: ... - @overload - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Any: ... - -class ClassType: ... - -class UnboundMethodType: - im_class: type = ... - im_func: FunctionType = ... - im_self: object = ... - __name__: str - __func__ = im_func - __self__ = im_self - def __init__(self, func: Callable[..., Any], obj: object) -> None: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - -class InstanceType(object): ... - -MethodType = UnboundMethodType - -class BuiltinFunctionType: - __self__: object | None - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - -BuiltinMethodType = BuiltinFunctionType - -class ModuleType: - __doc__: str | None - __file__: str | None - __name__: str - __package__: str | None - __path__: Iterable[str] | None - __dict__: dict[str, Any] - def __init__(self, name: str, doc: str | None = ...) -> None: ... - -FileType = file -XRangeType = xrange - -class TracebackType: - tb_frame: FrameType - tb_lasti: int - tb_lineno: int - tb_next: TracebackType - -class FrameType: - f_back: FrameType - f_builtins: dict[str, Any] - f_code: CodeType - f_exc_type: None - f_exc_value: None - f_exc_traceback: None - f_globals: dict[str, Any] - f_lasti: int - f_lineno: int | None - f_locals: dict[str, Any] - f_restricted: bool - f_trace: Callable[[], None] - def clear(self) -> None: ... - -SliceType = slice - -class EllipsisType: ... - -class DictProxyType: - # TODO is it possible to have non-string keys? - # no __init__ - def copy(self) -> dict[Any, Any]: ... - def get(self, key: str, default: _T = ...) -> Any | _T: ... - def has_key(self, key: str) -> bool: ... - def items(self) -> list[tuple[str, Any]]: ... - def iteritems(self) -> Iterator[tuple[str, Any]]: ... - def iterkeys(self) -> Iterator[str]: ... - def itervalues(self) -> Iterator[Any]: ... - def keys(self) -> list[str]: ... - def values(self) -> list[Any]: ... - def __contains__(self, key: str) -> bool: ... - def __getitem__(self, key: str) -> Any: ... - def __iter__(self) -> Iterator[str]: ... - def __len__(self) -> int: ... - -class NotImplementedType: ... - -class GetSetDescriptorType: - __name__: str - __objclass__: type - def __get__(self, obj: Any, type: type = ...) -> Any: ... - def __set__(self, obj: Any) -> None: ... - def __delete__(self, obj: Any) -> None: ... - -# Same type on Jython, different on CPython and PyPy, unknown on IronPython. -class MemberDescriptorType: - __name__: str - __objclass__: type - def __get__(self, obj: Any, type: type = ...) -> Any: ... - def __set__(self, obj: Any) -> None: ... - def __delete__(self, obj: Any) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/typing.pyi b/mypy/typeshed/stdlib/@python2/typing.pyi deleted file mode 100644 index d1c9ae574e98..000000000000 --- a/mypy/typeshed/stdlib/@python2/typing.pyi +++ /dev/null @@ -1,493 +0,0 @@ -import collections # Needed by aliases like DefaultDict, see mypy issue 2986 -from _typeshed import Self -from abc import ABCMeta, abstractmethod -from types import CodeType, FrameType, TracebackType - -# Definitions of special type checking related constructs. Their definitions -# are not used, so their value does not matter. - -Any = object() - -class TypeVar: - __name__: str - __bound__: type[Any] | None - __constraints__: tuple[type[Any], ...] - __covariant__: bool - __contravariant__: bool - def __init__( - self, name: str, *constraints: type[Any], bound: type[Any] | None = ..., covariant: bool = ..., contravariant: bool = ... - ) -> None: ... - -_promote = object() - -# N.B. Keep this definition in sync with typing_extensions._SpecialForm -class _SpecialForm(object): - def __getitem__(self, typeargs: Any) -> object: ... - -# Unlike the vast majority module-level objects in stub files, -# these `_SpecialForm` objects in typing need the default value `= ...`, -# due to the fact that they are used elswhere in the same file. -# Otherwise, flake8 erroneously flags them as undefined. -# `_SpecialForm` objects in typing.py that are not used elswhere in the same file -# do not need the default value assignment. -Generic: _SpecialForm = ... -Protocol: _SpecialForm = ... -Callable: _SpecialForm = ... -Union: _SpecialForm = ... - -Optional: _SpecialForm -Tuple: _SpecialForm -Type: _SpecialForm -ClassVar: _SpecialForm -Final: _SpecialForm -_F = TypeVar("_F", bound=Callable[..., Any]) - -def final(f: _F) -> _F: ... -def overload(f: _F) -> _F: ... - -Literal: _SpecialForm -# TypedDict is a (non-subscriptable) special form. -TypedDict: object - -class GenericMeta(type): ... - -# Return type that indicates a function does not return. -# This type is equivalent to the None type, but the no-op Union is necessary to -# distinguish the None type from the None value. -NoReturn = Union[None] - -# These type variables are used by the container types. -_T = TypeVar("_T") -_KT = TypeVar("_KT") # Key type. -_VT = TypeVar("_VT") # Value type. -_T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers. -_V_co = TypeVar("_V_co", covariant=True) # Any type covariant containers. -_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers. -_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers. -_T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant. -_TC = TypeVar("_TC", bound=type[object]) - -def no_type_check(f: _F) -> _F: ... -def no_type_check_decorator(decorator: _F) -> _F: ... - -# Type aliases and type constructors - -class _Alias: - # Class for defining generic aliases for library types. - def __getitem__(self, typeargs: Any) -> Any: ... - -List = _Alias() -Dict = _Alias() -DefaultDict = _Alias() -Set = _Alias() -FrozenSet = _Alias() -Counter = _Alias() -Deque = _Alias() - -# Predefined type variables. -AnyStr = TypeVar("AnyStr", str, unicode) # noqa: Y001 - -# Abstract base classes. - -def runtime_checkable(cls: _TC) -> _TC: ... -@runtime_checkable -class SupportsInt(Protocol, metaclass=ABCMeta): - @abstractmethod - def __int__(self) -> int: ... - -@runtime_checkable -class SupportsFloat(Protocol, metaclass=ABCMeta): - @abstractmethod - def __float__(self) -> float: ... - -@runtime_checkable -class SupportsComplex(Protocol, metaclass=ABCMeta): - @abstractmethod - def __complex__(self) -> complex: ... - -@runtime_checkable -class SupportsAbs(Protocol[_T_co]): - @abstractmethod - def __abs__(self) -> _T_co: ... - -@runtime_checkable -class Reversible(Protocol[_T_co]): - @abstractmethod - def __reversed__(self) -> Iterator[_T_co]: ... - -@runtime_checkable -class Sized(Protocol, metaclass=ABCMeta): - @abstractmethod - def __len__(self) -> int: ... - -@runtime_checkable -class Hashable(Protocol, metaclass=ABCMeta): - # TODO: This is special, in that a subclass of a hashable class may not be hashable - # (for example, list vs. object). It's not obvious how to represent this. This class - # is currently mostly useless for static checking. - @abstractmethod - def __hash__(self) -> int: ... - -@runtime_checkable -class Iterable(Protocol[_T_co]): - @abstractmethod - def __iter__(self) -> Iterator[_T_co]: ... - -@runtime_checkable -class Iterator(Iterable[_T_co], Protocol[_T_co]): - @abstractmethod - def next(self) -> _T_co: ... - def __iter__(self) -> Iterator[_T_co]: ... - -class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): - @abstractmethod - def next(self) -> _T_co: ... - @abstractmethod - def send(self, __value: _T_contra) -> _T_co: ... - @overload - @abstractmethod - def throw( - self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> _T_co: ... - @overload - @abstractmethod - def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... - @abstractmethod - def close(self) -> None: ... - @property - def gi_code(self) -> CodeType: ... - @property - def gi_frame(self) -> FrameType: ... - @property - def gi_running(self) -> bool: ... - -@runtime_checkable -class Container(Protocol[_T_co]): - @abstractmethod - def __contains__(self, x: object) -> bool: ... - -class Sequence(Iterable[_T_co], Container[_T_co], Reversible[_T_co], Generic[_T_co]): - @overload - @abstractmethod - def __getitem__(self, i: int) -> _T_co: ... - @overload - @abstractmethod - def __getitem__(self, s: slice) -> Sequence[_T_co]: ... - # Mixin methods - def index(self, x: Any) -> int: ... - def count(self, x: Any) -> int: ... - def __contains__(self, x: object) -> bool: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __reversed__(self) -> Iterator[_T_co]: ... - # Implement Sized (but don't have it as a base class). - @abstractmethod - def __len__(self) -> int: ... - -class MutableSequence(Sequence[_T], Generic[_T]): - @abstractmethod - def insert(self, index: int, object: _T) -> None: ... - @overload - @abstractmethod - def __getitem__(self, i: int) -> _T: ... - @overload - @abstractmethod - def __getitem__(self, s: slice) -> MutableSequence[_T]: ... - @overload - @abstractmethod - def __setitem__(self, i: int, o: _T) -> None: ... - @overload - @abstractmethod - def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - @overload - @abstractmethod - def __delitem__(self, i: int) -> None: ... - @overload - @abstractmethod - def __delitem__(self, i: slice) -> None: ... - # Mixin methods - def append(self, object: _T) -> None: ... - def extend(self, iterable: Iterable[_T]) -> None: ... - def reverse(self) -> None: ... - def pop(self, index: int = ...) -> _T: ... - def remove(self, object: _T) -> None: ... - def __iadd__(self: Self, x: Iterable[_T]) -> Self: ... - -class AbstractSet(Iterable[_T_co], Container[_T_co], Generic[_T_co]): - @abstractmethod - def __contains__(self, x: object) -> bool: ... - # Mixin methods - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __and__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __or__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... - def __sub__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ... - # TODO: argument can be any container? - def isdisjoint(self, s: AbstractSet[Any]) -> bool: ... - # Implement Sized (but don't have it as a base class). - @abstractmethod - def __len__(self) -> int: ... - -class MutableSet(AbstractSet[_T], Generic[_T]): - @abstractmethod - def add(self, x: _T) -> None: ... - @abstractmethod - def discard(self, x: _T) -> None: ... - # Mixin methods - def clear(self) -> None: ... - def pop(self) -> _T: ... - def remove(self, element: _T) -> None: ... - def __ior__(self: Self, s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - def __iand__(self: Self, s: AbstractSet[Any]) -> Self: ... - def __ixor__(self: Self, s: AbstractSet[_T]) -> Self: ... # type: ignore[override,misc] - def __isub__(self: Self, s: AbstractSet[Any]) -> Self: ... - -class MappingView(object): - def __len__(self) -> int: ... - -class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]): - def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ... - -class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): - def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_KT_co]: ... - -class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): - def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_VT_co]: ... - -@runtime_checkable -class ContextManager(Protocol[_T_co]): - def __enter__(self) -> _T_co: ... - def __exit__( - self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None - ) -> bool | None: ... - -class Mapping(Iterable[_KT], Container[_KT], Generic[_KT, _VT_co]): - # TODO: We wish the key type could also be covariant, but that doesn't work, - # see discussion in https: //github.com/python/typing/pull/273. - @abstractmethod - def __getitem__(self, k: _KT) -> _VT_co: ... - # Mixin methods - @overload - def get(self, k: _KT) -> _VT_co | None: ... - @overload - def get(self, k: _KT, default: _VT_co | _T) -> _VT_co | _T: ... - def keys(self) -> list[_KT]: ... - def values(self) -> list[_VT_co]: ... - def items(self) -> list[tuple[_KT, _VT_co]]: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT_co]: ... - def iteritems(self) -> Iterator[tuple[_KT, _VT_co]]: ... - def __contains__(self, o: object) -> bool: ... - # Implement Sized (but don't have it as a base class). - @abstractmethod - def __len__(self) -> int: ... - -class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): - @abstractmethod - def __setitem__(self, k: _KT, v: _VT) -> None: ... - @abstractmethod - def __delitem__(self, v: _KT) -> None: ... - def clear(self) -> None: ... - @overload - def pop(self, k: _KT) -> _VT: ... - @overload - def pop(self, k: _KT, default: _VT | _T = ...) -> _VT | _T: ... - def popitem(self) -> tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... - @overload - def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - @overload - def update(self, **kwargs: _VT) -> None: ... - -Text = unicode - -TYPE_CHECKING: bool - -class IO(Iterator[AnyStr], Generic[AnyStr]): - # TODO detach - # TODO use abstract properties - @property - def mode(self) -> str: ... - @property - def name(self) -> str: ... - @abstractmethod - def close(self) -> None: ... - @property - def closed(self) -> bool: ... - @abstractmethod - def fileno(self) -> int: ... - @abstractmethod - def flush(self) -> None: ... - @abstractmethod - def isatty(self) -> bool: ... - # TODO what if n is None? - @abstractmethod - def read(self, n: int = ...) -> AnyStr: ... - @abstractmethod - def readable(self) -> bool: ... - @abstractmethod - def readline(self, limit: int = ...) -> AnyStr: ... - @abstractmethod - def readlines(self, hint: int = ...) -> list[AnyStr]: ... - @abstractmethod - def seek(self, offset: int, whence: int = ...) -> int: ... - @abstractmethod - def seekable(self) -> bool: ... - @abstractmethod - def tell(self) -> int: ... - @abstractmethod - def truncate(self, size: int | None = ...) -> int: ... - @abstractmethod - def writable(self) -> bool: ... - # TODO buffer objects - @abstractmethod - def write(self, s: AnyStr) -> int: ... - @abstractmethod - def writelines(self, lines: Iterable[AnyStr]) -> None: ... - @abstractmethod - def next(self) -> AnyStr: ... - @abstractmethod - def __iter__(self) -> Iterator[AnyStr]: ... - @abstractmethod - def __enter__(self) -> IO[AnyStr]: ... - @abstractmethod - def __exit__( - self, t: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... - -class BinaryIO(IO[str]): - # TODO readinto - # TODO read1? - # TODO peek? - @abstractmethod - def __enter__(self) -> BinaryIO: ... - -class TextIO(IO[unicode]): - # TODO use abstractproperty - @property - def buffer(self) -> BinaryIO: ... - @property - def encoding(self) -> str: ... - @property - def errors(self) -> str | None: ... - @property - def line_buffering(self) -> bool: ... - @property - def newlines(self) -> Any: ... # None, str or tuple - @abstractmethod - def __enter__(self) -> TextIO: ... - -class ByteString(Sequence[int], metaclass=ABCMeta): ... - -class Match(Generic[AnyStr]): - pos: int - endpos: int - lastindex: int | None - string: AnyStr - - # The regular expression object whose match() or search() method produced - # this match instance. This should not be Pattern[AnyStr] because the type - # of the pattern is independent of the type of the matched string in - # Python 2. Strictly speaking Match should be generic over AnyStr twice: - # once for the type of the pattern and once for the type of the matched - # string. - re: Pattern[Any] - # Can be None if there are no groups or if the last group was unnamed; - # otherwise matches the type of the pattern. - lastgroup: Any | None - def expand(self, template: str | Text) -> Any: ... - @overload - def group(self, group1: int = ...) -> AnyStr: ... - @overload - def group(self, group1: str) -> AnyStr: ... - @overload - def group(self, group1: int, group2: int, *groups: int) -> tuple[AnyStr, ...]: ... - @overload - def group(self, group1: str, group2: str, *groups: str) -> tuple[AnyStr, ...]: ... - def groups(self, default: AnyStr = ...) -> tuple[AnyStr, ...]: ... - def groupdict(self, default: AnyStr = ...) -> Dict[str, AnyStr]: ... - def start(self, __group: int | str = ...) -> int: ... - def end(self, __group: int | str = ...) -> int: ... - def span(self, __group: int | str = ...) -> tuple[int, int]: ... - @property - def regs(self) -> tuple[tuple[int, int], ...]: ... # undocumented - -# We need a second TypeVar with the same definition as AnyStr, because -# Pattern is generic over AnyStr (determining the type of its .pattern -# attribute), but at the same time its methods take either bytes or -# Text and return the same type, regardless of the type of the pattern. -_AnyStr2 = TypeVar("_AnyStr2", bytes, Text) - -class Pattern(Generic[AnyStr]): - flags: int - groupindex: Dict[AnyStr, int] - groups: int - pattern: AnyStr - def search(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Match[_AnyStr2] | None: ... - def match(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Match[_AnyStr2] | None: ... - def split(self, string: _AnyStr2, maxsplit: int = ...) -> List[_AnyStr2]: ... - # Returns either a list of _AnyStr2 or a list of tuples, depending on - # whether there are groups in the pattern. - def findall(self, string: bytes | Text, pos: int = ..., endpos: int = ...) -> List[Any]: ... - def finditer(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Iterator[Match[_AnyStr2]]: ... - @overload - def sub(self, repl: _AnyStr2, string: _AnyStr2, count: int = ...) -> _AnyStr2: ... - @overload - def sub(self, repl: Callable[[Match[_AnyStr2]], _AnyStr2], string: _AnyStr2, count: int = ...) -> _AnyStr2: ... - @overload - def subn(self, repl: _AnyStr2, string: _AnyStr2, count: int = ...) -> tuple[_AnyStr2, int]: ... - @overload - def subn(self, repl: Callable[[Match[_AnyStr2]], _AnyStr2], string: _AnyStr2, count: int = ...) -> tuple[_AnyStr2, int]: ... - -# Functions - -def get_type_hints( - obj: Callable[..., Any], globalns: Dict[Text, Any] | None = ..., localns: Dict[Text, Any] | None = ... -) -> None: ... -@overload -def cast(tp: type[_T], obj: Any) -> _T: ... -@overload -def cast(tp: str, obj: Any) -> Any: ... -@overload -def cast(tp: object, obj: Any) -> Any: ... - -# Type constructors - -# NamedTuple is special-cased in the type checker -class NamedTuple(tuple[Any, ...]): - _fields: tuple[str, ...] - def __init__(self, typename: Text, fields: Iterable[tuple[Text, Any]] = ..., **kwargs: Any) -> None: ... - @classmethod - def _make(cls: type[Self], iterable: Iterable[Any]) -> Self: ... - def _asdict(self) -> Dict[str, Any]: ... - def _replace(self: Self, **kwargs: Any) -> Self: ... - -# Internal mypy fallback type for all typed dicts (does not exist at runtime) -class _TypedDict(Mapping[str, object], metaclass=ABCMeta): - def copy(self: Self) -> Self: ... - # Using NoReturn so that only calls using mypy plugin hook that specialize the signature - # can go through. - def setdefault(self, k: NoReturn, default: object) -> object: ... - # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. - def pop(self, k: NoReturn, default: _T = ...) -> object: ... - def update(self: _T, __m: _T) -> None: ... - def has_key(self, k: str) -> bool: ... - def viewitems(self) -> ItemsView[str, object]: ... - def viewkeys(self) -> KeysView[str]: ... - def viewvalues(self) -> ValuesView[object]: ... - def __delitem__(self, k: NoReturn) -> None: ... - -def NewType(name: str, tp: type[_T]) -> type[_T]: ... - -# This itself is only available during type checking -def type_check_only(func_or_cls: _F) -> _F: ... diff --git a/mypy/typeshed/stdlib/@python2/typing_extensions.pyi b/mypy/typeshed/stdlib/@python2/typing_extensions.pyi deleted file mode 100644 index 62ef6f7b787c..000000000000 --- a/mypy/typeshed/stdlib/@python2/typing_extensions.pyi +++ /dev/null @@ -1,102 +0,0 @@ -import abc -from _typeshed import Self -from typing import ( # noqa: Y022 - TYPE_CHECKING as TYPE_CHECKING, - Any, - Callable, - ClassVar as ClassVar, - ContextManager as ContextManager, - Counter as Counter, - DefaultDict as DefaultDict, - Deque as Deque, - ItemsView, - KeysView, - Mapping, - NewType as NewType, - NoReturn as NoReturn, - Protocol as Protocol, - Text as Text, - Type as Type, - TypeVar, - ValuesView, - _Alias, - overload as overload, - runtime_checkable as runtime_checkable, -) - -_T = TypeVar("_T") -_F = TypeVar("_F", bound=Callable[..., Any]) - -# unfortunately we have to duplicate this class definition from typing.pyi or we break pytype -class _SpecialForm: - def __getitem__(self, typeargs: Any) -> object: ... - -# This alias for above is kept here for backwards compatibility. -runtime = runtime_checkable -Final: _SpecialForm - -def final(f: _F) -> _F: ... - -Literal: _SpecialForm - -def IntVar(name: str) -> Any: ... # returns a new TypeVar - -# Internal mypy fallback type for all typed dicts (does not exist at runtime) -class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): - def copy(self: Self) -> Self: ... - # Using NoReturn so that only calls using mypy plugin hook that specialize the signature - # can go through. - def setdefault(self, k: NoReturn, default: object) -> object: ... - def pop(self, k: NoReturn, default: _T = ...) -> object: ... - def update(self: _T, __m: _T) -> None: ... - def has_key(self, k: str) -> bool: ... - def viewitems(self) -> ItemsView[str, object]: ... - def viewkeys(self) -> KeysView[str]: ... - def viewvalues(self) -> ValuesView[object]: ... - def __delitem__(self, k: NoReturn) -> None: ... - -# TypedDict is a (non-subscriptable) special form. -TypedDict: object - -OrderedDict = _Alias() - -def get_type_hints( - obj: Callable[..., Any], - globalns: dict[str, Any] | None = ..., - localns: dict[str, Any] | None = ..., - include_extras: bool = ..., -) -> dict[str, Any]: ... - -Annotated: _SpecialForm -_AnnotatedAlias: Any # undocumented - -@runtime_checkable -class SupportsIndex(Protocol, metaclass=abc.ABCMeta): - @abc.abstractmethod - def __index__(self) -> int: ... - -# PEP 612 support for Python < 3.9 -class ParamSpecArgs: - __origin__: ParamSpec - def __init__(self, origin: ParamSpec) -> None: ... - -class ParamSpecKwargs: - __origin__: ParamSpec - def __init__(self, origin: ParamSpec) -> None: ... - -class ParamSpec: - __name__: str - __bound__: type[Any] | None - __covariant__: bool - __contravariant__: bool - def __init__( - self, name: str, *, bound: None | type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ... - ) -> None: ... - @property - def args(self) -> ParamSpecArgs: ... - @property - def kwargs(self) -> ParamSpecKwargs: ... - -Concatenate: _SpecialForm -TypeAlias: _SpecialForm -TypeGuard: _SpecialForm diff --git a/mypy/typeshed/stdlib/@python2/unicodedata.pyi b/mypy/typeshed/stdlib/@python2/unicodedata.pyi deleted file mode 100644 index f4ca655e5c7e..000000000000 --- a/mypy/typeshed/stdlib/@python2/unicodedata.pyi +++ /dev/null @@ -1,37 +0,0 @@ -from typing import Any, Text, TypeVar - -ucd_3_2_0: UCD -ucnhash_CAPI: Any -unidata_version: str - -_T = TypeVar("_T") - -def bidirectional(__chr: Text) -> Text: ... -def category(__chr: Text) -> Text: ... -def combining(__chr: Text) -> int: ... -def decimal(__chr: Text, __default: _T = ...) -> int | _T: ... -def decomposition(__chr: Text) -> Text: ... -def digit(__chr: Text, __default: _T = ...) -> int | _T: ... -def east_asian_width(__chr: Text) -> Text: ... -def lookup(__name: Text | bytes) -> Text: ... -def mirrored(__chr: Text) -> int: ... -def name(__chr: Text, __default: _T = ...) -> Text | _T: ... -def normalize(__form: Text, __unistr: Text) -> Text: ... -def numeric(__chr: Text, __default: _T = ...) -> float | _T: ... - -class UCD(object): - # The methods below are constructed from the same array in C - # (unicodedata_functions) and hence identical to the methods above. - unidata_version: str - def bidirectional(self, __chr: Text) -> str: ... - def category(self, __chr: Text) -> str: ... - def combining(self, __chr: Text) -> int: ... - def decimal(self, __chr: Text, __default: _T = ...) -> int | _T: ... - def decomposition(self, __chr: Text) -> str: ... - def digit(self, __chr: Text, __default: _T = ...) -> int | _T: ... - def east_asian_width(self, __chr: Text) -> str: ... - def lookup(self, __name: Text | bytes) -> Text: ... - def mirrored(self, __chr: Text) -> int: ... - def name(self, __chr: Text, __default: _T = ...) -> Text | _T: ... - def normalize(self, __form: Text, __unistr: Text) -> Text: ... - def numeric(self, __chr: Text, __default: _T = ...) -> float | _T: ... diff --git a/mypy/typeshed/stdlib/@python2/unittest.pyi b/mypy/typeshed/stdlib/@python2/unittest.pyi deleted file mode 100644 index 887e7055207d..000000000000 --- a/mypy/typeshed/stdlib/@python2/unittest.pyi +++ /dev/null @@ -1,260 +0,0 @@ -import datetime -import types -from _typeshed import Self -from abc import ABCMeta, abstractmethod -from typing import Any, Callable, Iterable, Iterator, Mapping, NoReturn, Pattern, Sequence, Text, TextIO, TypeVar, Union, overload -from typing_extensions import ParamSpec - -_T = TypeVar("_T") -_FT = TypeVar("_FT") -_P = ParamSpec("_P") - -_ExceptionType = Union[type[BaseException], tuple[type[BaseException], ...]] -_Regexp = Text | Pattern[Text] - -_SysExcInfoType = Union[tuple[type[BaseException], BaseException, types.TracebackType], tuple[None, None, None]] - -class Testable(metaclass=ABCMeta): - @abstractmethod - def run(self, result: TestResult) -> None: ... - @abstractmethod - def debug(self) -> None: ... - @abstractmethod - def countTestCases(self) -> int: ... - -# TODO ABC for test runners? - -class TestResult: - errors: list[tuple[TestCase, str]] - failures: list[tuple[TestCase, str]] - skipped: list[tuple[TestCase, str]] - expectedFailures: list[tuple[TestCase, str]] - unexpectedSuccesses: list[TestCase] - shouldStop: bool - testsRun: int - buffer: bool - failfast: bool - def wasSuccessful(self) -> bool: ... - def stop(self) -> None: ... - def startTest(self, test: TestCase) -> None: ... - def stopTest(self, test: TestCase) -> None: ... - def startTestRun(self) -> None: ... - def stopTestRun(self) -> None: ... - def addError(self, test: TestCase, err: _SysExcInfoType) -> None: ... - def addFailure(self, test: TestCase, err: _SysExcInfoType) -> None: ... - def addSuccess(self, test: TestCase) -> None: ... - def addSkip(self, test: TestCase, reason: str) -> None: ... - def addExpectedFailure(self, test: TestCase, err: str) -> None: ... - def addUnexpectedSuccess(self, test: TestCase) -> None: ... - -class _AssertRaisesBaseContext: - expected: Any - failureException: type[BaseException] - obj_name: str - expected_regex: Pattern[str] - -class _AssertRaisesContext(_AssertRaisesBaseContext): - exception: Any - def __enter__(self: Self) -> Self: ... - def __exit__(self, exc_type, exc_value, tb) -> bool: ... - -class TestCase(Testable): - failureException: type[BaseException] - longMessage: bool - maxDiff: int | None - # undocumented - _testMethodName: str - def __init__(self, methodName: str = ...) -> None: ... - def setUp(self) -> None: ... - def tearDown(self) -> None: ... - @classmethod - def setUpClass(cls) -> None: ... - @classmethod - def tearDownClass(cls) -> None: ... - def run(self, result: TestResult = ...) -> None: ... - def debug(self) -> None: ... - def assert_(self, expr: Any, msg: object = ...) -> None: ... - def failUnless(self, expr: Any, msg: object = ...) -> None: ... - def assertTrue(self, expr: Any, msg: object = ...) -> None: ... - def assertEqual(self, first: Any, second: Any, msg: object = ...) -> None: ... - def assertEquals(self, first: Any, second: Any, msg: object = ...) -> None: ... - def failUnlessEqual(self, first: Any, second: Any, msg: object = ...) -> None: ... - def assertNotEqual(self, first: Any, second: Any, msg: object = ...) -> None: ... - def assertNotEquals(self, first: Any, second: Any, msg: object = ...) -> None: ... - def failIfEqual(self, first: Any, second: Any, msg: object = ...) -> None: ... - @overload - def assertAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... - @overload - def assertAlmostEqual(self, first: float, second: float, *, msg: Any = ..., delta: float = ...) -> None: ... - @overload - def assertAlmostEqual( - self, first: datetime.datetime, second: datetime.datetime, *, msg: Any = ..., delta: datetime.timedelta = ... - ) -> None: ... - @overload - def assertAlmostEquals(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... - @overload - def assertAlmostEquals(self, first: float, second: float, *, msg: Any = ..., delta: float = ...) -> None: ... - @overload - def assertAlmostEquals( - self, first: datetime.datetime, second: datetime.datetime, *, msg: Any = ..., delta: datetime.timedelta = ... - ) -> None: ... - def failUnlessAlmostEqual(self, first: float, second: float, places: int = ..., msg: object = ...) -> None: ... - @overload - def assertNotAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... - @overload - def assertNotAlmostEqual(self, first: float, second: float, *, msg: Any = ..., delta: float = ...) -> None: ... - @overload - def assertNotAlmostEqual( - self, first: datetime.datetime, second: datetime.datetime, *, msg: Any = ..., delta: datetime.timedelta = ... - ) -> None: ... - @overload - def assertNotAlmostEquals(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... - @overload - def assertNotAlmostEquals(self, first: float, second: float, *, msg: Any = ..., delta: float = ...) -> None: ... - @overload - def assertNotAlmostEquals( - self, first: datetime.datetime, second: datetime.datetime, *, msg: Any = ..., delta: datetime.timedelta = ... - ) -> None: ... - def failIfAlmostEqual( - self, first: float, second: float, places: int = ..., msg: object = ..., delta: float = ... - ) -> None: ... - def assertGreater(self, first: Any, second: Any, msg: object = ...) -> None: ... - def assertGreaterEqual(self, first: Any, second: Any, msg: object = ...) -> None: ... - def assertMultiLineEqual(self, first: str, second: str, msg: object = ...) -> None: ... - def assertSequenceEqual( - self, first: Sequence[Any], second: Sequence[Any], msg: object = ..., seq_type: type = ... - ) -> None: ... - def assertListEqual(self, first: list[Any], second: list[Any], msg: object = ...) -> None: ... - def assertTupleEqual(self, first: tuple[Any, ...], second: tuple[Any, ...], msg: object = ...) -> None: ... - def assertSetEqual(self, first: set[Any] | frozenset[Any], second: set[Any] | frozenset[Any], msg: object = ...) -> None: ... - def assertDictEqual(self, first: dict[Any, Any], second: dict[Any, Any], msg: object = ...) -> None: ... - def assertLess(self, first: Any, second: Any, msg: object = ...) -> None: ... - def assertLessEqual(self, first: Any, second: Any, msg: object = ...) -> None: ... - @overload - def assertRaises(self, exception: _ExceptionType, callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - @overload - def assertRaises(self, exception: _ExceptionType) -> _AssertRaisesContext: ... - @overload - def assertRaisesRegexp( - self, exception: _ExceptionType, regexp: _Regexp, callable: Callable[..., Any], *args: Any, **kwargs: Any - ) -> None: ... - @overload - def assertRaisesRegexp(self, exception: _ExceptionType, regexp: _Regexp) -> _AssertRaisesContext: ... - def assertRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ... - def assertNotRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ... - def assertItemsEqual(self, first: Iterable[Any], second: Iterable[Any], msg: object = ...) -> None: ... - def assertDictContainsSubset(self, expected: Mapping[Any, Any], actual: Mapping[Any, Any], msg: object = ...) -> None: ... - def addTypeEqualityFunc(self, typeobj: type, function: Callable[..., None]) -> None: ... - @overload - def failUnlessRaises(self, exception: _ExceptionType, callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - @overload - def failUnlessRaises(self, exception: _ExceptionType) -> _AssertRaisesContext: ... - def failIf(self, expr: Any, msg: object = ...) -> None: ... - def assertFalse(self, expr: Any, msg: object = ...) -> None: ... - def assertIs(self, first: object, second: object, msg: object = ...) -> None: ... - def assertIsNot(self, first: object, second: object, msg: object = ...) -> None: ... - def assertIsNone(self, expr: Any, msg: object = ...) -> None: ... - def assertIsNotNone(self, expr: Any, msg: object = ...) -> None: ... - def assertIn(self, first: _T, second: Iterable[_T], msg: object = ...) -> None: ... - def assertNotIn(self, first: _T, second: Iterable[_T], msg: object = ...) -> None: ... - def assertIsInstance(self, obj: Any, cls: type | tuple[type, ...], msg: object = ...) -> None: ... - def assertNotIsInstance(self, obj: Any, cls: type | tuple[type, ...], msg: object = ...) -> None: ... - def fail(self, msg: object = ...) -> NoReturn: ... - def countTestCases(self) -> int: ... - def defaultTestResult(self) -> TestResult: ... - def id(self) -> str: ... - def shortDescription(self) -> str: ... # May return None - def addCleanup(self, function: Any, *args: Any, **kwargs: Any) -> None: ... - def doCleanups(self) -> bool: ... - def skipTest(self, reason: Any) -> None: ... - def _formatMessage(self, msg: Text | None, standardMsg: Text) -> str: ... # undocumented - def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented - -class FunctionTestCase(TestCase): - def __init__( - self, - testFunc: Callable[[], None], - setUp: Callable[[], None] | None = ..., - tearDown: Callable[[], None] | None = ..., - description: str | None = ..., - ) -> None: ... - def debug(self) -> None: ... - def countTestCases(self) -> int: ... - -class TestSuite(Testable): - def __init__(self, tests: Iterable[Testable] = ...) -> None: ... - def addTest(self, test: Testable) -> None: ... - def addTests(self, tests: Iterable[Testable]) -> None: ... - def run(self, result: TestResult) -> None: ... - def debug(self) -> None: ... - def countTestCases(self) -> int: ... - def __iter__(self) -> Iterator[Testable]: ... - -class TestLoader: - testMethodPrefix: str - sortTestMethodsUsing: Callable[[str, str], int] | None - suiteClass: Callable[[list[TestCase]], TestSuite] - def loadTestsFromTestCase(self, testCaseClass: type[TestCase]) -> TestSuite: ... - def loadTestsFromModule(self, module: types.ModuleType = ..., use_load_tests: bool = ...) -> TestSuite: ... - def loadTestsFromName(self, name: str = ..., module: types.ModuleType | None = ...) -> TestSuite: ... - def loadTestsFromNames(self, names: list[str] = ..., module: types.ModuleType | None = ...) -> TestSuite: ... - def discover(self, start_dir: str, pattern: str = ..., top_level_dir: str | None = ...) -> TestSuite: ... - def getTestCaseNames(self, testCaseClass: type[TestCase] = ...) -> list[str]: ... - -defaultTestLoader: TestLoader - -class TextTestResult(TestResult): - def __init__(self, stream: TextIO, descriptions: bool, verbosity: int) -> None: ... - def getDescription(self, test: TestCase) -> str: ... # undocumented - def printErrors(self) -> None: ... # undocumented - def printErrorList(self, flavour: str, errors: list[tuple[TestCase, str]]) -> None: ... # undocumented - -class TextTestRunner: - def __init__( - self, - stream: TextIO | None = ..., - descriptions: bool = ..., - verbosity: int = ..., - failfast: bool = ..., - buffer: bool = ..., - resultclass: type[TestResult] | None = ..., - ) -> None: ... - def _makeResult(self) -> TestResult: ... - def run(self, test: Testable) -> TestResult: ... # undocumented - -class SkipTest(Exception): ... - -# TODO precise types -def skipUnless(condition: Any, reason: str | unicode) -> Any: ... -def skipIf(condition: Any, reason: str | unicode) -> Any: ... -def expectedFailure(func: _FT) -> _FT: ... -def skip(reason: str | unicode) -> Any: ... - -# not really documented -class TestProgram: - result: TestResult - def runTests(self) -> None: ... # undocumented - -def main( - module: None | Text | types.ModuleType = ..., - defaultTest: str | None = ..., - argv: Sequence[str] | None = ..., - testRunner: type[TextTestRunner] | TextTestRunner | None = ..., - testLoader: TestLoader = ..., - exit: bool = ..., - verbosity: int = ..., - failfast: bool | None = ..., - catchbreak: bool | None = ..., - buffer: bool | None = ..., -) -> TestProgram: ... -def load_tests(loader: TestLoader, tests: TestSuite, pattern: Text | None) -> TestSuite: ... -def installHandler() -> None: ... -def registerResult(result: TestResult) -> None: ... -def removeResult(result: TestResult) -> bool: ... -@overload -def removeHandler() -> None: ... -@overload -def removeHandler(function: Callable[_P, _T]) -> Callable[_P, _T]: ... - -# private but occasionally used -util: types.ModuleType diff --git a/mypy/typeshed/stdlib/@python2/urllib.pyi b/mypy/typeshed/stdlib/@python2/urllib.pyi deleted file mode 100644 index 56a75af74bb3..000000000000 --- a/mypy/typeshed/stdlib/@python2/urllib.pyi +++ /dev/null @@ -1,132 +0,0 @@ -from _typeshed import Self -from typing import IO, Any, AnyStr, Mapping, Sequence, Text - -def url2pathname(pathname: AnyStr) -> AnyStr: ... -def pathname2url(pathname: AnyStr) -> AnyStr: ... -def urlopen(url: str, data=..., proxies: Mapping[str, str] = ..., context=...) -> IO[Any]: ... -def urlretrieve(url, filename=..., reporthook=..., data=..., context=...): ... -def urlcleanup() -> None: ... - -class ContentTooShortError(IOError): - content: Any - def __init__(self, message, content) -> None: ... - -class URLopener: - version: Any - proxies: Any - key_file: Any - cert_file: Any - context: Any - addheaders: Any - tempcache: Any - ftpcache: Any - def __init__(self, proxies: Mapping[str, str] = ..., context=..., **x509) -> None: ... - def __del__(self): ... - def close(self): ... - def cleanup(self): ... - def addheader(self, *args): ... - type: Any - def open(self, fullurl: str, data=...): ... - def open_unknown(self, fullurl, data=...): ... - def open_unknown_proxy(self, proxy, fullurl, data=...): ... - def retrieve(self, url, filename=..., reporthook=..., data=...): ... - def open_http(self, url, data=...): ... - def http_error(self, url, fp, errcode, errmsg, headers, data=...): ... - def http_error_default(self, url, fp, errcode, errmsg, headers): ... - def open_https(self, url, data=...): ... - def open_file(self, url): ... - def open_local_file(self, url): ... - def open_ftp(self, url): ... - def open_data(self, url, data=...): ... - -class FancyURLopener(URLopener): - auth_cache: Any - tries: Any - maxtries: Any - def __init__(self, *args, **kwargs) -> None: ... - def http_error_default(self, url, fp, errcode, errmsg, headers): ... - def http_error_302(self, url, fp, errcode, errmsg, headers, data=...): ... - def redirect_internal(self, url, fp, errcode, errmsg, headers, data): ... - def http_error_301(self, url, fp, errcode, errmsg, headers, data=...): ... - def http_error_303(self, url, fp, errcode, errmsg, headers, data=...): ... - def http_error_307(self, url, fp, errcode, errmsg, headers, data=...): ... - def http_error_401(self, url, fp, errcode, errmsg, headers, data=...): ... - def http_error_407(self, url, fp, errcode, errmsg, headers, data=...): ... - def retry_proxy_http_basic_auth(self, url, realm, data=...): ... - def retry_proxy_https_basic_auth(self, url, realm, data=...): ... - def retry_http_basic_auth(self, url, realm, data=...): ... - def retry_https_basic_auth(self, url, realm, data=...): ... - def get_user_passwd(self, host, realm, clear_cache=...): ... - def prompt_user_passwd(self, host, realm): ... - -class ftpwrapper: - user: Any - passwd: Any - host: Any - port: Any - dirs: Any - timeout: Any - refcount: Any - keepalive: Any - def __init__(self, user, passwd, host, port, dirs, timeout=..., persistent=...) -> None: ... - busy: Any - ftp: Any - def init(self): ... - def retrfile(self, file, type): ... - def endtransfer(self): ... - def close(self): ... - def file_close(self): ... - def real_close(self): ... - -class addbase: - fp: Any - def read(self, n: int = ...) -> bytes: ... - def readline(self, limit: int = ...) -> bytes: ... - def readlines(self, hint: int = ...) -> list[bytes]: ... - def fileno(self) -> int: ... # Optional[int], but that is rare - def __iter__(self: Self) -> Self: ... - def next(self) -> bytes: ... - def __init__(self, fp) -> None: ... - def close(self) -> None: ... - -class addclosehook(addbase): - closehook: Any - hookargs: Any - def __init__(self, fp, closehook, *hookargs) -> None: ... - def close(self): ... - -class addinfo(addbase): - headers: Any - def __init__(self, fp, headers) -> None: ... - def info(self): ... - -class addinfourl(addbase): - headers: Any - url: Any - code: Any - def __init__(self, fp, headers, url, code=...) -> None: ... - def info(self): ... - def getcode(self): ... - def geturl(self): ... - -def unwrap(url): ... -def splittype(url): ... -def splithost(url): ... -def splituser(host): ... -def splitpasswd(user): ... -def splitport(host): ... -def splitnport(host, defport=...): ... -def splitquery(url): ... -def splittag(url): ... -def splitattr(url): ... -def splitvalue(attr): ... -def unquote(s: AnyStr) -> AnyStr: ... -def unquote_plus(s: AnyStr) -> AnyStr: ... -def quote(s: AnyStr, safe: Text = ...) -> AnyStr: ... -def quote_plus(s: AnyStr, safe: Text = ...) -> AnyStr: ... -def urlencode(query: Sequence[tuple[Any, Any]] | Mapping[Any, Any], doseq=...) -> str: ... -def getproxies() -> Mapping[str, str]: ... -def proxy_bypass(host: str) -> Any: ... # undocumented - -# Names in __all__ with no definition: -# basejoin diff --git a/mypy/typeshed/stdlib/@python2/urllib2.pyi b/mypy/typeshed/stdlib/@python2/urllib2.pyi deleted file mode 100644 index 1ea1bce28db1..000000000000 --- a/mypy/typeshed/stdlib/@python2/urllib2.pyi +++ /dev/null @@ -1,185 +0,0 @@ -import ssl -from httplib import HTTPConnectionProtocol, HTTPResponse -from typing import Any, AnyStr, Callable, Mapping, Sequence, Text -from urllib import addinfourl - -_string = str | unicode - -class URLError(IOError): - reason: str | BaseException - -class HTTPError(URLError, addinfourl): - code: int - headers: Mapping[str, str] - def __init__(self, url, code: int, msg: str, hdrs: Mapping[str, str], fp: addinfourl) -> None: ... - -class Request(object): - host: str - port: str - data: str - headers: dict[str, str] - unverifiable: bool - type: str | None - origin_req_host = ... - unredirected_hdrs: dict[str, str] - timeout: float | None # Undocumented, only set after __init__() by OpenerDirector.open() - def __init__( - self, - url: str, - data: str | None = ..., - headers: dict[str, str] = ..., - origin_req_host: str | None = ..., - unverifiable: bool = ..., - ) -> None: ... - def __getattr__(self, attr): ... - def get_method(self) -> str: ... - def add_data(self, data) -> None: ... - def has_data(self) -> bool: ... - def get_data(self) -> str: ... - def get_full_url(self) -> str: ... - def get_type(self): ... - def get_host(self) -> str: ... - def get_selector(self): ... - def set_proxy(self, host, type) -> None: ... - def has_proxy(self) -> bool: ... - def get_origin_req_host(self) -> str: ... - def is_unverifiable(self) -> bool: ... - def add_header(self, key: str, val: str) -> None: ... - def add_unredirected_header(self, key: str, val: str) -> None: ... - def has_header(self, header_name: str) -> bool: ... - def get_header(self, header_name: str, default: str | None = ...) -> str: ... - def header_items(self): ... - -class OpenerDirector(object): - addheaders: list[tuple[str, str]] - def add_handler(self, handler: BaseHandler) -> None: ... - def open(self, fullurl: Request | _string, data: _string | None = ..., timeout: float | None = ...) -> addinfourl | None: ... - def error(self, proto: _string, *args: Any): ... - -# Note that this type is somewhat a lie. The return *can* be None if -# a custom opener has been installed that fails to handle the request. -def urlopen( - url: Request | _string, - data: _string | None = ..., - timeout: float | None = ..., - cafile: _string | None = ..., - capath: _string | None = ..., - cadefault: bool = ..., - context: ssl.SSLContext | None = ..., -) -> addinfourl: ... -def install_opener(opener: OpenerDirector) -> None: ... -def build_opener(*handlers: BaseHandler | type[BaseHandler]) -> OpenerDirector: ... - -class BaseHandler: - handler_order: int - parent: OpenerDirector - def add_parent(self, parent: OpenerDirector) -> None: ... - def close(self) -> None: ... - def __lt__(self, other: Any) -> bool: ... - -class HTTPErrorProcessor(BaseHandler): - def http_response(self, request, response): ... - -class HTTPDefaultErrorHandler(BaseHandler): - def http_error_default(self, req: Request, fp: addinfourl, code: int, msg: str, hdrs: Mapping[str, str]): ... - -class HTTPRedirectHandler(BaseHandler): - max_repeats: int - max_redirections: int - def redirect_request(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str], newurl): ... - def http_error_301(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - def http_error_302(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - def http_error_303(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - def http_error_307(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - inf_msg: str - -class ProxyHandler(BaseHandler): - proxies: Mapping[str, str] - def __init__(self, proxies: Mapping[str, str] | None = ...): ... - def proxy_open(self, req: Request, proxy, type): ... - -class HTTPPasswordMgr: - def __init__(self) -> None: ... - def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... - def find_user_password(self, realm: Text | None, authuri: Text) -> tuple[Any, Any]: ... - def reduce_uri(self, uri: _string, default_port: bool = ...) -> tuple[Any, Any]: ... - def is_suburi(self, base: _string, test: _string) -> bool: ... - -class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): ... - -class AbstractBasicAuthHandler: - def __init__(self, password_mgr: HTTPPasswordMgr | None = ...) -> None: ... - def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... - def http_error_auth_reqed(self, authreq, host, req: Request, headers: Mapping[str, str]): ... - def retry_http_basic_auth(self, host, req: Request, realm): ... - -class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): - auth_header: str - def http_error_401(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - -class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): - auth_header: str - def http_error_407(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - -class AbstractDigestAuthHandler: - def __init__(self, passwd: HTTPPasswordMgr | None = ...) -> None: ... - def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... - def reset_retry_count(self) -> None: ... - def http_error_auth_reqed(self, auth_header: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ... - def retry_http_digest_auth(self, req: Request, auth: str) -> HTTPResponse | None: ... - def get_cnonce(self, nonce: str) -> str: ... - def get_authorization(self, req: Request, chal: Mapping[str, str]) -> str: ... - def get_algorithm_impls(self, algorithm: str) -> tuple[Callable[[str], str], Callable[[str, str], str]]: ... - def get_entity_digest(self, data: bytes | None, chal: Mapping[str, str]) -> str | None: ... - -class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): - auth_header: str - handler_order: int - def http_error_401(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - -class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): - auth_header: str - handler_order: int - def http_error_407(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... - -class AbstractHTTPHandler(BaseHandler): # undocumented - def __init__(self, debuglevel: int = ...) -> None: ... - def set_http_debuglevel(self, level: int) -> None: ... - def do_request_(self, request: Request) -> Request: ... - def do_open(self, http_class: HTTPConnectionProtocol, req: Request, **http_conn_args: Any | None) -> addinfourl: ... - -class HTTPHandler(AbstractHTTPHandler): - def http_open(self, req: Request) -> addinfourl: ... - def http_request(self, request: Request) -> Request: ... # undocumented - -class HTTPSHandler(AbstractHTTPHandler): - def __init__(self, debuglevel: int = ..., context: ssl.SSLContext | None = ...) -> None: ... - def https_open(self, req: Request) -> addinfourl: ... - def https_request(self, request: Request) -> Request: ... # undocumented - -class HTTPCookieProcessor(BaseHandler): - def __init__(self, cookiejar: Any | None = ...): ... - def http_request(self, request: Request): ... - def http_response(self, request: Request, response): ... - -class UnknownHandler(BaseHandler): - def unknown_open(self, req: Request): ... - -class FileHandler(BaseHandler): - def file_open(self, req: Request): ... - def get_names(self): ... - def open_local_file(self, req: Request): ... - -class FTPHandler(BaseHandler): - def ftp_open(self, req: Request): ... - def connect_ftp(self, user, passwd, host, port, dirs, timeout): ... - -class CacheFTPHandler(FTPHandler): - def __init__(self) -> None: ... - def setTimeout(self, t: float | None): ... - def setMaxConns(self, m: int): ... - def check_cache(self): ... - def clear_cache(self): ... - -def parse_http_list(s: AnyStr) -> list[AnyStr]: ... -def parse_keqv_list(l: list[AnyStr]) -> dict[AnyStr, AnyStr]: ... diff --git a/mypy/typeshed/stdlib/@python2/urlparse.pyi b/mypy/typeshed/stdlib/@python2/urlparse.pyi deleted file mode 100644 index 16c32753c7c5..000000000000 --- a/mypy/typeshed/stdlib/@python2/urlparse.pyi +++ /dev/null @@ -1,61 +0,0 @@ -from typing import AnyStr, NamedTuple, Sequence, overload - -_String = str | unicode - -uses_relative: list[str] -uses_netloc: list[str] -uses_params: list[str] -non_hierarchical: list[str] -uses_query: list[str] -uses_fragment: list[str] -scheme_chars: str -MAX_CACHE_SIZE: int - -def clear_cache() -> None: ... - -class ResultMixin(object): - @property - def username(self) -> str | None: ... - @property - def password(self) -> str | None: ... - @property - def hostname(self) -> str | None: ... - @property - def port(self) -> int | None: ... - -class _SplitResult(NamedTuple): - scheme: str - netloc: str - path: str - query: str - fragment: str - -class SplitResult(_SplitResult, ResultMixin): - def geturl(self) -> str: ... - -class _ParseResult(NamedTuple): - scheme: str - netloc: str - path: str - params: str - query: str - fragment: str - -class ParseResult(_ParseResult, ResultMixin): - def geturl(self) -> _String: ... - -def urlparse(url: _String, scheme: _String = ..., allow_fragments: bool = ...) -> ParseResult: ... -def urlsplit(url: _String, scheme: _String = ..., allow_fragments: bool = ...) -> SplitResult: ... -@overload -def urlunparse(data: tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ... -@overload -def urlunparse(data: Sequence[AnyStr]) -> AnyStr: ... -@overload -def urlunsplit(data: tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ... -@overload -def urlunsplit(data: Sequence[AnyStr]) -> AnyStr: ... -def urljoin(base: AnyStr, url: AnyStr, allow_fragments: bool = ...) -> AnyStr: ... -def urldefrag(url: AnyStr) -> tuple[AnyStr, AnyStr]: ... -def unquote(s: AnyStr) -> AnyStr: ... -def parse_qs(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> dict[AnyStr, list[AnyStr]]: ... -def parse_qsl(qs: AnyStr, keep_blank_values: int = ..., strict_parsing: bool = ...) -> list[tuple[AnyStr, AnyStr]]: ... diff --git a/mypy/typeshed/stdlib/@python2/user.pyi b/mypy/typeshed/stdlib/@python2/user.pyi deleted file mode 100644 index 9c33922b383d..000000000000 --- a/mypy/typeshed/stdlib/@python2/user.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import Any - -def __getattr__(name) -> Any: ... - -home: str -pythonrc: str diff --git a/mypy/typeshed/stdlib/@python2/uu.pyi b/mypy/typeshed/stdlib/@python2/uu.pyi deleted file mode 100644 index a9585bac60a1..000000000000 --- a/mypy/typeshed/stdlib/@python2/uu.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import BinaryIO, Text - -_File = Text | BinaryIO - -class Error(Exception): ... - -def encode(in_file: _File, out_file: _File, name: str | None = ..., mode: int | None = ...) -> None: ... -def decode(in_file: _File, out_file: _File | None = ..., mode: int | None = ..., quiet: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/uuid.pyi b/mypy/typeshed/stdlib/@python2/uuid.pyi deleted file mode 100644 index 8ba2d7e5aa24..000000000000 --- a/mypy/typeshed/stdlib/@python2/uuid.pyi +++ /dev/null @@ -1,81 +0,0 @@ -from typing import Any, Text - -# Because UUID has properties called int and bytes we need to rename these temporarily. -_Int = int -_Bytes = bytes -_FieldsType = tuple[int, int, int, int, int, int] - -class UUID: - def __init__( - self, - hex: Text | None = ..., - bytes: _Bytes | None = ..., - bytes_le: _Bytes | None = ..., - fields: _FieldsType | None = ..., - int: _Int | None = ..., - version: _Int | None = ..., - ) -> None: ... - @property - def bytes(self) -> _Bytes: ... - @property - def bytes_le(self) -> _Bytes: ... - @property - def clock_seq(self) -> _Int: ... - @property - def clock_seq_hi_variant(self) -> _Int: ... - @property - def clock_seq_low(self) -> _Int: ... - @property - def fields(self) -> _FieldsType: ... - @property - def hex(self) -> str: ... - @property - def int(self) -> _Int: ... - @property - def node(self) -> _Int: ... - @property - def time(self) -> _Int: ... - @property - def time_hi_version(self) -> _Int: ... - @property - def time_low(self) -> _Int: ... - @property - def time_mid(self) -> _Int: ... - @property - def urn(self) -> str: ... - @property - def variant(self) -> str: ... - @property - def version(self) -> _Int | None: ... - def __int__(self) -> _Int: ... - def get_bytes(self) -> _Bytes: ... - def get_bytes_le(self) -> _Bytes: ... - def get_clock_seq(self) -> _Int: ... - def get_clock_seq_hi_variant(self) -> _Int: ... - def get_clock_seq_low(self) -> _Int: ... - def get_fields(self) -> _FieldsType: ... - def get_hex(self) -> str: ... - def get_node(self) -> _Int: ... - def get_time(self) -> _Int: ... - def get_time_hi_version(self) -> _Int: ... - def get_time_low(self) -> _Int: ... - def get_time_mid(self) -> _Int: ... - def get_urn(self) -> str: ... - def get_variant(self) -> str: ... - def get_version(self) -> _Int | None: ... - def __cmp__(self, other: Any) -> _Int: ... - -def getnode() -> int: ... -def uuid1(node: _Int | None = ..., clock_seq: _Int | None = ...) -> UUID: ... -def uuid3(namespace: UUID, name: str) -> UUID: ... -def uuid4() -> UUID: ... -def uuid5(namespace: UUID, name: str) -> UUID: ... - -NAMESPACE_DNS: UUID -NAMESPACE_URL: UUID -NAMESPACE_OID: UUID -NAMESPACE_X500: UUID -RESERVED_NCS: str -RFC_4122: str -RESERVED_MICROSOFT: str -RESERVED_FUTURE: str diff --git a/mypy/typeshed/stdlib/@python2/warnings.pyi b/mypy/typeshed/stdlib/@python2/warnings.pyi deleted file mode 100644 index 2e872a4fb28e..000000000000 --- a/mypy/typeshed/stdlib/@python2/warnings.pyi +++ /dev/null @@ -1,51 +0,0 @@ -from _warnings import warn as warn, warn_explicit as warn_explicit -from types import ModuleType, TracebackType -from typing import TextIO, overload -from typing_extensions import Literal - -def showwarning( - message: Warning | str, category: type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... -) -> None: ... -def formatwarning(message: Warning | str, category: type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ... -def filterwarnings( - action: str, message: str = ..., category: type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ... -) -> None: ... -def simplefilter(action: str, category: type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... -def resetwarnings() -> None: ... - -class _OptionError(Exception): ... - -class WarningMessage: - message: Warning | str - category: type[Warning] - filename: str - lineno: int - file: TextIO | None - line: str | None - def __init__( - self, - message: Warning | str, - category: type[Warning], - filename: str, - lineno: int, - file: TextIO | None = ..., - line: str | None = ..., - ) -> None: ... - -class catch_warnings: - @overload - def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ... - @overload - def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ... - @overload - def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... - def __enter__(self) -> list[WarningMessage] | None: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - -class _catch_warnings_without_records(catch_warnings): - def __enter__(self) -> None: ... - -class _catch_warnings_with_records(catch_warnings): - def __enter__(self) -> list[WarningMessage]: ... diff --git a/mypy/typeshed/stdlib/@python2/wave.pyi b/mypy/typeshed/stdlib/@python2/wave.pyi deleted file mode 100644 index d13f74664f43..000000000000 --- a/mypy/typeshed/stdlib/@python2/wave.pyi +++ /dev/null @@ -1,56 +0,0 @@ -from typing import IO, Any, BinaryIO, NoReturn, Text - -_File = Text | IO[bytes] - -class Error(Exception): ... - -WAVE_FORMAT_PCM: int - -_wave_params = tuple[int, int, int, int, str, str] - -class Wave_read: - def __init__(self, f: _File) -> None: ... - def getfp(self) -> BinaryIO | None: ... - def rewind(self) -> None: ... - def close(self) -> None: ... - def tell(self) -> int: ... - def getnchannels(self) -> int: ... - def getnframes(self) -> int: ... - def getsampwidth(self) -> int: ... - def getframerate(self) -> int: ... - def getcomptype(self) -> str: ... - def getcompname(self) -> str: ... - def getparams(self) -> _wave_params: ... - def getmarkers(self) -> None: ... - def getmark(self, id: Any) -> NoReturn: ... - def setpos(self, pos: int) -> None: ... - def readframes(self, nframes: int) -> bytes: ... - -class Wave_write: - def __init__(self, f: _File) -> None: ... - def setnchannels(self, nchannels: int) -> None: ... - def getnchannels(self) -> int: ... - def setsampwidth(self, sampwidth: int) -> None: ... - def getsampwidth(self) -> int: ... - def setframerate(self, framerate: float) -> None: ... - def getframerate(self) -> int: ... - def setnframes(self, nframes: int) -> None: ... - def getnframes(self) -> int: ... - def setcomptype(self, comptype: str, compname: str) -> None: ... - def getcomptype(self) -> str: ... - def getcompname(self) -> str: ... - def setparams(self, params: _wave_params) -> None: ... - def getparams(self) -> _wave_params: ... - def setmark(self, id: Any, pos: Any, name: Any) -> NoReturn: ... - def getmark(self, id: Any) -> NoReturn: ... - def getmarkers(self) -> None: ... - def tell(self) -> int: ... - # should be any bytes-like object after 3.4, but we don't have a type for that - def writeframesraw(self, data: bytes) -> None: ... - def writeframes(self, data: bytes) -> None: ... - def close(self) -> None: ... - -# Returns a Wave_read if mode is rb and Wave_write if mode is wb -def open(f: _File, mode: str | None = ...) -> Any: ... - -openfp = open diff --git a/mypy/typeshed/stdlib/@python2/weakref.pyi b/mypy/typeshed/stdlib/@python2/weakref.pyi deleted file mode 100644 index 959c3e1b9d1e..000000000000 --- a/mypy/typeshed/stdlib/@python2/weakref.pyi +++ /dev/null @@ -1,69 +0,0 @@ -from _weakrefset import WeakSet as WeakSet -from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar, overload - -from _weakref import ( - CallableProxyType as CallableProxyType, - ProxyType as ProxyType, - ReferenceType as ReferenceType, - getweakrefcount as getweakrefcount, - getweakrefs as getweakrefs, - proxy as proxy, - ref as ref, -) -from exceptions import ReferenceError as ReferenceError - -_T = TypeVar("_T") -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") - -ProxyTypes: tuple[type[Any], ...] - -class WeakValueDictionary(MutableMapping[_KT, _VT]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, __other: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - def __len__(self) -> int: ... - def __getitem__(self, k: _KT) -> _VT: ... - def __setitem__(self, k: _KT, v: _VT) -> None: ... - def __delitem__(self, v: _KT) -> None: ... - def has_key(self, key: object) -> bool: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_KT]: ... - def copy(self) -> WeakValueDictionary[_KT, _VT]: ... - def keys(self) -> list[_KT]: ... - def values(self) -> list[_VT]: ... - def items(self) -> list[tuple[_KT, _VT]]: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT]: ... - def iteritems(self) -> Iterator[tuple[_KT, _VT]]: ... - def itervaluerefs(self) -> Iterator[KeyedRef[_KT, _VT]]: ... - def valuerefs(self) -> list[KeyedRef[_KT, _VT]]: ... - -class KeyedRef(ref[_T], Generic[_KT, _T]): - key: _KT - # This __new__ method uses a non-standard name for the "cls" parameter - def __new__(type, ob: _T, callback: Callable[[_T], Any], key: _KT) -> KeyedRef[_KT, _T]: ... - def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ... - -class WeakKeyDictionary(MutableMapping[_KT, _VT]): - @overload - def __init__(self, dict: None = ...) -> None: ... - @overload - def __init__(self, dict: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]]) -> None: ... - def __len__(self) -> int: ... - def __getitem__(self, k: _KT) -> _VT: ... - def __setitem__(self, k: _KT, v: _VT) -> None: ... - def __delitem__(self, v: _KT) -> None: ... - def has_key(self, key: object) -> bool: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_KT]: ... - def copy(self) -> WeakKeyDictionary[_KT, _VT]: ... - def keys(self) -> list[_KT]: ... - def values(self) -> list[_VT]: ... - def items(self) -> list[tuple[_KT, _VT]]: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT]: ... - def iteritems(self) -> Iterator[tuple[_KT, _VT]]: ... - def iterkeyrefs(self) -> Iterator[ref[_KT]]: ... - def keyrefs(self) -> list[ref[_KT]]: ... diff --git a/mypy/typeshed/stdlib/@python2/webbrowser.pyi b/mypy/typeshed/stdlib/@python2/webbrowser.pyi deleted file mode 100644 index 33600fe3255d..000000000000 --- a/mypy/typeshed/stdlib/@python2/webbrowser.pyi +++ /dev/null @@ -1,97 +0,0 @@ -import sys -from typing import Callable, Sequence, Text - -class Error(Exception): ... - -def register( - name: Text, klass: Callable[[], BaseBrowser] | None, instance: BaseBrowser | None = ..., update_tryorder: int = ... -) -> None: ... -def get(using: Text | None = ...) -> BaseBrowser: ... -def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... -def open_new(url: Text) -> bool: ... -def open_new_tab(url: Text) -> bool: ... - -class BaseBrowser: - args: list[str] - name: str - basename: str - def __init__(self, name: Text = ...) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - def open_new(self, url: Text) -> bool: ... - def open_new_tab(self, url: Text) -> bool: ... - -class GenericBrowser(BaseBrowser): - args: list[str] - name: str - basename: str - def __init__(self, name: Text | Sequence[Text]) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - -class BackgroundBrowser(GenericBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - -class UnixBrowser(BaseBrowser): - raise_opts: list[str] | None - background: bool - redirect_stdout: bool - remote_args: list[str] - remote_action: str - remote_action_newwin: str - remote_action_newtab: str - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - -class Mozilla(UnixBrowser): - remote_args: list[str] - remote_action: str - remote_action_newwin: str - remote_action_newtab: str - background: bool - -class Galeon(UnixBrowser): - raise_opts: list[str] - remote_args: list[str] - remote_action: str - remote_action_newwin: str - background: bool - -class Chrome(UnixBrowser): - remote_args: list[str] - remote_action: str - remote_action_newwin: str - remote_action_newtab: str - background: bool - -class Opera(UnixBrowser): - remote_args: list[str] - remote_action: str - remote_action_newwin: str - remote_action_newtab: str - background: bool - -class Elinks(UnixBrowser): - remote_args: list[str] - remote_action: str - remote_action_newwin: str - remote_action_newtab: str - background: bool - redirect_stdout: bool - -class Konqueror(BaseBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - -class Grail(BaseBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - -if sys.platform == "win32": - class WindowsDefault(BaseBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - -if sys.platform == "darwin": - class MacOSX(BaseBrowser): - name: str - def __init__(self, name: Text) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - - class MacOSXOSAScript(BaseBrowser): - def __init__(self, name: Text) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/whichdb.pyi b/mypy/typeshed/stdlib/@python2/whichdb.pyi deleted file mode 100644 index 1c678e9392e8..000000000000 --- a/mypy/typeshed/stdlib/@python2/whichdb.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from typing import Text - -def whichdb(filename: Text) -> str | None: ... diff --git a/mypy/typeshed/stdlib/@python2/winsound.pyi b/mypy/typeshed/stdlib/@python2/winsound.pyi deleted file mode 100644 index 3d79f3b043f2..000000000000 --- a/mypy/typeshed/stdlib/@python2/winsound.pyi +++ /dev/null @@ -1,27 +0,0 @@ -import sys -from typing import overload -from typing_extensions import Literal - -if sys.platform == "win32": - SND_FILENAME: int - SND_ALIAS: int - SND_LOOP: int - SND_MEMORY: int - SND_PURGE: int - SND_ASYNC: int - SND_NODEFAULT: int - SND_NOSTOP: int - SND_NOWAIT: int - - MB_ICONASTERISK: int - MB_ICONEXCLAMATION: int - MB_ICONHAND: int - MB_ICONQUESTION: int - MB_OK: int - def Beep(frequency: int, duration: int) -> None: ... - # Can actually accept anything ORed with 4, and if not it's definitely str, but that's inexpressible - @overload - def PlaySound(sound: bytes | None, flags: Literal[4]) -> None: ... - @overload - def PlaySound(sound: str | bytes | None, flags: int) -> None: ... - def MessageBeep(type: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/wsgiref/__init__.pyi b/mypy/typeshed/stdlib/@python2/wsgiref/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/wsgiref/handlers.pyi b/mypy/typeshed/stdlib/@python2/wsgiref/handlers.pyi deleted file mode 100644 index 4dd63ac75035..000000000000 --- a/mypy/typeshed/stdlib/@python2/wsgiref/handlers.pyi +++ /dev/null @@ -1,89 +0,0 @@ -from abc import abstractmethod -from types import TracebackType -from typing import IO, Callable, MutableMapping, Optional, Text - -from .headers import Headers -from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment -from .util import FileWrapper - -_exc_info = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]] - -def format_date_time(timestamp: float | None) -> str: ... # undocumented - -class BaseHandler: - wsgi_version: tuple[int, int] # undocumented - wsgi_multithread: bool - wsgi_multiprocess: bool - wsgi_run_once: bool - - origin_server: bool - http_version: str - server_software: str | None - - os_environ: MutableMapping[str, str] - - wsgi_file_wrapper: type[FileWrapper] | None - headers_class: type[Headers] # undocumented - - traceback_limit: int | None - error_status: str - error_headers: list[tuple[Text, Text]] - error_body: bytes - def run(self, application: WSGIApplication) -> None: ... - def setup_environ(self) -> None: ... - def finish_response(self) -> None: ... - def get_scheme(self) -> str: ... - def set_content_length(self) -> None: ... - def cleanup_headers(self) -> None: ... - def start_response( - self, status: Text, headers: list[tuple[Text, Text]], exc_info: _exc_info | None = ... - ) -> Callable[[bytes], None]: ... - def send_preamble(self) -> None: ... - def write(self, data: bytes) -> None: ... - def sendfile(self) -> bool: ... - def finish_content(self) -> None: ... - def close(self) -> None: ... - def send_headers(self) -> None: ... - def result_is_file(self) -> bool: ... - def client_is_modern(self) -> bool: ... - def log_exception(self, exc_info: _exc_info) -> None: ... - def handle_error(self) -> None: ... - def error_output(self, environ: WSGIEnvironment, start_response: StartResponse) -> list[bytes]: ... - @abstractmethod - def _write(self, data: bytes) -> None: ... - @abstractmethod - def _flush(self) -> None: ... - @abstractmethod - def get_stdin(self) -> InputStream: ... - @abstractmethod - def get_stderr(self) -> ErrorStream: ... - @abstractmethod - def add_cgi_vars(self) -> None: ... - -class SimpleHandler(BaseHandler): - stdin: InputStream - stdout: IO[bytes] - stderr: ErrorStream - base_env: MutableMapping[str, str] - def __init__( - self, - stdin: InputStream, - stdout: IO[bytes], - stderr: ErrorStream, - environ: MutableMapping[str, str], - multithread: bool = ..., - multiprocess: bool = ..., - ) -> None: ... - def get_stdin(self) -> InputStream: ... - def get_stderr(self) -> ErrorStream: ... - def add_cgi_vars(self) -> None: ... - def _write(self, data: bytes) -> None: ... - def _flush(self) -> None: ... - -class BaseCGIHandler(SimpleHandler): ... - -class CGIHandler(BaseCGIHandler): - def __init__(self) -> None: ... - -class IISCGIHandler(BaseCGIHandler): - def __init__(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/wsgiref/headers.pyi b/mypy/typeshed/stdlib/@python2/wsgiref/headers.pyi deleted file mode 100644 index 5c939a342510..000000000000 --- a/mypy/typeshed/stdlib/@python2/wsgiref/headers.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from typing import Pattern, overload - -_HeaderList = list[tuple[str, str]] - -tspecials: Pattern[str] # undocumented - -class Headers: - def __init__(self, headers: _HeaderList) -> None: ... - def __len__(self) -> int: ... - def __setitem__(self, name: str, val: str) -> None: ... - def __delitem__(self, name: str) -> None: ... - def __getitem__(self, name: str) -> str | None: ... - def has_key(self, name: str) -> bool: ... - def __contains__(self, name: str) -> bool: ... - def get_all(self, name: str) -> list[str]: ... - @overload - def get(self, name: str, default: str) -> str: ... - @overload - def get(self, name: str, default: str | None = ...) -> str | None: ... - def keys(self) -> list[str]: ... - def values(self) -> list[str]: ... - def items(self) -> _HeaderList: ... - def setdefault(self, name: str, value: str) -> str: ... - def add_header(self, _name: str, _value: str | None, **_params: str | None) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/wsgiref/simple_server.pyi b/mypy/typeshed/stdlib/@python2/wsgiref/simple_server.pyi deleted file mode 100644 index 6faba328f935..000000000000 --- a/mypy/typeshed/stdlib/@python2/wsgiref/simple_server.pyi +++ /dev/null @@ -1,37 +0,0 @@ -from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer -from typing import TypeVar, overload - -from .handlers import SimpleHandler -from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment - -server_version: str # undocumented -sys_version: str # undocumented -software_version: str # undocumented - -class ServerHandler(SimpleHandler): # undocumented - server_software: str - def close(self) -> None: ... - -class WSGIServer(HTTPServer): - application: WSGIApplication | None - base_environ: WSGIEnvironment # only available after call to setup_environ() - def setup_environ(self) -> None: ... - def get_app(self) -> WSGIApplication | None: ... - def set_app(self, application: WSGIApplication | None) -> None: ... - -class WSGIRequestHandler(BaseHTTPRequestHandler): - server_version: str - def get_environ(self) -> WSGIEnvironment: ... - def get_stderr(self) -> ErrorStream: ... - def handle(self) -> None: ... - -def demo_app(environ: WSGIEnvironment, start_response: StartResponse) -> list[bytes]: ... - -_S = TypeVar("_S", bound=WSGIServer) - -@overload -def make_server(host: str, port: int, app: WSGIApplication, *, handler_class: type[WSGIRequestHandler] = ...) -> WSGIServer: ... -@overload -def make_server( - host: str, port: int, app: WSGIApplication, server_class: type[_S], handler_class: type[WSGIRequestHandler] = ... -) -> _S: ... diff --git a/mypy/typeshed/stdlib/@python2/wsgiref/types.pyi b/mypy/typeshed/stdlib/@python2/wsgiref/types.pyi deleted file mode 100644 index c272ae67c391..000000000000 --- a/mypy/typeshed/stdlib/@python2/wsgiref/types.pyi +++ /dev/null @@ -1,3 +0,0 @@ -# Obsolete, use _typeshed.wsgi directly. - -from _typeshed.wsgi import * diff --git a/mypy/typeshed/stdlib/@python2/wsgiref/util.pyi b/mypy/typeshed/stdlib/@python2/wsgiref/util.pyi deleted file mode 100644 index c8e045a8cb8e..000000000000 --- a/mypy/typeshed/stdlib/@python2/wsgiref/util.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import IO, Any, Callable - -from .types import WSGIEnvironment - -class FileWrapper: - filelike: IO[bytes] - blksize: int - close: Callable[[], None] # only exists if filelike.close exists - def __init__(self, filelike: IO[bytes], blksize: int = ...) -> None: ... - def __getitem__(self, key: Any) -> bytes: ... - def __iter__(self) -> FileWrapper: ... - def next(self) -> bytes: ... - -def guess_scheme(environ: WSGIEnvironment) -> str: ... -def application_uri(environ: WSGIEnvironment) -> str: ... -def request_uri(environ: WSGIEnvironment, include_query: bool = ...) -> str: ... -def shift_path_info(environ: WSGIEnvironment) -> str | None: ... -def setup_testing_defaults(environ: WSGIEnvironment) -> None: ... -def is_hop_by_hop(header_name: str) -> bool: ... diff --git a/mypy/typeshed/stdlib/@python2/wsgiref/validate.pyi b/mypy/typeshed/stdlib/@python2/wsgiref/validate.pyi deleted file mode 100644 index b3e629b02d71..000000000000 --- a/mypy/typeshed/stdlib/@python2/wsgiref/validate.pyi +++ /dev/null @@ -1,44 +0,0 @@ -from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication -from typing import Any, Callable, Iterable, Iterator, NoReturn - -class WSGIWarning(Warning): ... - -def validator(application: WSGIApplication) -> WSGIApplication: ... - -class InputWrapper: - input: InputStream - def __init__(self, wsgi_input: InputStream) -> None: ... - def read(self, size: int = ...) -> bytes: ... - def readline(self) -> bytes: ... - def readlines(self, hint: int = ...) -> bytes: ... - def __iter__(self) -> Iterable[bytes]: ... - def close(self) -> NoReturn: ... - -class ErrorWrapper: - errors: ErrorStream - def __init__(self, wsgi_errors: ErrorStream) -> None: ... - def write(self, s: str) -> None: ... - def flush(self) -> None: ... - def writelines(self, seq: Iterable[str]) -> None: ... - def close(self) -> NoReturn: ... - -class WriteWrapper: - writer: Callable[[bytes], Any] - def __init__(self, wsgi_writer: Callable[[bytes], Any]) -> None: ... - def __call__(self, s: bytes) -> None: ... - -class PartialIteratorWrapper: - iterator: Iterator[bytes] - def __init__(self, wsgi_iterator: Iterator[bytes]) -> None: ... - def __iter__(self) -> IteratorWrapper: ... - -class IteratorWrapper: - original_iterator: Iterator[bytes] - iterator: Iterator[bytes] - closed: bool - check_start_response: bool | None - def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: bool | None) -> None: ... - def __iter__(self) -> IteratorWrapper: ... - def next(self) -> bytes: ... - def close(self) -> None: ... - def __del__(self) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/xdrlib.pyi b/mypy/typeshed/stdlib/@python2/xdrlib.pyi deleted file mode 100644 index f59843f8ee9d..000000000000 --- a/mypy/typeshed/stdlib/@python2/xdrlib.pyi +++ /dev/null @@ -1,55 +0,0 @@ -from typing import Callable, Sequence, TypeVar - -_T = TypeVar("_T") - -class Error(Exception): - msg: str - def __init__(self, msg: str) -> None: ... - -class ConversionError(Error): ... - -class Packer: - def __init__(self) -> None: ... - def reset(self) -> None: ... - def get_buffer(self) -> bytes: ... - def get_buf(self) -> bytes: ... - def pack_uint(self, x: int) -> None: ... - def pack_int(self, x: int) -> None: ... - def pack_enum(self, x: int) -> None: ... - def pack_bool(self, x: bool) -> None: ... - def pack_uhyper(self, x: int) -> None: ... - def pack_hyper(self, x: int) -> None: ... - def pack_float(self, x: float) -> None: ... - def pack_double(self, x: float) -> None: ... - def pack_fstring(self, n: int, s: bytes) -> None: ... - def pack_fopaque(self, n: int, s: bytes) -> None: ... - def pack_string(self, s: bytes) -> None: ... - def pack_opaque(self, s: bytes) -> None: ... - def pack_bytes(self, s: bytes) -> None: ... - def pack_list(self, list: Sequence[_T], pack_item: Callable[[_T], None]) -> None: ... - def pack_farray(self, n: int, list: Sequence[_T], pack_item: Callable[[_T], None]) -> None: ... - def pack_array(self, list: Sequence[_T], pack_item: Callable[[_T], None]) -> None: ... - -class Unpacker: - def __init__(self, data: bytes) -> None: ... - def reset(self, data: bytes) -> None: ... - def get_position(self) -> int: ... - def set_position(self, position: int) -> None: ... - def get_buffer(self) -> bytes: ... - def done(self) -> None: ... - def unpack_uint(self) -> int: ... - def unpack_int(self) -> int: ... - def unpack_enum(self) -> int: ... - def unpack_bool(self) -> bool: ... - def unpack_uhyper(self) -> int: ... - def unpack_hyper(self) -> int: ... - def unpack_float(self) -> float: ... - def unpack_double(self) -> float: ... - def unpack_fstring(self, n: int) -> bytes: ... - def unpack_fopaque(self, n: int) -> bytes: ... - def unpack_string(self) -> bytes: ... - def unpack_opaque(self) -> bytes: ... - def unpack_bytes(self) -> bytes: ... - def unpack_list(self, unpack_item: Callable[[], _T]) -> list[_T]: ... - def unpack_farray(self, n: int, unpack_item: Callable[[], _T]) -> list[_T]: ... - def unpack_array(self, unpack_item: Callable[[], _T]) -> list[_T]: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/__init__.pyi b/mypy/typeshed/stdlib/@python2/xml/__init__.pyi deleted file mode 100644 index c524ac2b1cfc..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -import xml.parsers as parsers diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/NodeFilter.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/NodeFilter.pyi deleted file mode 100644 index 80fb73d23433..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/NodeFilter.pyi +++ /dev/null @@ -1,19 +0,0 @@ -class NodeFilter: - FILTER_ACCEPT: int - FILTER_REJECT: int - FILTER_SKIP: int - - SHOW_ALL: int - SHOW_ELEMENT: int - SHOW_ATTRIBUTE: int - SHOW_TEXT: int - SHOW_CDATA_SECTION: int - SHOW_ENTITY_REFERENCE: int - SHOW_ENTITY: int - SHOW_PROCESSING_INSTRUCTION: int - SHOW_COMMENT: int - SHOW_DOCUMENT: int - SHOW_DOCUMENT_TYPE: int - SHOW_DOCUMENT_FRAGMENT: int - SHOW_NOTATION: int - def acceptNode(self, node) -> int: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/__init__.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/__init__.pyi deleted file mode 100644 index c5766c326c3e..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/__init__.pyi +++ /dev/null @@ -1,68 +0,0 @@ -from typing import Any - -from .domreg import getDOMImplementation as getDOMImplementation, registerDOMImplementation as registerDOMImplementation - -class Node: - ELEMENT_NODE: int - ATTRIBUTE_NODE: int - TEXT_NODE: int - CDATA_SECTION_NODE: int - ENTITY_REFERENCE_NODE: int - ENTITY_NODE: int - PROCESSING_INSTRUCTION_NODE: int - COMMENT_NODE: int - DOCUMENT_NODE: int - DOCUMENT_TYPE_NODE: int - DOCUMENT_FRAGMENT_NODE: int - NOTATION_NODE: int - -# ExceptionCode -INDEX_SIZE_ERR: int -DOMSTRING_SIZE_ERR: int -HIERARCHY_REQUEST_ERR: int -WRONG_DOCUMENT_ERR: int -INVALID_CHARACTER_ERR: int -NO_DATA_ALLOWED_ERR: int -NO_MODIFICATION_ALLOWED_ERR: int -NOT_FOUND_ERR: int -NOT_SUPPORTED_ERR: int -INUSE_ATTRIBUTE_ERR: int -INVALID_STATE_ERR: int -SYNTAX_ERR: int -INVALID_MODIFICATION_ERR: int -NAMESPACE_ERR: int -INVALID_ACCESS_ERR: int -VALIDATION_ERR: int - -class DOMException(Exception): - code: int - def __init__(self, *args: Any, **kw: Any) -> None: ... - def _get_code(self) -> int: ... - -class IndexSizeErr(DOMException): ... -class DomstringSizeErr(DOMException): ... -class HierarchyRequestErr(DOMException): ... -class WrongDocumentErr(DOMException): ... -class NoDataAllowedErr(DOMException): ... -class NoModificationAllowedErr(DOMException): ... -class NotFoundErr(DOMException): ... -class NotSupportedErr(DOMException): ... -class InuseAttributeErr(DOMException): ... -class InvalidStateErr(DOMException): ... -class SyntaxErr(DOMException): ... -class InvalidModificationErr(DOMException): ... -class NamespaceErr(DOMException): ... -class InvalidAccessErr(DOMException): ... -class ValidationErr(DOMException): ... - -class UserDataHandler: - NODE_CLONED: int - NODE_IMPORTED: int - NODE_DELETED: int - NODE_RENAMED: int - -XML_NAMESPACE: str -XMLNS_NAMESPACE: str -XHTML_NAMESPACE: str -EMPTY_NAMESPACE: None -EMPTY_PREFIX: None diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/domreg.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/domreg.pyi deleted file mode 100644 index b9e2dd9eb263..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/domreg.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from _typeshed.xml import DOMImplementation -from typing import Callable, Iterable - -well_known_implementations: dict[str, str] -registered: dict[str, Callable[[], DOMImplementation]] - -def registerDOMImplementation(name: str, factory: Callable[[], DOMImplementation]) -> None: ... -def getDOMImplementation(name: str | None = ..., features: str | Iterable[tuple[str, str | None]] = ...) -> DOMImplementation: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/expatbuilder.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/expatbuilder.pyi deleted file mode 100644 index 964e6fa3f426..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/expatbuilder.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from typing import Any - -def __getattr__(name: str) -> Any: ... # incomplete diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/minicompat.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/minicompat.pyi deleted file mode 100644 index e37b7cd89176..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/minicompat.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from typing import Any, Iterable, TypeVar - -_T = TypeVar("_T") - -StringTypes: tuple[type[str]] - -class NodeList(list[_T]): - length: int - def item(self, index: int) -> _T | None: ... - -class EmptyNodeList(tuple[Any, ...]): - length: int - def item(self, index: int) -> None: ... - def __add__(self, other: Iterable[_T]) -> NodeList[_T]: ... # type: ignore[override] - def __radd__(self, other: Iterable[_T]) -> NodeList[_T]: ... - -def defproperty(klass: type[Any], name: str, doc: str) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/minidom.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/minidom.pyi deleted file mode 100644 index b09d1a503b44..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/minidom.pyi +++ /dev/null @@ -1,291 +0,0 @@ -import xml.dom -from _typeshed import Self -from typing import IO, Any, Text as _Text -from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS -from xml.sax.xmlreader import XMLReader - -def parse(file: str | IO[Any], parser: XMLReader | None = ..., bufsize: int | None = ...): ... -def parseString(string: bytes | _Text, parser: XMLReader | None = ...): ... -def getDOMImplementation(features=...): ... - -class Node(xml.dom.Node): - namespaceURI: str | None - parentNode: Any - ownerDocument: Any - nextSibling: Any - previousSibling: Any - prefix: Any - def toxml(self, encoding: Any | None = ...): ... - def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Any | None = ...): ... - def hasChildNodes(self) -> bool: ... - def insertBefore(self, newChild, refChild): ... - def appendChild(self, node): ... - def replaceChild(self, newChild, oldChild): ... - def removeChild(self, oldChild): ... - def normalize(self) -> None: ... - def cloneNode(self, deep): ... - def isSupported(self, feature, version): ... - def isSameNode(self, other): ... - def getInterface(self, feature): ... - def getUserData(self, key): ... - def setUserData(self, key, data, handler): ... - childNodes: Any - def unlink(self) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__(self, et, ev, tb) -> None: ... - -class DocumentFragment(Node): - nodeType: Any - nodeName: str - nodeValue: Any - attributes: Any - parentNode: Any - childNodes: Any - def __init__(self) -> None: ... - -class Attr(Node): - name: str - nodeType: Any - attributes: Any - specified: bool - ownerElement: Any - namespaceURI: str | None - childNodes: Any - nodeName: Any - nodeValue: str - value: str - prefix: Any - def __init__( - self, qName: str, namespaceURI: str | None = ..., localName: Any | None = ..., prefix: Any | None = ... - ) -> None: ... - def unlink(self) -> None: ... - -class NamedNodeMap: - def __init__(self, attrs, attrsNS, ownerElement) -> None: ... - def item(self, index): ... - def items(self): ... - def itemsNS(self): ... - def __contains__(self, key): ... - def keys(self): ... - def keysNS(self): ... - def values(self): ... - def get(self, name, value: Any | None = ...): ... - def __len__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... - def __ge__(self, other: Any) -> bool: ... - def __gt__(self, other: Any) -> bool: ... - def __le__(self, other: Any) -> bool: ... - def __lt__(self, other: Any) -> bool: ... - def __getitem__(self, attname_or_tuple): ... - def __setitem__(self, attname, value) -> None: ... - def getNamedItem(self, name): ... - def getNamedItemNS(self, namespaceURI: str, localName): ... - def removeNamedItem(self, name): ... - def removeNamedItemNS(self, namespaceURI: str, localName): ... - def setNamedItem(self, node): ... - def setNamedItemNS(self, node): ... - def __delitem__(self, attname_or_tuple) -> None: ... - -AttributeList = NamedNodeMap - -class TypeInfo: - namespace: Any - name: Any - def __init__(self, namespace, name) -> None: ... - -class Element(Node): - nodeType: Any - nodeValue: Any - schemaType: Any - parentNode: Any - tagName: str - prefix: Any - namespaceURI: str | None - childNodes: Any - nextSibling: Any - def __init__( - self, tagName, namespaceURI: str | None = ..., prefix: Any | None = ..., localName: Any | None = ... - ) -> None: ... - def unlink(self) -> None: ... - def getAttribute(self, attname): ... - def getAttributeNS(self, namespaceURI: str, localName): ... - def setAttribute(self, attname, value) -> None: ... - def setAttributeNS(self, namespaceURI: str, qualifiedName: str, value) -> None: ... - def getAttributeNode(self, attrname): ... - def getAttributeNodeNS(self, namespaceURI: str, localName): ... - def setAttributeNode(self, attr): ... - setAttributeNodeNS: Any - def removeAttribute(self, name) -> None: ... - def removeAttributeNS(self, namespaceURI: str, localName) -> None: ... - def removeAttributeNode(self, node): ... - removeAttributeNodeNS: Any - def hasAttribute(self, name: str) -> bool: ... - def hasAttributeNS(self, namespaceURI: str, localName) -> bool: ... - def getElementsByTagName(self, name): ... - def getElementsByTagNameNS(self, namespaceURI: str, localName): ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... - def hasAttributes(self) -> bool: ... - def setIdAttribute(self, name) -> None: ... - def setIdAttributeNS(self, namespaceURI: str, localName) -> None: ... - def setIdAttributeNode(self, idAttr) -> None: ... - -class Childless: - attributes: Any - childNodes: Any - firstChild: Any - lastChild: Any - def appendChild(self, node) -> None: ... - def hasChildNodes(self) -> bool: ... - def insertBefore(self, newChild, refChild) -> None: ... - def removeChild(self, oldChild) -> None: ... - def normalize(self) -> None: ... - def replaceChild(self, newChild, oldChild) -> None: ... - -class ProcessingInstruction(Childless, Node): - nodeType: Any - target: Any - data: Any - def __init__(self, target, data) -> None: ... - nodeValue: Any - nodeName: Any - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... - -class CharacterData(Childless, Node): - ownerDocument: Any - previousSibling: Any - def __init__(self) -> None: ... - def __len__(self) -> int: ... - data: str - nodeValue: Any - def substringData(self, offset: int, count: int) -> str: ... - def appendData(self, arg: str) -> None: ... - def insertData(self, offset: int, arg: str) -> None: ... - def deleteData(self, offset: int, count: int) -> None: ... - def replaceData(self, offset: int, count: int, arg: str) -> None: ... - -class Text(CharacterData): - nodeType: Any - nodeName: str - attributes: Any - data: Any - def splitText(self, offset): ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... - def replaceWholeText(self, content): ... - -class Comment(CharacterData): - nodeType: Any - nodeName: str - def __init__(self, data) -> None: ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... - -class CDATASection(Text): - nodeType: Any - nodeName: str - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... - -class ReadOnlySequentialNamedNodeMap: - def __init__(self, seq=...) -> None: ... - def __len__(self): ... - def getNamedItem(self, name): ... - def getNamedItemNS(self, namespaceURI: str, localName): ... - def __getitem__(self, name_or_tuple): ... - def item(self, index): ... - def removeNamedItem(self, name) -> None: ... - def removeNamedItemNS(self, namespaceURI: str, localName) -> None: ... - def setNamedItem(self, node) -> None: ... - def setNamedItemNS(self, node) -> None: ... - -class Identified: ... - -class DocumentType(Identified, Childless, Node): - nodeType: Any - nodeValue: Any - name: Any - publicId: Any - systemId: Any - internalSubset: Any - entities: Any - notations: Any - nodeName: Any - def __init__(self, qualifiedName: str) -> None: ... - def cloneNode(self, deep): ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... - -class Entity(Identified, Node): - attributes: Any - nodeType: Any - nodeValue: Any - actualEncoding: Any - encoding: Any - version: Any - nodeName: Any - notationName: Any - childNodes: Any - def __init__(self, name, publicId, systemId, notation) -> None: ... - def appendChild(self, newChild) -> None: ... - def insertBefore(self, newChild, refChild) -> None: ... - def removeChild(self, oldChild) -> None: ... - def replaceChild(self, newChild, oldChild) -> None: ... - -class Notation(Identified, Childless, Node): - nodeType: Any - nodeValue: Any - nodeName: Any - def __init__(self, name, publicId, systemId) -> None: ... - -class DOMImplementation(DOMImplementationLS): - def hasFeature(self, feature, version) -> bool: ... - def createDocument(self, namespaceURI: str, qualifiedName: str, doctype): ... - def createDocumentType(self, qualifiedName: str, publicId, systemId): ... - def getInterface(self, feature): ... - -class ElementInfo: - tagName: Any - def __init__(self, name) -> None: ... - def getAttributeType(self, aname): ... - def getAttributeTypeNS(self, namespaceURI: str, localName): ... - def isElementContent(self): ... - def isEmpty(self): ... - def isId(self, aname): ... - def isIdNS(self, namespaceURI: str, localName): ... - -class Document(Node, DocumentLS): - implementation: Any - nodeType: Any - nodeName: str - nodeValue: Any - attributes: Any - parentNode: Any - previousSibling: Any - nextSibling: Any - actualEncoding: Any - encoding: Any - standalone: Any - version: Any - strictErrorChecking: bool - errorHandler: Any - documentURI: Any - doctype: Any - childNodes: Any - def __init__(self) -> None: ... - def appendChild(self, node): ... - documentElement: Any - def removeChild(self, oldChild): ... - def unlink(self) -> None: ... - def cloneNode(self, deep): ... - def createDocumentFragment(self): ... - def createElement(self, tagName: str): ... - def createTextNode(self, data): ... - def createCDATASection(self, data): ... - def createComment(self, data): ... - def createProcessingInstruction(self, target, data): ... - def createAttribute(self, qName) -> Attr: ... - def createElementNS(self, namespaceURI: str, qualifiedName: str): ... - def createAttributeNS(self, namespaceURI: str, qualifiedName: str) -> Attr: ... - def getElementById(self, id): ... - def getElementsByTagName(self, name: str): ... - def getElementsByTagNameNS(self, namespaceURI: str, localName): ... - def isSupported(self, feature, version): ... - def importNode(self, node, deep): ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Any | None = ...) -> None: ... - def renameNode(self, n, namespaceURI: str, name): ... diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/pulldom.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/pulldom.pyi deleted file mode 100644 index 964e6fa3f426..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/pulldom.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from typing import Any - -def __getattr__(name: str) -> Any: ... # incomplete diff --git a/mypy/typeshed/stdlib/@python2/xml/dom/xmlbuilder.pyi b/mypy/typeshed/stdlib/@python2/xml/dom/xmlbuilder.pyi deleted file mode 100644 index a77c99790fda..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/dom/xmlbuilder.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import Any - -def __getattr__(name: str) -> Any: ... # incomplete - -class DocumentLS(Any): ... -class DOMImplementationLS(Any): ... diff --git a/mypy/typeshed/stdlib/@python2/xml/etree/ElementInclude.pyi b/mypy/typeshed/stdlib/@python2/xml/etree/ElementInclude.pyi deleted file mode 100644 index b74285d3e9b7..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/etree/ElementInclude.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Callable -from xml.etree.ElementTree import Element - -XINCLUDE: str -XINCLUDE_INCLUDE: str -XINCLUDE_FALLBACK: str - -class FatalIncludeError(SyntaxError): ... - -def default_loader(href: str | bytes | int, parse: str, encoding: str | None = ...) -> str | Element: ... - -# TODO: loader is of type default_loader ie it takes a callable that has the -# same signature as default_loader. But default_loader has a keyword argument -# Which can't be represented using Callable... -def include(elem: Element, loader: Callable[..., str | Element] | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/etree/ElementPath.pyi b/mypy/typeshed/stdlib/@python2/xml/etree/ElementPath.pyi deleted file mode 100644 index 5a2dd69c1bee..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/etree/ElementPath.pyi +++ /dev/null @@ -1,31 +0,0 @@ -from typing import Callable, Generator, Pattern, TypeVar -from xml.etree.ElementTree import Element - -xpath_tokenizer_re: Pattern[str] - -_token = tuple[str, str] -_next = Callable[[], _token] -_callback = Callable[[_SelectorContext, list[Element]], Generator[Element, None, None]] - -def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = ...) -> Generator[_token, None, None]: ... -def get_parent_map(context: _SelectorContext) -> dict[Element, Element]: ... -def prepare_child(next: _next, token: _token) -> _callback: ... -def prepare_star(next: _next, token: _token) -> _callback: ... -def prepare_self(next: _next, token: _token) -> _callback: ... -def prepare_descendant(next: _next, token: _token) -> _callback: ... -def prepare_parent(next: _next, token: _token) -> _callback: ... -def prepare_predicate(next: _next, token: _token) -> _callback: ... - -ops: dict[str, Callable[[_next, _token], _callback]] - -class _SelectorContext: - parent_map: dict[Element, Element] | None - root: Element - def __init__(self, root: Element) -> None: ... - -_T = TypeVar("_T") - -def iterfind(elem: Element, path: str, namespaces: dict[str, str] | None = ...) -> Generator[Element, None, None]: ... -def find(elem: Element, path: str, namespaces: dict[str, str] | None = ...) -> Element | None: ... -def findall(elem: Element, path: str, namespaces: dict[str, str] | None = ...) -> list[Element]: ... -def findtext(elem: Element, path: str, default: _T | None = ..., namespaces: dict[str, str] | None = ...) -> _T | str: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/etree/ElementTree.pyi b/mypy/typeshed/stdlib/@python2/xml/etree/ElementTree.pyi deleted file mode 100644 index f17ae5211252..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/etree/ElementTree.pyi +++ /dev/null @@ -1,197 +0,0 @@ -from _typeshed import FileDescriptor -from typing import ( - IO, - Any, - Callable, - Generator, - ItemsView, - Iterable, - Iterator, - KeysView, - MutableSequence, - Sequence, - Text, - TypeVar, - overload, -) - -VERSION: str - -class ParseError(SyntaxError): - code: int - position: tuple[int, int] - -def iselement(element: object) -> bool: ... - -_T = TypeVar("_T") - -# Type for parser inputs. Parser will accept any unicode/str/bytes and coerce, -# and this is true in py2 and py3 (even fromstringlist() in python3 can be -# called with a heterogeneous list) -_parser_input_type = bytes | Text - -# Type for individual tag/attr/ns/text values in args to most functions. -# In py2, the library accepts str or unicode everywhere and coerces -# aggressively. -# In py3, bytes is not coerced to str and so use of bytes is probably an error, -# so we exclude it. (why? the parser never produces bytes when it parses XML, -# so e.g., element.get(b'name') will always return None for parsed XML, even if -# there is a 'name' attribute.) -_str_argument_type = str | Text - -# Type for return values from individual tag/attr/text values -# in python2, if the tag/attribute/text wasn't decode-able as ascii, it -# comes out as a unicode string; otherwise it comes out as str. (see -# _fixtext function in the source). Client code knows best: -_str_result_type = Any - -_file_or_filename = Text | FileDescriptor | IO[Any] - -class Element(MutableSequence[Element]): - tag: _str_result_type - attrib: dict[_str_result_type, _str_result_type] - text: _str_result_type | None - tail: _str_result_type | None - def __init__( - self, - tag: _str_argument_type | Callable[..., Element], - attrib: dict[_str_argument_type, _str_argument_type] = ..., - **extra: _str_argument_type, - ) -> None: ... - def append(self, __subelement: Element) -> None: ... - def clear(self) -> None: ... - def extend(self, __elements: Iterable[Element]) -> None: ... - def find( - self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> Element | None: ... - def findall( - self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> list[Element]: ... - @overload - def findtext( - self, path: _str_argument_type, default: None = ..., namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> _str_result_type | None: ... - @overload - def findtext( - self, path: _str_argument_type, default: _T, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> _T | _str_result_type: ... - @overload - def get(self, key: _str_argument_type, default: None = ...) -> _str_result_type | None: ... - @overload - def get(self, key: _str_argument_type, default: _T) -> _str_result_type | _T: ... - def insert(self, __index: int, __element: Element) -> None: ... - def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... - def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ... - def iterfind( - self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> Generator[Element, None, None]: ... - def itertext(self) -> Generator[_str_result_type, None, None]: ... - def keys(self) -> KeysView[_str_result_type]: ... - def makeelement(self, __tag: _str_argument_type, __attrib: dict[_str_argument_type, _str_argument_type]) -> Element: ... - def remove(self, __subelement: Element) -> None: ... - def set(self, __key: _str_argument_type, __value: _str_argument_type) -> None: ... - def __delitem__(self, i: int | slice) -> None: ... - @overload - def __getitem__(self, i: int) -> Element: ... - @overload - def __getitem__(self, s: slice) -> MutableSequence[Element]: ... - def __len__(self) -> int: ... - @overload - def __setitem__(self, i: int, o: Element) -> None: ... - @overload - def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ... - def getchildren(self) -> list[Element]: ... - def getiterator(self, tag: _str_argument_type | None = ...) -> list[Element]: ... - -def SubElement( - parent: Element, - tag: _str_argument_type, - attrib: dict[_str_argument_type, _str_argument_type] = ..., - **extra: _str_argument_type, -) -> Element: ... -def Comment(text: _str_argument_type | None = ...) -> Element: ... -def ProcessingInstruction(target: _str_argument_type, text: _str_argument_type | None = ...) -> Element: ... - -PI: Callable[..., Element] - -class QName: - text: str - def __init__(self, text_or_uri: _str_argument_type, tag: _str_argument_type | None = ...) -> None: ... - -class ElementTree: - def __init__(self, element: Element | None = ..., file: _file_or_filename | None = ...) -> None: ... - def getroot(self) -> Element: ... - def parse(self, source: _file_or_filename, parser: XMLParser | None = ...) -> Element: ... - def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ... - def getiterator(self, tag: _str_argument_type | None = ...) -> list[Element]: ... - def find( - self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> Element | None: ... - @overload - def findtext( - self, path: _str_argument_type, default: None = ..., namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> _str_result_type | None: ... - @overload - def findtext( - self, path: _str_argument_type, default: _T, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> _T | _str_result_type: ... - def findall( - self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> list[Element]: ... - def iterfind( - self, path: _str_argument_type, namespaces: dict[_str_argument_type, _str_argument_type] | None = ... - ) -> Generator[Element, None, None]: ... - def write( - self, - file_or_filename: _file_or_filename, - encoding: str | None = ..., - xml_declaration: bool | None = ..., - default_namespace: _str_argument_type | None = ..., - method: str | None = ..., - ) -> None: ... - def write_c14n(self, file: _file_or_filename) -> None: ... - -def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... -def tostring(element: Element, encoding: str | None = ..., method: str | None = ...) -> bytes: ... -def tostringlist(element: Element, encoding: str | None = ..., method: str | None = ...) -> list[bytes]: ... -def dump(elem: Element) -> None: ... -def parse(source: _file_or_filename, parser: XMLParser | None = ...) -> ElementTree: ... -def iterparse( - source: _file_or_filename, events: Sequence[str] | None = ..., parser: XMLParser | None = ... -) -> Iterator[tuple[str, Any]]: ... -def XML(text: _parser_input_type, parser: XMLParser | None = ...) -> Element: ... -def XMLID(text: _parser_input_type, parser: XMLParser | None = ...) -> tuple[Element, dict[_str_result_type, Element]]: ... - -# This is aliased to XML in the source. -fromstring = XML - -def fromstringlist(sequence: Sequence[_parser_input_type], parser: XMLParser | None = ...) -> Element: ... - -# This type is both not precise enough and too precise. The TreeBuilder -# requires the elementfactory to accept tag and attrs in its args and produce -# some kind of object that has .text and .tail properties. -# I've chosen to constrain the ElementFactory to always produce an Element -# because that is how almost everyone will use it. -# Unfortunately, the type of the factory arguments is dependent on how -# TreeBuilder is called by client code (they could pass strs, bytes or whatever); -# but we don't want to use a too-broad type, or it would be too hard to write -# elementfactories. -_ElementFactory = Callable[[Any, dict[Any, Any]], Element] - -class TreeBuilder: - def __init__(self, element_factory: _ElementFactory | None = ...) -> None: ... - def close(self) -> Element: ... - def data(self, __data: _parser_input_type) -> None: ... - def start(self, __tag: _parser_input_type, __attrs: dict[_parser_input_type, _parser_input_type]) -> Element: ... - def end(self, __tag: _parser_input_type) -> Element: ... - -class XMLParser: - parser: Any - target: Any - # TODO-what is entity used for??? - entity: Any - version: str - def __init__(self, html: int = ..., target: Any = ..., encoding: str | None = ...) -> None: ... - def doctype(self, __name: str, __pubid: str, __system: str) -> None: ... - def close(self) -> Any: ... - def feed(self, __data: _parser_input_type) -> None: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/etree/__init__.pyi b/mypy/typeshed/stdlib/@python2/xml/etree/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/mypy/typeshed/stdlib/@python2/xml/etree/cElementTree.pyi b/mypy/typeshed/stdlib/@python2/xml/etree/cElementTree.pyi deleted file mode 100644 index 02272d803c18..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/etree/cElementTree.pyi +++ /dev/null @@ -1 +0,0 @@ -from xml.etree.ElementTree import * diff --git a/mypy/typeshed/stdlib/@python2/xml/parsers/__init__.pyi b/mypy/typeshed/stdlib/@python2/xml/parsers/__init__.pyi deleted file mode 100644 index cac086235cba..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/parsers/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -import xml.parsers.expat as expat diff --git a/mypy/typeshed/stdlib/@python2/xml/parsers/expat/__init__.pyi b/mypy/typeshed/stdlib/@python2/xml/parsers/expat/__init__.pyi deleted file mode 100644 index 73f3758c61ec..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/parsers/expat/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -from pyexpat import * diff --git a/mypy/typeshed/stdlib/@python2/xml/parsers/expat/errors.pyi b/mypy/typeshed/stdlib/@python2/xml/parsers/expat/errors.pyi deleted file mode 100644 index e22d769ec340..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/parsers/expat/errors.pyi +++ /dev/null @@ -1 +0,0 @@ -from pyexpat.errors import * diff --git a/mypy/typeshed/stdlib/@python2/xml/parsers/expat/model.pyi b/mypy/typeshed/stdlib/@python2/xml/parsers/expat/model.pyi deleted file mode 100644 index d8f44b47c51b..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/parsers/expat/model.pyi +++ /dev/null @@ -1 +0,0 @@ -from pyexpat.model import * diff --git a/mypy/typeshed/stdlib/@python2/xml/sax/__init__.pyi b/mypy/typeshed/stdlib/@python2/xml/sax/__init__.pyi deleted file mode 100644 index 7a35805f9f16..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/sax/__init__.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from typing import IO, Any, NoReturn, Text -from xml.sax.handler import ContentHandler, ErrorHandler -from xml.sax.xmlreader import Locator, XMLReader - -class SAXException(Exception): - def __init__(self, msg: str, exception: Exception | None = ...) -> None: ... - def getMessage(self) -> str: ... - def getException(self) -> Exception: ... - def __getitem__(self, ix: Any) -> NoReturn: ... - -class SAXParseException(SAXException): - def __init__(self, msg: str, exception: Exception, locator: Locator) -> None: ... - def getColumnNumber(self) -> int: ... - def getLineNumber(self) -> int: ... - def getPublicId(self): ... - def getSystemId(self): ... - -class SAXNotRecognizedException(SAXException): ... -class SAXNotSupportedException(SAXException): ... -class SAXReaderNotAvailable(SAXNotSupportedException): ... - -default_parser_list: list[str] - -def make_parser(parser_list: list[str] = ...) -> XMLReader: ... -def parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... -def parseString(string: bytes | Text, handler: ContentHandler, errorHandler: ErrorHandler | None = ...) -> None: ... -def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/mypy/typeshed/stdlib/@python2/xml/sax/handler.pyi b/mypy/typeshed/stdlib/@python2/xml/sax/handler.pyi deleted file mode 100644 index 3a5193300981..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/sax/handler.pyi +++ /dev/null @@ -1,46 +0,0 @@ -from typing import Any - -version: Any - -class ErrorHandler: - def error(self, exception): ... - def fatalError(self, exception): ... - def warning(self, exception): ... - -class ContentHandler: - def __init__(self) -> None: ... - def setDocumentLocator(self, locator): ... - def startDocument(self): ... - def endDocument(self): ... - def startPrefixMapping(self, prefix, uri): ... - def endPrefixMapping(self, prefix): ... - def startElement(self, name, attrs): ... - def endElement(self, name): ... - def startElementNS(self, name, qname, attrs): ... - def endElementNS(self, name, qname): ... - def characters(self, content): ... - def ignorableWhitespace(self, whitespace): ... - def processingInstruction(self, target, data): ... - def skippedEntity(self, name): ... - -class DTDHandler: - def notationDecl(self, name, publicId, systemId): ... - def unparsedEntityDecl(self, name, publicId, systemId, ndata): ... - -class EntityResolver: - def resolveEntity(self, publicId, systemId): ... - -feature_namespaces: Any -feature_namespace_prefixes: Any -feature_string_interning: Any -feature_validation: Any -feature_external_ges: Any -feature_external_pes: Any -all_features: Any -property_lexical_handler: Any -property_declaration_handler: Any -property_dom_node: Any -property_xml_string: Any -property_encoding: Any -property_interning_dict: Any -all_properties: Any diff --git a/mypy/typeshed/stdlib/@python2/xml/sax/saxutils.pyi b/mypy/typeshed/stdlib/@python2/xml/sax/saxutils.pyi deleted file mode 100644 index 1fc896490f54..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/sax/saxutils.pyi +++ /dev/null @@ -1,59 +0,0 @@ -from _typeshed import SupportsWrite -from codecs import StreamReaderWriter, StreamWriter -from io import RawIOBase, TextIOBase -from typing import Mapping, Text -from xml.sax import handler, xmlreader - -def escape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... -def unescape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... -def quoteattr(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... - -class XMLGenerator(handler.ContentHandler): - def __init__( - self, - out: TextIOBase | RawIOBase | StreamWriter | StreamReaderWriter | SupportsWrite[str] | None = ..., - encoding: Text = ..., - ) -> None: ... - def startDocument(self): ... - def endDocument(self): ... - def startPrefixMapping(self, prefix, uri): ... - def endPrefixMapping(self, prefix): ... - def startElement(self, name, attrs): ... - def endElement(self, name): ... - def startElementNS(self, name, qname, attrs): ... - def endElementNS(self, name, qname): ... - def characters(self, content): ... - def ignorableWhitespace(self, content): ... - def processingInstruction(self, target, data): ... - -class XMLFilterBase(xmlreader.XMLReader): - def __init__(self, parent: xmlreader.XMLReader | None = ...) -> None: ... - def error(self, exception): ... - def fatalError(self, exception): ... - def warning(self, exception): ... - def setDocumentLocator(self, locator): ... - def startDocument(self): ... - def endDocument(self): ... - def startPrefixMapping(self, prefix, uri): ... - def endPrefixMapping(self, prefix): ... - def startElement(self, name, attrs): ... - def endElement(self, name): ... - def startElementNS(self, name, qname, attrs): ... - def endElementNS(self, name, qname): ... - def characters(self, content): ... - def ignorableWhitespace(self, chars): ... - def processingInstruction(self, target, data): ... - def skippedEntity(self, name): ... - def notationDecl(self, name, publicId, systemId): ... - def unparsedEntityDecl(self, name, publicId, systemId, ndata): ... - def resolveEntity(self, publicId, systemId): ... - def parse(self, source): ... - def setLocale(self, locale): ... - def getFeature(self, name): ... - def setFeature(self, name, state): ... - def getProperty(self, name): ... - def setProperty(self, name, value): ... - def getParent(self): ... - def setParent(self, parent): ... - -def prepare_input_source(source, base=...): ... diff --git a/mypy/typeshed/stdlib/@python2/xml/sax/xmlreader.pyi b/mypy/typeshed/stdlib/@python2/xml/sax/xmlreader.pyi deleted file mode 100644 index 684e9cef1f42..000000000000 --- a/mypy/typeshed/stdlib/@python2/xml/sax/xmlreader.pyi +++ /dev/null @@ -1,72 +0,0 @@ -from typing import Mapping - -class XMLReader: - def __init__(self) -> None: ... - def parse(self, source): ... - def getContentHandler(self): ... - def setContentHandler(self, handler): ... - def getDTDHandler(self): ... - def setDTDHandler(self, handler): ... - def getEntityResolver(self): ... - def setEntityResolver(self, resolver): ... - def getErrorHandler(self): ... - def setErrorHandler(self, handler): ... - def setLocale(self, locale): ... - def getFeature(self, name): ... - def setFeature(self, name, state): ... - def getProperty(self, name): ... - def setProperty(self, name, value): ... - -class IncrementalParser(XMLReader): - def __init__(self, bufsize: int = ...) -> None: ... - def parse(self, source): ... - def feed(self, data): ... - def prepareParser(self, source): ... - def close(self): ... - def reset(self): ... - -class Locator: - def getColumnNumber(self): ... - def getLineNumber(self): ... - def getPublicId(self): ... - def getSystemId(self): ... - -class InputSource: - def __init__(self, system_id: str | None = ...) -> None: ... - def setPublicId(self, public_id): ... - def getPublicId(self): ... - def setSystemId(self, system_id): ... - def getSystemId(self): ... - def setEncoding(self, encoding): ... - def getEncoding(self): ... - def setByteStream(self, bytefile): ... - def getByteStream(self): ... - def setCharacterStream(self, charfile): ... - def getCharacterStream(self): ... - -class AttributesImpl: - def __init__(self, attrs: Mapping[str, str]) -> None: ... - def getLength(self): ... - def getType(self, name): ... - def getValue(self, name): ... - def getValueByQName(self, name): ... - def getNameByQName(self, name): ... - def getQNameByName(self, name): ... - def getNames(self): ... - def getQNames(self): ... - def __len__(self): ... - def __getitem__(self, name): ... - def keys(self): ... - def __contains__(self, name): ... - def get(self, name, alternative=...): ... - def copy(self): ... - def items(self): ... - def values(self): ... - -class AttributesNSImpl(AttributesImpl): - def __init__(self, attrs: Mapping[tuple[str, str], str], qnames: Mapping[tuple[str, str], str]) -> None: ... - def getValueByQName(self, name): ... - def getNameByQName(self, name): ... - def getQNameByName(self, name): ... - def getQNames(self): ... - def copy(self): ... diff --git a/mypy/typeshed/stdlib/@python2/xmlrpclib.pyi b/mypy/typeshed/stdlib/@python2/xmlrpclib.pyi deleted file mode 100644 index 2365bcf90cd1..000000000000 --- a/mypy/typeshed/stdlib/@python2/xmlrpclib.pyi +++ /dev/null @@ -1,244 +0,0 @@ -from datetime import datetime -from gzip import GzipFile -from httplib import HTTPConnection, HTTPResponse, HTTPSConnection -from ssl import SSLContext -from StringIO import StringIO -from time import struct_time -from types import InstanceType -from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, MutableMapping, Union - -_Unmarshaller = Any -_timeTuple = tuple[int, int, int, int, int, int, int, int, int] -# Represents types that can be compared against a DateTime object -_dateTimeComp = unicode | DateTime | datetime -# A "host description" used by Transport factories -_hostDesc = Union[str, tuple[str, Mapping[Any, Any]]] - -def escape(s: AnyStr, replace: Callable[[AnyStr, AnyStr, AnyStr], AnyStr] = ...) -> AnyStr: ... - -MAXINT: int -MININT: int -PARSE_ERROR: int -SERVER_ERROR: int -APPLICATION_ERROR: int -SYSTEM_ERROR: int -TRANSPORT_ERROR: int -NOT_WELLFORMED_ERROR: int -UNSUPPORTED_ENCODING: int -INVALID_ENCODING_CHAR: int -INVALID_XMLRPC: int -METHOD_NOT_FOUND: int -INVALID_METHOD_PARAMS: int -INTERNAL_ERROR: int - -class Error(Exception): ... - -class ProtocolError(Error): - url: str - errcode: int - errmsg: str - headers: Any - def __init__(self, url: str, errcode: int, errmsg: str, headers: Any) -> None: ... - -class ResponseError(Error): ... - -class Fault(Error): - faultCode: Any - faultString: str - def __init__(self, faultCode: Any, faultString: str, **extra: Any) -> None: ... - -boolean: type[bool] -Boolean: type[bool] - -class DateTime: - value: str - def __init__(self, value: str | unicode | datetime | float | int | _timeTuple | struct_time = ...) -> None: ... - def make_comparable(self, other: _dateTimeComp) -> tuple[unicode, unicode]: ... - def __lt__(self, other: _dateTimeComp) -> bool: ... - def __le__(self, other: _dateTimeComp) -> bool: ... - def __gt__(self, other: _dateTimeComp) -> bool: ... - def __ge__(self, other: _dateTimeComp) -> bool: ... - def __eq__(self, other: _dateTimeComp) -> bool: ... # type: ignore[override] - def __ne__(self, other: _dateTimeComp) -> bool: ... # type: ignore[override] - def timetuple(self) -> struct_time: ... - def __cmp__(self, other: _dateTimeComp) -> int: ... - def decode(self, data: Any) -> None: ... - def encode(self, out: IO[str]) -> None: ... - -class Binary: - data: str - def __init__(self, data: str | None = ...) -> None: ... - def __cmp__(self, other: Any) -> int: ... - def decode(self, data: str) -> None: ... - def encode(self, out: IO[str]) -> None: ... - -WRAPPERS: tuple[type[Any], ...] - -# Still part of the public API, but see http://bugs.python.org/issue1773632 -FastParser: None -FastUnmarshaller: None -FastMarshaller: None - -# xmlrpclib.py will leave ExpatParser undefined if it can't import expat from -# xml.parsers. Because this is Python 2.7, the import will succeed. -class ExpatParser: - def __init__(self, target: _Unmarshaller) -> None: ... - def feed(self, data: str): ... - def close(self): ... - -# TODO: Add xmllib.XMLParser as base class -class SlowParser: - handle_xml: Callable[[str, bool], None] - unknown_starttag: Callable[[str, Any], None] - handle_data: Callable[[str], None] - handle_cdata: Callable[[str], None] - unknown_endtag: Callable[[str, Callable[[Iterable[str], str], str]], None] - def __init__(self, target: _Unmarshaller) -> None: ... - -class Marshaller: - memo: MutableMapping[int, Any] - data: str | None - encoding: str | None - allow_none: bool - def __init__(self, encoding: str | None = ..., allow_none: bool = ...) -> None: ... - dispatch: Mapping[type, Callable[[Marshaller, str, Callable[[str], None]], None]] - def dumps( - self, - values: Iterable[ - None - | int - | bool - | long - | float - | str - | unicode - | list[Any] - | tuple[Any, ...] - | Mapping[Any, Any] - | datetime - | InstanceType - ] - | Fault, - ) -> str: ... - def dump_nil(self, value: None, write: Callable[[str], None]) -> None: ... - def dump_int(self, value: int, write: Callable[[str], None]) -> None: ... - def dump_bool(self, value: bool, write: Callable[[str], None]) -> None: ... - def dump_long(self, value: long, write: Callable[[str], None]) -> None: ... - def dump_double(self, value: float, write: Callable[[str], None]) -> None: ... - def dump_string( - self, - value: str, - write: Callable[[str], None], - escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ..., - ) -> None: ... - def dump_unicode( - self, - value: unicode, - write: Callable[[str], None], - escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ..., - ) -> None: ... - def dump_array(self, value: Iterable[Any], write: Callable[[str], None]) -> None: ... - def dump_struct( - self, - value: Mapping[unicode, Any], - write: Callable[[str], None], - escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ..., - ) -> None: ... - def dump_datetime(self, value: datetime, write: Callable[[str], None]) -> None: ... - def dump_instance(self, value: InstanceType, write: Callable[[str], None]) -> None: ... - -class Unmarshaller: - def append(self, object: Any) -> None: ... - def __init__(self, use_datetime: bool = ...) -> None: ... - def close(self) -> tuple[Any, ...]: ... - def getmethodname(self) -> str | None: ... - def xml(self, encoding: str, standalone: bool) -> None: ... - def start(self, tag: str, attrs: Any) -> None: ... - def data(self, text: str) -> None: ... - def end(self, tag: str, join: Callable[[Iterable[str], str], str] = ...) -> None: ... - def end_dispatch(self, tag: str, data: str) -> None: ... - dispatch: Mapping[str, Callable[[Unmarshaller, str], None]] - def end_nil(self, data: str): ... - def end_boolean(self, data: str) -> None: ... - def end_int(self, data: str) -> None: ... - def end_double(self, data: str) -> None: ... - def end_string(self, data: str) -> None: ... - def end_array(self, data: str) -> None: ... - def end_struct(self, data: str) -> None: ... - def end_base64(self, data: str) -> None: ... - def end_dateTime(self, data: str) -> None: ... - def end_value(self, data: str) -> None: ... - def end_params(self, data: str) -> None: ... - def end_fault(self, data: str) -> None: ... - def end_methodName(self, data: str) -> None: ... - -class _MultiCallMethod: - def __init__(self, call_list: list[tuple[str, tuple[Any, ...]]], name: str) -> None: ... - -class MultiCallIterator: - def __init__(self, results: list[Any]) -> None: ... - -class MultiCall: - def __init__(self, server: ServerProxy) -> None: ... - def __getattr__(self, name: str) -> _MultiCallMethod: ... - def __call__(self) -> MultiCallIterator: ... - -def getparser(use_datetime: bool = ...) -> tuple[ExpatParser | SlowParser, Unmarshaller]: ... -def dumps( - params: tuple[Any, ...] | Fault, - methodname: str | None = ..., - methodresponse: bool | None = ..., - encoding: str | None = ..., - allow_none: bool = ..., -) -> str: ... -def loads(data: str, use_datetime: bool = ...) -> tuple[tuple[Any, ...], str | None]: ... -def gzip_encode(data: str) -> str: ... -def gzip_decode(data: str, max_decode: int = ...) -> str: ... - -class GzipDecodedResponse(GzipFile): - stringio: StringIO[Any] - def __init__(self, response: HTTPResponse) -> None: ... - def close(self): ... - -class _Method: - def __init__(self, send: Callable[[str, tuple[Any, ...]], Any], name: str) -> None: ... - def __getattr__(self, name: str) -> _Method: ... - def __call__(self, *args: Any) -> Any: ... - -class Transport: - user_agent: str - accept_gzip_encoding: bool - encode_threshold: int | None - def __init__(self, use_datetime: bool = ...) -> None: ... - def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple[Any, ...]: ... - verbose: bool - def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple[Any, ...]: ... - def getparser(self) -> tuple[ExpatParser | SlowParser, Unmarshaller]: ... - def get_host_info(self, host: _hostDesc) -> tuple[str, list[tuple[str, str]] | None, Mapping[Any, Any] | None]: ... - def make_connection(self, host: _hostDesc) -> HTTPConnection: ... - def close(self) -> None: ... - def send_request(self, connection: HTTPConnection, handler: str, request_body: str) -> None: ... - def send_host(self, connection: HTTPConnection, host: str) -> None: ... - def send_user_agent(self, connection: HTTPConnection) -> None: ... - def send_content(self, connection: HTTPConnection, request_body: str) -> None: ... - def parse_response(self, response: HTTPResponse) -> tuple[Any, ...]: ... - -class SafeTransport(Transport): - def __init__(self, use_datetime: bool = ..., context: SSLContext | None = ...) -> None: ... - def make_connection(self, host: _hostDesc) -> HTTPSConnection: ... - -class ServerProxy: - def __init__( - self, - uri: str, - transport: Transport | None = ..., - encoding: str | None = ..., - verbose: bool = ..., - allow_none: bool = ..., - use_datetime: bool = ..., - context: SSLContext | None = ..., - ) -> None: ... - def __getattr__(self, name: str) -> _Method: ... - def __call__(self, attr: str) -> Transport | None: ... - -Server = ServerProxy diff --git a/mypy/typeshed/stdlib/@python2/zipfile.pyi b/mypy/typeshed/stdlib/@python2/zipfile.pyi deleted file mode 100644 index 63c93b482855..000000000000 --- a/mypy/typeshed/stdlib/@python2/zipfile.pyi +++ /dev/null @@ -1,100 +0,0 @@ -import io -from _typeshed import Self, StrPath -from types import TracebackType -from typing import IO, Any, Callable, Iterable, Pattern, Protocol, Sequence, Text - -_SZI = Text | ZipInfo -_DT = tuple[int, int, int, int, int, int] - -class BadZipfile(Exception): ... - -error = BadZipfile - -class LargeZipFile(Exception): ... - -class ZipExtFile(io.BufferedIOBase): - MAX_N: int = ... - MIN_READ_SIZE: int = ... - - PATTERN: Pattern[str] = ... - - newlines: list[bytes] | None - mode: str - name: str - def __init__( - self, - fileobj: IO[bytes], - mode: str, - zipinfo: ZipInfo, - decrypter: Callable[[Sequence[int]], bytes] | None = ..., - close_fileobj: bool = ..., - ) -> None: ... - def read(self, n: int | None = ...) -> bytes: ... - def readline(self, limit: int = ...) -> bytes: ... # type: ignore[override] - def peek(self, n: int = ...) -> bytes: ... - def read1(self, n: int | None) -> bytes: ... - -class _Writer(Protocol): - def write(self, __s: str) -> Any: ... - -class ZipFile: - filename: Text | None - debug: int - comment: bytes - filelist: list[ZipInfo] - fp: IO[bytes] | None - NameToInfo: dict[Text, ZipInfo] - start_dir: int # undocumented - def __init__(self, file: StrPath | IO[bytes], mode: Text = ..., compression: int = ..., allowZip64: bool = ...) -> None: ... - def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... - def close(self) -> None: ... - def getinfo(self, name: Text) -> ZipInfo: ... - def infolist(self) -> list[ZipInfo]: ... - def namelist(self) -> list[Text]: ... - def open(self, name: _SZI, mode: Text = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... - def extract(self, member: _SZI, path: StrPath | None = ..., pwd: bytes | None = ...) -> str: ... - def extractall(self, path: StrPath | None = ..., members: Iterable[Text] | None = ..., pwd: bytes | None = ...) -> None: ... - def printdir(self) -> None: ... - def setpassword(self, pwd: bytes) -> None: ... - def read(self, name: _SZI, pwd: bytes | None = ...) -> bytes: ... - def testzip(self) -> str | None: ... - def write(self, filename: StrPath, arcname: StrPath | None = ..., compress_type: int | None = ...) -> None: ... - def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: int | None = ...) -> None: ... - -class PyZipFile(ZipFile): - def writepy(self, pathname: Text, basename: Text = ...) -> None: ... - -class ZipInfo: - filename: Text - date_time: _DT - compress_type: int - comment: bytes - extra: bytes - create_system: int - create_version: int - extract_version: int - reserved: int - flag_bits: int - volume: int - internal_attr: int - external_attr: int - header_offset: int - CRC: int - compress_size: int - file_size: int - def __init__(self, filename: Text | None = ..., date_time: _DT | None = ...) -> None: ... - def FileHeader(self, zip64: bool | None = ...) -> bytes: ... - -class _PathOpenProtocol(Protocol): - def __call__(self, mode: str = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... - -def is_zipfile(filename: StrPath | IO[bytes]) -> bool: ... - -ZIP_STORED: int -ZIP_DEFLATED: int -ZIP64_LIMIT: int -ZIP_FILECOUNT_LIMIT: int -ZIP_MAX_COMMENT: int diff --git a/mypy/typeshed/stdlib/@python2/zipimport.pyi b/mypy/typeshed/stdlib/@python2/zipimport.pyi deleted file mode 100644 index bcefd6859059..000000000000 --- a/mypy/typeshed/stdlib/@python2/zipimport.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from types import CodeType, ModuleType - -class ZipImportError(ImportError): ... - -class zipimporter(object): - archive: str - prefix: str - def __init__(self, path: str | bytes) -> None: ... - def find_module(self, fullname: str, path: str | None = ...) -> zipimporter | None: ... - def get_code(self, fullname: str) -> CodeType: ... - def get_data(self, pathname: str) -> str: ... - def get_filename(self, fullname: str) -> str: ... - def get_source(self, fullname: str) -> str | None: ... - def is_package(self, fullname: str) -> bool: ... - def load_module(self, fullname: str) -> ModuleType: ... diff --git a/mypy/typeshed/stdlib/@python2/zlib.pyi b/mypy/typeshed/stdlib/@python2/zlib.pyi deleted file mode 100644 index 2cee20fc0928..000000000000 --- a/mypy/typeshed/stdlib/@python2/zlib.pyi +++ /dev/null @@ -1,40 +0,0 @@ -from array import array -from typing import Any - -DEFLATED: int -DEF_MEM_LEVEL: int -MAX_WBITS: int -ZLIB_VERSION: str -Z_BEST_COMPRESSION: int -Z_BEST_SPEED: int -Z_DEFAULT_COMPRESSION: int -Z_DEFAULT_STRATEGY: int -Z_FILTERED: int -Z_FINISH: int -Z_FIXED: int -Z_FULL_FLUSH: int -Z_HUFFMAN_ONLY: int -Z_NO_FLUSH: int -Z_RLE: int -Z_SYNC_FLUSH: int - -class error(Exception): ... - -class _Compress: - def compress(self, data: bytes) -> bytes: ... - def flush(self, mode: int = ...) -> bytes: ... - def copy(self) -> _Compress: ... - -class _Decompress: - unused_data: bytes - unconsumed_tail: bytes - def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... - def flush(self, length: int = ...) -> bytes: ... - def copy(self) -> _Decompress: ... - -def adler32(__data: bytes, __value: int = ...) -> int: ... -def compress(__data: bytes, level: int = ...) -> bytes: ... -def compressobj(level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ...) -> _Compress: ... -def crc32(__data: array[Any] | bytes, __value: int = ...) -> int: ... -def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... -def decompressobj(wbits: int = ...) -> _Decompress: ... diff --git a/mypy/typeshed/stdlib/VERSIONS b/mypy/typeshed/stdlib/VERSIONS index acf392d97816..d396ce4d0560 100644 --- a/mypy/typeshed/stdlib/VERSIONS +++ b/mypy/typeshed/stdlib/VERSIONS @@ -14,46 +14,46 @@ # # Python versions before 2.7 are ignored, so any module that was already # present in 2.7 will have "2.7" as its minimum version. Version ranges -# for unsupported versions of Python 3 (currently 3.5 and lower) are -# generally accurate but we do not guarantee their correctness. +# for unsupported versions of Python 3 are generally accurate but we do +# not guarantee their correctness. __future__: 2.7- __main__: 2.7- _ast: 2.7- _bisect: 2.7- -_bootlocale: 3.6-3.9 +_bootlocale: 3.4-3.9 _codecs: 2.7- _collections_abc: 3.3- -_compat_pickle: 3.6- -_compression: 3.6- +_compat_pickle: 3.1- +_compression: 3.5- _csv: 2.7- _curses: 2.7- -_decimal: 3.6- -_dummy_thread: 3.6-3.8 +_decimal: 3.3- +_dummy_thread: 3.0-3.8 _dummy_threading: 2.7-3.8 _heapq: 2.7- -_imp: 3.6- +_imp: 3.0- _json: 2.7- _markupbase: 2.7- _msi: 2.7- -_operator: 3.6- +_operator: 3.4- _osx_support: 2.7- -_posixsubprocess: 3.6- +_posixsubprocess: 3.2- _py_abc: 3.7- -_pydecimal: 3.6- +_pydecimal: 3.5- _random: 2.7- -_sitebuiltins: 3.6- +_sitebuiltins: 3.4- _socket: 3.0- # present in 2.7 at runtime, but not in typeshed -_stat: 3.6- +_stat: 3.4- _thread: 2.7- -_threading_local: 3.6- +_threading_local: 2.7- _tkinter: 2.7- -_tracemalloc: 3.6- +_tracemalloc: 3.4- _typeshed: 2.7- # not present at runtime, only for type checking _warnings: 2.7- _weakref: 2.7- _weakrefset: 2.7- -_winapi: 3.6- +_winapi: 3.3- abc: 2.7- aifc: 2.7- antigravity: 2.7- @@ -63,7 +63,6 @@ ast: 2.7- asynchat: 2.7- asyncio: 3.4- asyncio.mixins: 3.10- -asyncio.compat: 3.4-3.6 asyncio.exceptions: 3.8- asyncio.format_helpers: 3.7- asyncio.runners: 3.7- @@ -164,7 +163,6 @@ locale: 2.7- logging: 2.7- lzma: 3.3- macpath: 2.7-3.7 -macurl2path: 2.7-3.6 mailbox: 2.7- mailcap: 2.7- marshal: 2.7- @@ -175,6 +173,7 @@ modulefinder: 2.7- msilib: 2.7- msvcrt: 2.7- multiprocessing: 2.7- +multiprocessing.resource_tracker: 3.8- multiprocessing.shared_memory: 3.8- netrc: 2.7- nis: 2.7- @@ -291,7 +290,7 @@ wsgiref.types: 3.11- xdrlib: 2.7- xml: 2.7- xmlrpc: 3.0- -xxlimited: 3.6- +xxlimited: 3.2- zipapp: 3.5- zipfile: 2.7- zipimport: 2.7- diff --git a/mypy/typeshed/stdlib/__future__.pyi b/mypy/typeshed/stdlib/__future__.pyi index 80fb06a228a7..a90cf1eddab7 100644 --- a/mypy/typeshed/stdlib/__future__.pyi +++ b/mypy/typeshed/stdlib/__future__.pyi @@ -1,4 +1,3 @@ -import sys from typing_extensions import TypeAlias _VersionInfo: TypeAlias = tuple[int, int, int, str, int] @@ -18,9 +17,7 @@ unicode_literals: _Feature with_statement: _Feature barry_as_FLUFL: _Feature generator_stop: _Feature - -if sys.version_info >= (3, 7): - annotations: _Feature +annotations: _Feature all_feature_names: list[str] # undocumented @@ -35,7 +32,5 @@ __all__ = [ "with_statement", "barry_as_FLUFL", "generator_stop", + "annotations", ] - -if sys.version_info >= (3, 7): - __all__ += ["annotations"] diff --git a/mypy/typeshed/stdlib/_curses.pyi b/mypy/typeshed/stdlib/_curses.pyi index 1d10e93c5f92..adb1ea84e45b 100644 --- a/mypy/typeshed/stdlib/_curses.pyi +++ b/mypy/typeshed/stdlib/_curses.pyi @@ -60,8 +60,7 @@ if sys.platform != "win32": A_DIM: int A_HORIZONTAL: int A_INVIS: int - if sys.version_info >= (3, 7): - A_ITALIC: int + A_ITALIC: int A_LEFT: int A_LOW: int A_NORMAL: int diff --git a/mypy/typeshed/stdlib/_decimal.pyi b/mypy/typeshed/stdlib/_decimal.pyi index 515ed13d2a63..71dff44658be 100644 --- a/mypy/typeshed/stdlib/_decimal.pyi +++ b/mypy/typeshed/stdlib/_decimal.pyi @@ -26,9 +26,7 @@ ROUND_FLOOR: str ROUND_UP: str ROUND_HALF_DOWN: str ROUND_05UP: str - -if sys.version_info >= (3, 7): - HAVE_CONTEXTVAR: bool +HAVE_CONTEXTVAR: bool HAVE_THREADS: bool MAX_EMAX: int MAX_PREC: int diff --git a/mypy/typeshed/stdlib/_dummy_thread.pyi b/mypy/typeshed/stdlib/_dummy_thread.pyi index 4bcf84964add..463399ca43db 100644 --- a/mypy/typeshed/stdlib/_dummy_thread.pyi +++ b/mypy/typeshed/stdlib/_dummy_thread.pyi @@ -1,17 +1,13 @@ -import sys from collections.abc import Callable from types import TracebackType from typing import Any, NoReturn -__all__ = ["error", "start_new_thread", "exit", "get_ident", "allocate_lock", "interrupt_main", "LockType"] - -if sys.version_info >= (3, 7): - __all__ += ["RLock"] +__all__ = ["error", "start_new_thread", "exit", "get_ident", "allocate_lock", "interrupt_main", "LockType", "RLock"] TIMEOUT_MAX: int error = RuntimeError -def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... +def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ... def exit() -> NoReturn: ... def get_ident() -> int: ... def allocate_lock() -> LockType: ... @@ -26,8 +22,7 @@ class LockType: def release(self) -> bool: ... def locked(self) -> bool: ... -if sys.version_info >= (3, 7): - class RLock(LockType): - def release(self) -> None: ... # type: ignore[override] +class RLock(LockType): + def release(self) -> None: ... # type: ignore[override] def interrupt_main() -> None: ... diff --git a/mypy/typeshed/stdlib/_dummy_threading.pyi b/mypy/typeshed/stdlib/_dummy_threading.pyi index 583127500be8..c956946c8363 100644 --- a/mypy/typeshed/stdlib/_dummy_threading.pyi +++ b/mypy/typeshed/stdlib/_dummy_threading.pyi @@ -60,7 +60,7 @@ class Thread: def __init__( self, group: None = ..., - target: Callable[..., Any] | None = ..., + target: Callable[..., object] | None = ..., name: str | None = ..., args: Iterable[Any] = ..., kwargs: Mapping[str, Any] | None = ..., @@ -151,7 +151,7 @@ class Timer(Thread): def __init__( self, interval: float, - function: Callable[..., Any], + function: Callable[..., object], args: Iterable[Any] | None = ..., kwargs: Mapping[str, Any] | None = ..., ) -> None: ... diff --git a/mypy/typeshed/stdlib/_imp.pyi b/mypy/typeshed/stdlib/_imp.pyi index 856188dfbcd2..2b54a0f6fb42 100644 --- a/mypy/typeshed/stdlib/_imp.pyi +++ b/mypy/typeshed/stdlib/_imp.pyi @@ -4,10 +4,9 @@ from _typeshed import ReadableBuffer from importlib.machinery import ModuleSpec from typing import Any -if sys.version_info >= (3, 7): - check_hash_based_pycs: str - def source_hash(key: int, source: ReadableBuffer) -> bytes: ... +check_hash_based_pycs: str +def source_hash(key: int, source: ReadableBuffer) -> bytes: ... def create_builtin(__spec: ModuleSpec) -> types.ModuleType: ... def create_dynamic(__spec: ModuleSpec, __file: Any = ...) -> types.ModuleType: ... def acquire_lock() -> None: ... diff --git a/mypy/typeshed/stdlib/_msi.pyi b/mypy/typeshed/stdlib/_msi.pyi index ffe53c819e53..9dda8a598549 100644 --- a/mypy/typeshed/stdlib/_msi.pyi +++ b/mypy/typeshed/stdlib/_msi.pyi @@ -46,3 +46,43 @@ if sys.platform == "win32": def FCICreate(__cabname: str, __files: list[str]) -> None: ... def OpenDatabase(__path: str, __persist: int) -> _Database: ... def CreateRecord(__count: int) -> _Record: ... + + MSICOLINFO_NAMES: int + MSICOLINFO_TYPES: int + MSIDBOPEN_CREATE: int + MSIDBOPEN_CREATEDIRECT: int + MSIDBOPEN_DIRECT: int + MSIDBOPEN_PATCHFILE: int + MSIDBOPEN_READONLY: int + MSIDBOPEN_TRANSACT: int + MSIMODIFY_ASSIGN: int + MSIMODIFY_DELETE: int + MSIMODIFY_INSERT: int + MSIMODIFY_INSERT_TEMPORARY: int + MSIMODIFY_MERGE: int + MSIMODIFY_REFRESH: int + MSIMODIFY_REPLACE: int + MSIMODIFY_SEEK: int + MSIMODIFY_UPDATE: int + MSIMODIFY_VALIDATE: int + MSIMODIFY_VALIDATE_DELETE: int + MSIMODIFY_VALIDATE_FIELD: int + MSIMODIFY_VALIDATE_NEW: int + + PID_APPNAME: int + PID_AUTHOR: int + PID_CHARCOUNT: int + PID_CODEPAGE: int + PID_COMMENTS: int + PID_CREATE_DTM: int + PID_KEYWORDS: int + PID_LASTAUTHOR: int + PID_LASTPRINTED: int + PID_LASTSAVE_DTM: int + PID_PAGECOUNT: int + PID_REVNUMBER: int + PID_SECURITY: int + PID_SUBJECT: int + PID_TEMPLATE: int + PID_TITLE: int + PID_WORDCOUNT: int diff --git a/mypy/typeshed/stdlib/_pydecimal.pyi b/mypy/typeshed/stdlib/_pydecimal.pyi index 0d639bc164d4..faff626ac0ba 100644 --- a/mypy/typeshed/stdlib/_pydecimal.pyi +++ b/mypy/typeshed/stdlib/_pydecimal.pyi @@ -1,5 +1,3 @@ -import sys - # This is a slight lie, the implementations aren't exactly identical # However, in all likelihood, the differences are inconsequential from _decimal import * @@ -41,7 +39,5 @@ __all__ = [ "MIN_EMIN", "MIN_ETINY", "HAVE_THREADS", + "HAVE_CONTEXTVAR", ] - -if sys.version_info >= (3, 7): - __all__ += ["HAVE_CONTEXTVAR"] diff --git a/mypy/typeshed/stdlib/_socket.pyi b/mypy/typeshed/stdlib/_socket.pyi index 7af5be43c234..09dbaae3dc64 100644 --- a/mypy/typeshed/stdlib/_socket.pyi +++ b/mypy/typeshed/stdlib/_socket.pyi @@ -176,8 +176,7 @@ MSG_CTRUNC: int MSG_DONTROUTE: int if sys.platform != "darwin": - if sys.platform != "win32" or sys.version_info >= (3, 7): - MSG_ERRQUEUE: int + MSG_ERRQUEUE: int MSG_OOB: int MSG_PEEK: int @@ -218,15 +217,14 @@ if sys.platform == "linux" and sys.version_info >= (3, 11): SO_INCOMING_CPU: int TCP_FASTOPEN: int TCP_KEEPCNT: int +TCP_KEEPINTVL: int -if sys.platform != "win32" or sys.version_info >= (3, 7): - TCP_KEEPINTVL: int - if sys.platform != "darwin": - TCP_KEEPIDLE: int +if sys.platform != "darwin": + TCP_KEEPIDLE: int TCP_MAXSEG: int TCP_NODELAY: int -if sys.version_info >= (3, 7) and sys.platform != "win32": +if sys.platform != "win32": TCP_NOTSENT_LOWAT: int if sys.version_info >= (3, 10) and sys.platform == "darwin": TCP_KEEPALIVE: int @@ -368,7 +366,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 8): CAN_BCM_RX_RTR_FRAME: int CAN_BCM_CAN_FD_FRAME: int -if sys.platform == "linux" and sys.version_info >= (3, 7): +if sys.platform == "linux": CAN_ISOTP: int if sys.platform == "linux" and sys.version_info >= (3, 9): @@ -491,7 +489,7 @@ if sys.platform == "linux": ALG_SET_OP: int ALG_SET_PUBKEY: int -if sys.platform == "linux" and sys.version_info >= (3, 7): +if sys.platform == "linux": AF_VSOCK: int IOCTL_VM_SOCKETS_GET_LOCAL_CID: int VMADDR_CID_ANY: int @@ -598,9 +596,7 @@ class socket: def getsockopt(self, __level: int, __optname: int) -> int: ... @overload def getsockopt(self, __level: int, __optname: int, __buflen: int) -> bytes: ... - if sys.version_info >= (3, 7): - def getblocking(self) -> bool: ... - + def getblocking(self) -> bool: ... def gettimeout(self) -> float | None: ... if sys.platform == "win32": def ioctl(self, __control: int, __option: int | tuple[int, int, int] | bool) -> None: ... @@ -650,9 +646,7 @@ SocketType = socket # ----- Functions ----- -if sys.version_info >= (3, 7): - def close(__fd: _FD) -> None: ... - +def close(__fd: _FD) -> None: ... def dup(__fd: _FD) -> int: ... # the 5th tuple item is an address diff --git a/mypy/typeshed/stdlib/_thread.pyi b/mypy/typeshed/stdlib/_thread.pyi index 10a191cbdf78..152362edcaea 100644 --- a/mypy/typeshed/stdlib/_thread.pyi +++ b/mypy/typeshed/stdlib/_thread.pyi @@ -19,7 +19,7 @@ class LockType: self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... -def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ... +def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ... def interrupt_main() -> None: ... def exit() -> NoReturn: ... def allocate_lock() -> LockType: ... diff --git a/mypy/typeshed/stdlib/_typeshed/__init__.pyi b/mypy/typeshed/stdlib/_typeshed/__init__.pyi index ad78640b4ecc..89ca9d81619a 100644 --- a/mypy/typeshed/stdlib/_typeshed/__init__.pyi +++ b/mypy/typeshed/stdlib/_typeshed/__init__.pyi @@ -266,6 +266,10 @@ class structseq(Generic[_T_co]): # Superset of typing.AnyStr that also inclues LiteralString AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: Y001 +# Represents when str or LiteralStr is acceptable. Useful for string processing +# APIs where literalness of return value depends on literalness of inputs +StrOrLiteralStr = TypeVar("StrOrLiteralStr", LiteralString, str) # noqa: Y001 + # Objects suitable to be passed to sys.setprofile, threading.setprofile, and similar ProfileFunction: TypeAlias = Callable[[FrameType, str, Any], object] diff --git a/mypy/typeshed/stdlib/_typeshed/wsgi.pyi b/mypy/typeshed/stdlib/_typeshed/wsgi.pyi index 81ca12910bd9..de731aea918b 100644 --- a/mypy/typeshed/stdlib/_typeshed/wsgi.pyi +++ b/mypy/typeshed/stdlib/_typeshed/wsgi.pyi @@ -6,7 +6,7 @@ import sys from _typeshed import OptExcInfo -from collections.abc import Callable, Iterable +from collections.abc import Callable, Iterable, Iterator from typing import Any, Protocol from typing_extensions import TypeAlias @@ -31,7 +31,7 @@ else: def read(self, __size: int = ...) -> bytes: ... def readline(self, __size: int = ...) -> bytes: ... def readlines(self, __hint: int = ...) -> list[bytes]: ... - def __iter__(self) -> Iterable[bytes]: ... + def __iter__(self) -> Iterator[bytes]: ... # WSGI error streams per PEP 3333, stable class ErrorStream(Protocol): diff --git a/mypy/typeshed/stdlib/_winapi.pyi b/mypy/typeshed/stdlib/_winapi.pyi index 77e7714454e7..259293c51fd3 100644 --- a/mypy/typeshed/stdlib/_winapi.pyi +++ b/mypy/typeshed/stdlib/_winapi.pyi @@ -4,16 +4,14 @@ from typing import Any, NoReturn, overload from typing_extensions import Literal, final if sys.platform == "win32": - if sys.version_info >= (3, 7): - ABOVE_NORMAL_PRIORITY_CLASS: Literal[32768] - BELOW_NORMAL_PRIORITY_CLASS: Literal[16384] - CREATE_BREAKAWAY_FROM_JOB: Literal[16777216] - CREATE_DEFAULT_ERROR_MODE: Literal[67108864] - CREATE_NO_WINDOW: Literal[134217728] + ABOVE_NORMAL_PRIORITY_CLASS: Literal[32768] + BELOW_NORMAL_PRIORITY_CLASS: Literal[16384] + CREATE_BREAKAWAY_FROM_JOB: Literal[16777216] + CREATE_DEFAULT_ERROR_MODE: Literal[67108864] + CREATE_NO_WINDOW: Literal[134217728] CREATE_NEW_CONSOLE: Literal[16] CREATE_NEW_PROCESS_GROUP: Literal[512] - if sys.version_info >= (3, 7): - DETACHED_PROCESS: Literal[8] + DETACHED_PROCESS: Literal[8] DUPLICATE_CLOSE_SOURCE: Literal[1] DUPLICATE_SAME_ACCESS: Literal[2] @@ -39,24 +37,21 @@ if sys.platform == "win32": FILE_MAP_EXECUTE: Literal[32] FILE_MAP_READ: Literal[4] FILE_MAP_WRITE: Literal[2] - if sys.version_info >= (3, 7): - FILE_TYPE_CHAR: Literal[2] - FILE_TYPE_DISK: Literal[1] - FILE_TYPE_PIPE: Literal[3] - FILE_TYPE_REMOTE: Literal[32768] - FILE_TYPE_UNKNOWN: Literal[0] + FILE_TYPE_CHAR: Literal[2] + FILE_TYPE_DISK: Literal[1] + FILE_TYPE_PIPE: Literal[3] + FILE_TYPE_REMOTE: Literal[32768] + FILE_TYPE_UNKNOWN: Literal[0] GENERIC_READ: Literal[2147483648] GENERIC_WRITE: Literal[1073741824] - if sys.version_info >= (3, 7): - HIGH_PRIORITY_CLASS: Literal[128] + HIGH_PRIORITY_CLASS: Literal[128] INFINITE: Literal[4294967295] if sys.version_info >= (3, 8): INVALID_HANDLE_VALUE: int # very large number - if sys.version_info >= (3, 7): - IDLE_PRIORITY_CLASS: Literal[64] - NORMAL_PRIORITY_CLASS: Literal[32] - REALTIME_PRIORITY_CLASS: Literal[256] + IDLE_PRIORITY_CLASS: Literal[64] + NORMAL_PRIORITY_CLASS: Literal[32] + REALTIME_PRIORITY_CLASS: Literal[256] NMPWAIT_WAIT_FOREVER: Literal[4294967295] if sys.version_info >= (3, 8): @@ -110,6 +105,24 @@ if sys.platform == "win32": WAIT_ABANDONED_0: Literal[128] WAIT_OBJECT_0: Literal[0] WAIT_TIMEOUT: Literal[258] + + if sys.version_info >= (3, 11): + LOCALE_NAME_INVARIANT: str + LOCALE_NAME_MAX_LENGTH: int + LOCALE_NAME_SYSTEM_DEFAULT: str + LOCALE_NAME_USER_DEFAULT: str | None + + LCMAP_FULLWIDTH: int + LCMAP_HALFWIDTH: int + LCMAP_HIRAGANA: int + LCMAP_KATAKANA: int + LCMAP_LINGUISTIC_CASING: int + LCMAP_LOWERCASE: int + LCMAP_SIMPLIFIED_CHINESE: int + LCMAP_TITLECASE: int + LCMAP_TRADITIONAL_CHINESE: int + LCMAP_UPPERCASE: int + def CloseHandle(__handle: int) -> None: ... @overload def ConnectNamedPipe(handle: int, overlapped: Literal[True]) -> Overlapped: ... @@ -158,10 +171,8 @@ if sys.platform == "win32": __options: int = ..., ) -> int: ... def ExitProcess(__ExitCode: int) -> NoReturn: ... - if sys.version_info >= (3, 7): - def GetACP() -> int: ... - def GetFileType(handle: int) -> int: ... - + def GetACP() -> int: ... + def GetFileType(handle: int) -> int: ... def GetCurrentProcess() -> int: ... def GetExitCodeProcess(__process: int) -> int: ... def GetLastError() -> int: ... @@ -170,6 +181,9 @@ if sys.platform == "win32": def GetVersion() -> int: ... def OpenProcess(__desired_access: int, __inherit_handle: bool, __process_id: int) -> int: ... def PeekNamedPipe(__handle: int, __size: int = ...) -> tuple[int, int] | tuple[bytes, int, int]: ... + if sys.version_info >= (3, 11): + def LCMapStringEx(locale: str, flags: int, src: str) -> str: ... + @overload def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ... @overload diff --git a/mypy/typeshed/stdlib/argparse.pyi b/mypy/typeshed/stdlib/argparse.pyi index 4f6cb6720988..1b86a4e10cbb 100644 --- a/mypy/typeshed/stdlib/argparse.pyi +++ b/mypy/typeshed/stdlib/argparse.pyi @@ -1,6 +1,7 @@ import sys from collections.abc import Callable, Generator, Iterable, Sequence -from typing import IO, Any, Generic, NewType, NoReturn, Pattern, Protocol, TypeVar, overload +from re import Pattern +from typing import IO, Any, Generic, NewType, NoReturn, Protocol, TypeVar, overload from typing_extensions import Literal, TypeAlias __all__ = [ @@ -171,65 +172,35 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore[misc] @overload def parse_args(self, *, namespace: _N) -> _N: ... - if sys.version_info >= (3, 7): - @overload - def add_subparsers( - self: _ArgumentParserT, - *, - title: str = ..., - description: str | None = ..., - prog: str = ..., - action: type[Action] = ..., - option_string: str = ..., - dest: str | None = ..., - required: bool = ..., - help: str | None = ..., - metavar: str | None = ..., - ) -> _SubParsersAction[_ArgumentParserT]: ... - @overload - def add_subparsers( - self, - *, - title: str = ..., - description: str | None = ..., - prog: str = ..., - parser_class: type[_ArgumentParserT], - action: type[Action] = ..., - option_string: str = ..., - dest: str | None = ..., - required: bool = ..., - help: str | None = ..., - metavar: str | None = ..., - ) -> _SubParsersAction[_ArgumentParserT]: ... - else: - @overload - def add_subparsers( - self: _ArgumentParserT, - *, - title: str = ..., - description: str | None = ..., - prog: str = ..., - action: type[Action] = ..., - option_string: str = ..., - dest: str | None = ..., - help: str | None = ..., - metavar: str | None = ..., - ) -> _SubParsersAction[_ArgumentParserT]: ... - @overload - def add_subparsers( - self, - *, - title: str = ..., - description: str | None = ..., - prog: str = ..., - parser_class: type[_ArgumentParserT], - action: type[Action] = ..., - option_string: str = ..., - dest: str | None = ..., - help: str | None = ..., - metavar: str | None = ..., - ) -> _SubParsersAction[_ArgumentParserT]: ... - + @overload + def add_subparsers( + self: _ArgumentParserT, + *, + title: str = ..., + description: str | None = ..., + prog: str = ..., + action: type[Action] = ..., + option_string: str = ..., + dest: str | None = ..., + required: bool = ..., + help: str | None = ..., + metavar: str | None = ..., + ) -> _SubParsersAction[_ArgumentParserT]: ... + @overload + def add_subparsers( + self, + *, + title: str = ..., + description: str | None = ..., + prog: str = ..., + parser_class: type[_ArgumentParserT], + action: type[Action] = ..., + option_string: str = ..., + dest: str | None = ..., + required: bool = ..., + help: str | None = ..., + metavar: str | None = ..., + ) -> _SubParsersAction[_ArgumentParserT]: ... def print_usage(self, file: IO[str] | None = ...) -> None: ... def print_help(self, file: IO[str] | None = ...) -> None: ... def format_usage(self) -> str: ... @@ -240,11 +211,10 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ... def exit(self, status: int = ..., message: str | None = ...) -> NoReturn: ... def error(self, message: str) -> NoReturn: ... - if sys.version_info >= (3, 7): - def parse_intermixed_args(self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...) -> Namespace: ... - def parse_known_intermixed_args( - self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... - ) -> tuple[Namespace, list[str]]: ... + def parse_intermixed_args(self, args: Sequence[str] | None = ..., namespace: Namespace | None = ...) -> Namespace: ... + def parse_known_intermixed_args( + self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... + ) -> tuple[Namespace, list[str]]: ... # undocumented def _get_optional_actions(self) -> list[Action]: ... def _get_positional_actions(self) -> list[Action]: ... @@ -478,27 +448,16 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): _name_parser_map: dict[str, _ArgumentParserT] choices: dict[str, _ArgumentParserT] _choices_actions: list[Action] - if sys.version_info >= (3, 7): - def __init__( - self, - option_strings: Sequence[str], - prog: str, - parser_class: type[_ArgumentParserT], - dest: str = ..., - required: bool = ..., - help: str | None = ..., - metavar: str | tuple[str, ...] | None = ..., - ) -> None: ... - else: - def __init__( - self, - option_strings: Sequence[str], - prog: str, - parser_class: type[_ArgumentParserT], - dest: str = ..., - help: str | None = ..., - metavar: str | tuple[str, ...] | None = ..., - ) -> None: ... + def __init__( + self, + option_strings: Sequence[str], + prog: str, + parser_class: type[_ArgumentParserT], + dest: str = ..., + required: bool = ..., + help: str | None = ..., + metavar: str | tuple[str, ...] | None = ..., + ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: str, **kwargs: Any) -> _ArgumentParserT: ... def _get_subactions(self) -> list[Action]: ... @@ -506,9 +465,5 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]): # undocumented class ArgumentTypeError(Exception): ... -if sys.version_info < (3, 7): - # undocumented - def _ensure_value(namespace: Namespace, name: str, value: Any) -> Any: ... - # undocumented def _get_action_name(argument: Action | None) -> str | None: ... diff --git a/mypy/typeshed/stdlib/asyncio/__init__.pyi b/mypy/typeshed/stdlib/asyncio/__init__.pyi index 24a86caed66e..4afcd37f5d4a 100644 --- a/mypy/typeshed/stdlib/asyncio/__init__.pyi +++ b/mypy/typeshed/stdlib/asyncio/__init__.pyi @@ -8,14 +8,12 @@ from .futures import * from .locks import * from .protocols import * from .queues import * +from .runners import * from .streams import * from .subprocess import * from .tasks import * from .transports import * -if sys.version_info >= (3, 7): - from .runners import * - if sys.version_info >= (3, 8): from .exceptions import * diff --git a/mypy/typeshed/stdlib/asyncio/base_events.pyi b/mypy/typeshed/stdlib/asyncio/base_events.pyi index e413730bc0be..8697bfe306c4 100644 --- a/mypy/typeshed/stdlib/asyncio/base_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/base_events.pyi @@ -7,24 +7,20 @@ from asyncio.protocols import BaseProtocol from asyncio.tasks import Task from asyncio.transports import BaseTransport, ReadTransport, SubprocessTransport, WriteTransport from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable, Sequence +from contextvars import Context from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket from typing import IO, Any, TypeVar, overload from typing_extensions import Literal, TypeAlias -if sys.version_info >= (3, 7): - from contextvars import Context - if sys.version_info >= (3, 9): __all__ = ("BaseEventLoop", "Server") -elif sys.version_info >= (3, 7): - __all__ = ("BaseEventLoop",) else: - __all__ = ["BaseEventLoop"] + __all__ = ("BaseEventLoop",) _T = TypeVar("_T") _ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol) _Context: TypeAlias = dict[str, Any] -_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], Any] +_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object] _ProtocolFactory: TypeAlias = Callable[[], BaseProtocol] _SSLContext: TypeAlias = bool | None | ssl.SSLContext @@ -40,7 +36,7 @@ class Server(AbstractServer): ssl_handshake_timeout: float | None, ssl_shutdown_timeout: float | None = ..., ) -> None: ... - elif sys.version_info >= (3, 7): + else: def __init__( self, loop: AbstractEventLoop, @@ -50,21 +46,18 @@ class Server(AbstractServer): backlog: int, ssl_handshake_timeout: float | None, ) -> None: ... - else: - def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ... - if sys.version_info >= (3, 7): - def get_loop(self) -> AbstractEventLoop: ... - def is_serving(self) -> bool: ... - async def start_serving(self) -> None: ... - async def serve_forever(self) -> None: ... + + def get_loop(self) -> AbstractEventLoop: ... + def is_serving(self) -> bool: ... + async def start_serving(self) -> None: ... + async def serve_forever(self) -> None: ... if sys.version_info >= (3, 8): @property def sockets(self) -> tuple[socket, ...]: ... - elif sys.version_info >= (3, 7): + else: @property def sockets(self) -> list[socket]: ... - else: - sockets: list[socket] | None + def close(self) -> None: ... async def wait_closed(self) -> None: ... @@ -81,19 +74,11 @@ class BaseEventLoop(AbstractEventLoop): def close(self) -> None: ... async def shutdown_asyncgens(self) -> None: ... # Methods scheduling callbacks. All these return Handles. - if sys.version_info >= (3, 7): - def call_soon(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> Handle: ... - def call_later( - self, delay: float, callback: Callable[..., Any], *args: Any, context: Context | None = ... - ) -> TimerHandle: ... - def call_at( - self, when: float, callback: Callable[..., Any], *args: Any, context: Context | None = ... - ) -> TimerHandle: ... - else: - def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ... - def call_later(self, delay: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... - def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... - + def call_soon(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ... + def call_later( + self, delay: float, callback: Callable[..., object], *args: Any, context: Context | None = ... + ) -> TimerHandle: ... + def call_at(self, when: float, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> TimerHandle: ... def time(self) -> float: ... # Future methods def create_future(self) -> Future[Any]: ... @@ -110,11 +95,7 @@ class BaseEventLoop(AbstractEventLoop): def set_task_factory(self, factory: _TaskFactory | None) -> None: ... def get_task_factory(self) -> _TaskFactory | None: ... # Methods for interacting with threads - if sys.version_info >= (3, 7): - def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> Handle: ... - else: - def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... - + def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ... def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Future[_T]: ... def set_default_executor(self, executor: Any) -> None: ... # Network I/O methods returning Futures. @@ -205,7 +186,7 @@ class BaseEventLoop(AbstractEventLoop): happy_eyeballs_delay: float | None = ..., interleave: int | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - elif sys.version_info >= (3, 7): + else: @overload async def create_connection( self, @@ -238,37 +219,6 @@ class BaseEventLoop(AbstractEventLoop): server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - else: - @overload - async def create_connection( - self, - protocol_factory: Callable[[], _ProtocolT], - host: str = ..., - port: int = ..., - *, - ssl: _SSLContext = ..., - family: int = ..., - proto: int = ..., - flags: int = ..., - sock: None = ..., - local_addr: tuple[str, int] | None = ..., - server_hostname: str | None = ..., - ) -> tuple[BaseTransport, _ProtocolT]: ... - @overload - async def create_connection( - self, - protocol_factory: Callable[[], _ProtocolT], - host: None = ..., - port: None = ..., - *, - ssl: _SSLContext = ..., - family: int = ..., - proto: int = ..., - flags: int = ..., - sock: socket, - local_addr: None = ..., - server_hostname: str | None = ..., - ) -> tuple[BaseTransport, _ProtocolT]: ... if sys.version_info >= (3, 11): @overload async def create_server( @@ -326,7 +276,7 @@ class BaseEventLoop(AbstractEventLoop): ssl_handshake_timeout: float | None = ..., ssl_shutdown_timeout: float | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - elif sys.version_info >= (3, 7): + else: @overload async def create_server( self, @@ -379,47 +329,13 @@ class BaseEventLoop(AbstractEventLoop): ssl: _SSLContext = ..., ssl_handshake_timeout: float | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - else: - @overload - async def create_server( - self, - protocol_factory: _ProtocolFactory, - host: str | Sequence[str] | None = ..., - port: int = ..., - *, - family: int = ..., - flags: int = ..., - sock: None = ..., - backlog: int = ..., - ssl: _SSLContext = ..., - reuse_address: bool | None = ..., - reuse_port: bool | None = ..., - ) -> Server: ... - @overload - async def create_server( - self, - protocol_factory: _ProtocolFactory, - host: None = ..., - port: None = ..., - *, - family: int = ..., - flags: int = ..., - sock: socket, - backlog: int = ..., - ssl: _SSLContext = ..., - reuse_address: bool | None = ..., - reuse_port: bool | None = ..., - ) -> Server: ... - async def connect_accepted_socket( - self, protocol_factory: Callable[[], _ProtocolT], sock: socket, *, ssl: _SSLContext = ... - ) -> tuple[BaseTransport, _ProtocolT]: ... - if sys.version_info >= (3, 7): - async def sock_sendfile( - self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ... - ) -> int: ... - async def sendfile( - self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ... - ) -> int: ... + + async def sock_sendfile( + self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ... + ) -> int: ... + async def sendfile( + self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ... + ) -> int: ... if sys.version_info >= (3, 11): async def create_datagram_endpoint( # type: ignore[override] self, @@ -493,18 +409,11 @@ class BaseEventLoop(AbstractEventLoop): def remove_writer(self, fd: FileDescriptorLike) -> bool: ... # The sock_* methods (and probably some others) are not actually implemented on # BaseEventLoop, only on subclasses. We list them here for now for convenience. - # Completion based I/O methods returning Futures prior to 3.7 - if sys.version_info >= (3, 7): - async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ... - async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ... - async def sock_sendall(self, sock: socket, data: bytes) -> None: ... - async def sock_connect(self, sock: socket, address: _Address) -> None: ... - async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ... - else: - def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ... - def sock_sendall(self, sock: socket, data: bytes) -> Future[None]: ... - def sock_connect(self, sock: socket, address: _Address) -> Future[None]: ... - def sock_accept(self, sock: socket) -> Future[tuple[socket, _RetAddress]]: ... + async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ... + async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ... + async def sock_sendall(self, sock: socket, data: bytes) -> None: ... + async def sock_connect(self, sock: socket, address: _Address) -> None: ... + async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ... if sys.version_info >= (3, 11): async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ... async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = ...) -> int: ... diff --git a/mypy/typeshed/stdlib/asyncio/base_futures.pyi b/mypy/typeshed/stdlib/asyncio/base_futures.pyi index 8a973d1618f4..c51174ef23cd 100644 --- a/mypy/typeshed/stdlib/asyncio/base_futures.pyi +++ b/mypy/typeshed/stdlib/asyncio/base_futures.pyi @@ -1,17 +1,11 @@ -import sys from collections.abc import Callable, Sequence +from contextvars import Context from typing import Any from typing_extensions import Literal -if sys.version_info >= (3, 7): - from contextvars import Context - from . import futures -if sys.version_info >= (3, 7): - __all__ = () -else: - __all__: list[str] = [] +__all__ = () # asyncio defines 'isfuture()' in base_futures.py and re-imports it in futures.py # but it leads to circular import error in pytype tool. @@ -22,10 +16,5 @@ _PENDING: Literal["PENDING"] # undocumented _CANCELLED: Literal["CANCELLED"] # undocumented _FINISHED: Literal["FINISHED"] # undocumented -if sys.version_info >= (3, 7): - def _format_callbacks(cb: Sequence[tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented - -else: - def _format_callbacks(cb: Sequence[Callable[[futures.Future[Any]], None]]) -> str: ... # undocumented - +def _format_callbacks(cb: Sequence[tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented def _future_repr_info(future: futures.Future[Any]) -> list[str]: ... # undocumented diff --git a/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi b/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi index 963cfa93de28..44606b6d137c 100644 --- a/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi +++ b/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi @@ -56,7 +56,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): def terminate(self) -> None: ... def kill(self) -> None: ... async def _connect_pipes(self, waiter: futures.Future[Any] | None) -> None: ... # undocumented - def _call(self, cb: Callable[..., Any], *data: Any) -> None: ... # undocumented + def _call(self, cb: Callable[..., object], *data: Any) -> None: ... # undocumented def _pipe_connection_lost(self, fd: int, exc: BaseException | None) -> None: ... # undocumented def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented def _process_exited(self, returncode: int) -> None: ... # undocumented diff --git a/mypy/typeshed/stdlib/asyncio/compat.pyi b/mypy/typeshed/stdlib/asyncio/compat.pyi deleted file mode 100644 index f6f1bbca7faf..000000000000 --- a/mypy/typeshed/stdlib/asyncio/compat.pyi +++ /dev/null @@ -1,5 +0,0 @@ -PY34: bool -PY35: bool -PY352: bool - -def flatten_list_bytes(list_of_data: list[bytes]) -> bytes: ... diff --git a/mypy/typeshed/stdlib/asyncio/constants.pyi b/mypy/typeshed/stdlib/asyncio/constants.pyi index 1fa643c7414b..af209fa9ee62 100644 --- a/mypy/typeshed/stdlib/asyncio/constants.pyi +++ b/mypy/typeshed/stdlib/asyncio/constants.pyi @@ -5,9 +5,8 @@ from typing_extensions import Literal LOG_THRESHOLD_FOR_CONNLOST_WRITES: Literal[5] ACCEPT_RETRY_DELAY: Literal[1] DEBUG_STACK_DEPTH: Literal[10] -if sys.version_info >= (3, 7): - SSL_HANDSHAKE_TIMEOUT: float - SENDFILE_FALLBACK_READBUFFER_SIZE: Literal[262144] +SSL_HANDSHAKE_TIMEOUT: float +SENDFILE_FALLBACK_READBUFFER_SIZE: Literal[262144] if sys.version_info >= (3, 11): SSL_SHUTDOWN_TIMEOUT: float FLOW_CONTROL_HIGH_WATER_SSL_READ: Literal[256] diff --git a/mypy/typeshed/stdlib/asyncio/coroutines.pyi b/mypy/typeshed/stdlib/asyncio/coroutines.pyi index 5c640af5a1ca..14fb627ae6fe 100644 --- a/mypy/typeshed/stdlib/asyncio/coroutines.pyi +++ b/mypy/typeshed/stdlib/asyncio/coroutines.pyi @@ -1,23 +1,28 @@ import sys -from collections.abc import Coroutine -from typing import Any -from typing_extensions import TypeGuard +from collections.abc import Awaitable, Callable, Coroutine +from typing import Any, TypeVar, overload +from typing_extensions import ParamSpec, TypeGuard if sys.version_info >= (3, 11): __all__ = ("iscoroutinefunction", "iscoroutine") -elif sys.version_info >= (3, 7): - __all__ = ("coroutine", "iscoroutinefunction", "iscoroutine") else: - __all__ = ["coroutine", "iscoroutinefunction", "iscoroutine"] + __all__ = ("coroutine", "iscoroutinefunction", "iscoroutine") -if sys.version_info < (3, 11): - from collections.abc import Callable - from typing import TypeVar +_T = TypeVar("_T") +_FunctionT = TypeVar("_FunctionT", bound=Callable[..., Any]) +_P = ParamSpec("_P") - _F = TypeVar("_F", bound=Callable[..., Any]) - def coroutine(func: _F) -> _F: ... +if sys.version_info < (3, 11): + def coroutine(func: _FunctionT) -> _FunctionT: ... -def iscoroutinefunction(func: object) -> bool: ... +@overload +def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ... +@overload +def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ... +@overload +def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ... +@overload +def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ... # Can actually be a generator-style coroutine on Python 3.7 def iscoroutine(obj: object) -> TypeGuard[Coroutine[Any, Any, Any]]: ... diff --git a/mypy/typeshed/stdlib/asyncio/events.pyi b/mypy/typeshed/stdlib/asyncio/events.pyi index fb4dac56f01e..0eeebbc3ab8f 100644 --- a/mypy/typeshed/stdlib/asyncio/events.pyi +++ b/mypy/typeshed/stdlib/asyncio/events.pyi @@ -1,8 +1,9 @@ import ssl import sys -from _typeshed import FileDescriptorLike, Self, WriteableBuffer +from _typeshed import FileDescriptorLike, Self, StrPath, WriteableBuffer from abc import ABCMeta, abstractmethod from collections.abc import Awaitable, Callable, Coroutine, Generator, Sequence +from contextvars import Context from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket from typing import IO, Any, Protocol, TypeVar, overload from typing_extensions import Literal, TypeAlias @@ -14,9 +15,6 @@ from .tasks import Task from .transports import BaseTransport, ReadTransport, SubprocessTransport, WriteTransport from .unix_events import AbstractChildWatcher -if sys.version_info >= (3, 7): - from contextvars import Context - if sys.version_info >= (3, 8): __all__ = ( "AbstractEventLoopPolicy", @@ -36,7 +34,7 @@ if sys.version_info >= (3, 8): "_get_running_loop", ) -elif sys.version_info >= (3, 7): +else: __all__ = ( "AbstractEventLoopPolicy", "AbstractEventLoop", @@ -56,28 +54,10 @@ elif sys.version_info >= (3, 7): "_get_running_loop", ) -else: - __all__ = [ - "AbstractEventLoopPolicy", - "AbstractEventLoop", - "AbstractServer", - "Handle", - "TimerHandle", - "get_event_loop_policy", - "set_event_loop_policy", - "get_event_loop", - "set_event_loop", - "new_event_loop", - "get_child_watcher", - "set_child_watcher", - "_set_running_loop", - "_get_running_loop", - ] - _T = TypeVar("_T") _ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol) _Context: TypeAlias = dict[str, Any] -_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], Any] +_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object] _ProtocolFactory: TypeAlias = Callable[[], BaseProtocol] _SSLContext: TypeAlias = bool | None | ssl.SSLContext @@ -89,35 +69,24 @@ class _TaskFactory(Protocol): class Handle: _cancelled: bool _args: Sequence[Any] - if sys.version_info >= (3, 7): - def __init__( - self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = ... - ) -> None: ... - else: - def __init__(self, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ... - + def __init__( + self, callback: Callable[..., object], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = ... + ) -> None: ... def cancel(self) -> None: ... def _run(self) -> None: ... - if sys.version_info >= (3, 7): - def cancelled(self) -> bool: ... + def cancelled(self) -> bool: ... class TimerHandle(Handle): - if sys.version_info >= (3, 7): - def __init__( - self, - when: float, - callback: Callable[..., Any], - args: Sequence[Any], - loop: AbstractEventLoop, - context: Context | None = ..., - ) -> None: ... - else: - def __init__(self, when: float, callback: Callable[..., Any], args: Sequence[Any], loop: AbstractEventLoop) -> None: ... - + def __init__( + self, + when: float, + callback: Callable[..., object], + args: Sequence[Any], + loop: AbstractEventLoop, + context: Context | None = ..., + ) -> None: ... def __hash__(self) -> int: ... - if sys.version_info >= (3, 7): - def when(self) -> float: ... - + def when(self) -> float: ... def __lt__(self, other: TimerHandle) -> bool: ... def __le__(self, other: TimerHandle) -> bool: ... def __gt__(self, other: TimerHandle) -> bool: ... @@ -127,18 +96,16 @@ class TimerHandle(Handle): class AbstractServer: @abstractmethod def close(self) -> None: ... - if sys.version_info >= (3, 7): - async def __aenter__(self: Self) -> Self: ... - async def __aexit__(self, *exc: object) -> None: ... - @abstractmethod - def get_loop(self) -> AbstractEventLoop: ... - @abstractmethod - def is_serving(self) -> bool: ... - @abstractmethod - async def start_serving(self) -> None: ... - @abstractmethod - async def serve_forever(self) -> None: ... - + async def __aenter__(self: Self) -> Self: ... + async def __aexit__(self, *exc: object) -> None: ... + @abstractmethod + def get_loop(self) -> AbstractEventLoop: ... + @abstractmethod + def is_serving(self) -> bool: ... + @abstractmethod + async def start_serving(self) -> None: ... + @abstractmethod + async def serve_forever(self) -> None: ... @abstractmethod async def wait_closed(self) -> None: ... @@ -166,22 +133,22 @@ class AbstractEventLoop: # Methods scheduling callbacks. All these return Handles. if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2 @abstractmethod - def call_soon(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> Handle: ... + def call_soon(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ... @abstractmethod def call_later( - self, delay: float, callback: Callable[..., Any], *args: Any, context: Context | None = ... + self, delay: float, callback: Callable[..., object], *args: Any, context: Context | None = ... ) -> TimerHandle: ... @abstractmethod def call_at( - self, when: float, callback: Callable[..., Any], *args: Any, context: Context | None = ... + self, when: float, callback: Callable[..., object], *args: Any, context: Context | None = ... ) -> TimerHandle: ... else: @abstractmethod - def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ... + def call_soon(self, callback: Callable[..., object], *args: Any) -> Handle: ... @abstractmethod - def call_later(self, delay: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... + def call_later(self, delay: float, callback: Callable[..., object], *args: Any) -> TimerHandle: ... @abstractmethod - def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> TimerHandle: ... + def call_at(self, when: float, callback: Callable[..., object], *args: Any) -> TimerHandle: ... @abstractmethod def time(self) -> float: ... @@ -214,10 +181,10 @@ class AbstractEventLoop: # Methods for interacting with threads if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2 @abstractmethod - def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Context | None = ...) -> Handle: ... + def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any, context: Context | None = ...) -> Handle: ... else: @abstractmethod - def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... + def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any) -> Handle: ... @abstractmethod def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Future[_T]: ... @@ -317,7 +284,7 @@ class AbstractEventLoop: happy_eyeballs_delay: float | None = ..., interleave: int | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - elif sys.version_info >= (3, 7): + else: @overload @abstractmethod async def create_connection( @@ -352,39 +319,6 @@ class AbstractEventLoop: server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - else: - @overload - @abstractmethod - async def create_connection( - self, - protocol_factory: Callable[[], _ProtocolT], - host: str = ..., - port: int = ..., - *, - ssl: _SSLContext = ..., - family: int = ..., - proto: int = ..., - flags: int = ..., - sock: None = ..., - local_addr: tuple[str, int] | None = ..., - server_hostname: str | None = ..., - ) -> tuple[BaseTransport, _ProtocolT]: ... - @overload - @abstractmethod - async def create_connection( - self, - protocol_factory: Callable[[], _ProtocolT], - host: None = ..., - port: None = ..., - *, - ssl: _SSLContext = ..., - family: int = ..., - proto: int = ..., - flags: int = ..., - sock: socket, - local_addr: None = ..., - server_hostname: str | None = ..., - ) -> tuple[BaseTransport, _ProtocolT]: ... if sys.version_info >= (3, 11): @overload @abstractmethod @@ -439,7 +373,7 @@ class AbstractEventLoop: async def create_unix_server( self, protocol_factory: _ProtocolFactory, - path: str | None = ..., + path: StrPath | None = ..., *, sock: socket | None = ..., backlog: int = ..., @@ -448,7 +382,7 @@ class AbstractEventLoop: ssl_shutdown_timeout: float | None = ..., start_serving: bool = ..., ) -> Server: ... - elif sys.version_info >= (3, 7): + else: @overload @abstractmethod async def create_server( @@ -499,7 +433,7 @@ class AbstractEventLoop: async def create_unix_server( self, protocol_factory: _ProtocolFactory, - path: str | None = ..., + path: StrPath | None = ..., *, sock: socket | None = ..., backlog: int = ..., @@ -507,48 +441,6 @@ class AbstractEventLoop: ssl_handshake_timeout: float | None = ..., start_serving: bool = ..., ) -> Server: ... - else: - @overload - @abstractmethod - async def create_server( - self, - protocol_factory: _ProtocolFactory, - host: str | Sequence[str] | None = ..., - port: int = ..., - *, - family: int = ..., - flags: int = ..., - sock: None = ..., - backlog: int = ..., - ssl: _SSLContext = ..., - reuse_address: bool | None = ..., - reuse_port: bool | None = ..., - ) -> Server: ... - @overload - @abstractmethod - async def create_server( - self, - protocol_factory: _ProtocolFactory, - host: None = ..., - port: None = ..., - *, - family: int = ..., - flags: int = ..., - sock: socket, - backlog: int = ..., - ssl: _SSLContext = ..., - reuse_address: bool | None = ..., - reuse_port: bool | None = ..., - ) -> Server: ... - async def create_unix_server( - self, - protocol_factory: _ProtocolFactory, - path: str, - *, - sock: socket | None = ..., - backlog: int = ..., - ssl: _SSLContext = ..., - ) -> Server: ... if sys.version_info >= (3, 11): async def connect_accepted_socket( self, @@ -580,7 +472,7 @@ class AbstractEventLoop: ssl_handshake_timeout: float | None = ..., ssl_shutdown_timeout: float | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - elif sys.version_info >= (3, 7): + else: async def create_unix_connection( self, protocol_factory: Callable[[], _ProtocolT], @@ -591,26 +483,15 @@ class AbstractEventLoop: server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., ) -> tuple[BaseTransport, _ProtocolT]: ... - else: - async def create_unix_connection( - self, - protocol_factory: Callable[[], _ProtocolT], - path: str, - *, - ssl: _SSLContext = ..., - sock: socket | None = ..., - server_hostname: str | None = ..., - ) -> tuple[BaseTransport, _ProtocolT]: ... - if sys.version_info >= (3, 7): - @abstractmethod - async def sock_sendfile( - self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ... - ) -> int: ... - @abstractmethod - async def sendfile( - self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ... - ) -> int: ... + @abstractmethod + async def sock_sendfile( + self, sock: socket, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool | None = ... + ) -> int: ... + @abstractmethod + async def sendfile( + self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: int | None = ..., *, fallback: bool = ... + ) -> int: ... @abstractmethod async def create_datagram_endpoint( self, @@ -677,26 +558,16 @@ class AbstractEventLoop: @abstractmethod def remove_writer(self, fd: FileDescriptorLike) -> bool: ... # Completion based I/O methods returning Futures prior to 3.7 - if sys.version_info >= (3, 7): - @abstractmethod - async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ... - @abstractmethod - async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ... - @abstractmethod - async def sock_sendall(self, sock: socket, data: bytes) -> None: ... - @abstractmethod - async def sock_connect(self, sock: socket, address: _Address) -> None: ... - @abstractmethod - async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ... - else: - @abstractmethod - def sock_recv(self, sock: socket, nbytes: int) -> Future[bytes]: ... - @abstractmethod - def sock_sendall(self, sock: socket, data: bytes) -> Future[None]: ... - @abstractmethod - def sock_connect(self, sock: socket, address: _Address) -> Future[None]: ... - @abstractmethod - def sock_accept(self, sock: socket) -> Future[tuple[socket, _RetAddress]]: ... + @abstractmethod + async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ... + @abstractmethod + async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ... + @abstractmethod + async def sock_sendall(self, sock: socket, data: bytes) -> None: ... + @abstractmethod + async def sock_connect(self, sock: socket, address: _Address) -> None: ... + @abstractmethod + async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ... if sys.version_info >= (3, 11): @abstractmethod async def sock_recvfrom(self, sock: socket, bufsize: int) -> bytes: ... @@ -706,7 +577,7 @@ class AbstractEventLoop: async def sock_sendto(self, sock: socket, data: bytes, address: _Address) -> None: ... # Signal handling. @abstractmethod - def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ... + def add_signal_handler(self, sig: int, callback: Callable[..., object], *args: Any) -> None: ... @abstractmethod def remove_signal_handler(self, sig: int) -> bool: ... # Error handlers. @@ -755,8 +626,7 @@ def get_child_watcher() -> AbstractChildWatcher: ... def set_child_watcher(watcher: AbstractChildWatcher) -> None: ... def _set_running_loop(__loop: AbstractEventLoop | None) -> None: ... def _get_running_loop() -> AbstractEventLoop: ... +def get_running_loop() -> AbstractEventLoop: ... -if sys.version_info >= (3, 7): - def get_running_loop() -> AbstractEventLoop: ... - if sys.version_info < (3, 8): - class SendfileNotAvailableError(RuntimeError): ... +if sys.version_info < (3, 8): + class SendfileNotAvailableError(RuntimeError): ... diff --git a/mypy/typeshed/stdlib/asyncio/futures.pyi b/mypy/typeshed/stdlib/asyncio/futures.pyi index 21bfe86e44c6..f917bd5dee98 100644 --- a/mypy/typeshed/stdlib/asyncio/futures.pyi +++ b/mypy/typeshed/stdlib/asyncio/futures.pyi @@ -12,18 +12,15 @@ if sys.version_info < (3, 8): class InvalidStateError(Error): ... -if sys.version_info >= (3, 7): - from contextvars import Context +from contextvars import Context if sys.version_info >= (3, 9): from types import GenericAlias if sys.version_info >= (3, 8): __all__ = ("Future", "wrap_future", "isfuture") -elif sys.version_info >= (3, 7): - __all__ = ("CancelledError", "TimeoutError", "InvalidStateError", "Future", "wrap_future", "isfuture") else: - __all__ = ["CancelledError", "TimeoutError", "InvalidStateError", "Future", "wrap_future", "isfuture"] + __all__ = ("CancelledError", "TimeoutError", "InvalidStateError", "Future", "wrap_future", "isfuture") _T = TypeVar("_T") @@ -32,15 +29,6 @@ _T = TypeVar("_T") # That's why the import order is reversed. def isfuture(obj: object) -> TypeGuard[Future[Any]]: ... -if sys.version_info < (3, 7): - class _TracebackLogger: - exc: BaseException - tb: list[str] - def __init__(self, exc: Any, loop: AbstractEventLoop) -> None: ... - def activate(self) -> None: ... - def clear(self) -> None: ... - def __del__(self) -> None: ... - class Future(Awaitable[_T], Iterable[_T]): _state: str @property @@ -53,15 +41,10 @@ class Future(Awaitable[_T], Iterable[_T]): _asyncio_future_blocking: bool # is a part of duck-typing contract for `Future` def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ... def __del__(self) -> None: ... - if sys.version_info >= (3, 7): - def get_loop(self) -> AbstractEventLoop: ... - @property - def _callbacks(self: Self) -> list[tuple[Callable[[Self], Any], Context]]: ... - def add_done_callback(self: Self, __fn: Callable[[Self], Any], *, context: Context | None = ...) -> None: ... - else: - @property - def _callbacks(self: Self) -> list[Callable[[Self], Any]]: ... - def add_done_callback(self: Self, __fn: Callable[[Self], Any]) -> None: ... + def get_loop(self) -> AbstractEventLoop: ... + @property + def _callbacks(self: Self) -> list[tuple[Callable[[Self], Any], Context]]: ... + def add_done_callback(self: Self, __fn: Callable[[Self], object], *, context: Context | None = ...) -> None: ... if sys.version_info >= (3, 9): def cancel(self, msg: Any | None = ...) -> bool: ... else: @@ -71,7 +54,7 @@ class Future(Awaitable[_T], Iterable[_T]): def done(self) -> bool: ... def result(self) -> _T: ... def exception(self) -> BaseException | None: ... - def remove_done_callback(self: Self, __fn: Callable[[Self], Any]) -> int: ... + def remove_done_callback(self: Self, __fn: Callable[[Self], object]) -> int: ... def set_result(self, __result: _T) -> None: ... def set_exception(self, __exception: type | BaseException) -> None: ... def __iter__(self) -> Generator[Any, None, _T]: ... diff --git a/mypy/typeshed/stdlib/asyncio/locks.pyi b/mypy/typeshed/stdlib/asyncio/locks.pyi index 269602c7bc66..61f8a81dedc7 100644 --- a/mypy/typeshed/stdlib/asyncio/locks.pyi +++ b/mypy/typeshed/stdlib/asyncio/locks.pyi @@ -15,10 +15,8 @@ if sys.version_info >= (3, 11): if sys.version_info >= (3, 11): __all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore", "Barrier") -elif sys.version_info >= (3, 7): - __all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore") else: - __all__ = ["Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore"] + __all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore") _T = TypeVar("_T") diff --git a/mypy/typeshed/stdlib/asyncio/proactor_events.pyi b/mypy/typeshed/stdlib/asyncio/proactor_events.pyi index 21247401c9ba..665a885a1773 100644 --- a/mypy/typeshed/stdlib/asyncio/proactor_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/proactor_events.pyi @@ -6,16 +6,13 @@ from typing_extensions import Literal from . import base_events, constants, events, futures, streams, transports -if sys.version_info >= (3, 7): - __all__ = ("BaseProactorEventLoop",) -else: - __all__ = ["BaseProactorEventLoop"] +__all__ = ("BaseProactorEventLoop",) if sys.version_info >= (3, 8): class _WarnCallbackProtocol(Protocol): def __call__( self, message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... - ) -> None: ... + ) -> object: ... class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): def __init__( diff --git a/mypy/typeshed/stdlib/asyncio/protocols.pyi b/mypy/typeshed/stdlib/asyncio/protocols.pyi index e2fc118947bc..5173b74ed5a0 100644 --- a/mypy/typeshed/stdlib/asyncio/protocols.pyi +++ b/mypy/typeshed/stdlib/asyncio/protocols.pyi @@ -1,12 +1,8 @@ -import sys from _typeshed import ReadableBuffer from asyncio import transports from typing import Any -if sys.version_info >= (3, 7): - __all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol") -else: - __all__ = ["BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol"] +__all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol") class BaseProtocol: def connection_made(self, transport: transports.BaseTransport) -> None: ... @@ -18,11 +14,10 @@ class Protocol(BaseProtocol): def data_received(self, data: bytes) -> None: ... def eof_received(self) -> bool | None: ... -if sys.version_info >= (3, 7): - class BufferedProtocol(BaseProtocol): - def get_buffer(self, sizehint: int) -> ReadableBuffer: ... - def buffer_updated(self, nbytes: int) -> None: ... - def eof_received(self) -> bool | None: ... +class BufferedProtocol(BaseProtocol): + def get_buffer(self, sizehint: int) -> ReadableBuffer: ... + def buffer_updated(self, nbytes: int) -> None: ... + def eof_received(self) -> bool | None: ... class DatagramProtocol(BaseProtocol): def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override] diff --git a/mypy/typeshed/stdlib/asyncio/queues.pyi b/mypy/typeshed/stdlib/asyncio/queues.pyi index 0e1a0b2808df..90ba39aebb96 100644 --- a/mypy/typeshed/stdlib/asyncio/queues.pyi +++ b/mypy/typeshed/stdlib/asyncio/queues.pyi @@ -5,10 +5,7 @@ from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias -if sys.version_info >= (3, 7): - __all__ = ("Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty") -else: - __all__ = ["Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty"] +__all__ = ("Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty") class QueueEmpty(Exception): ... class QueueFull(Exception): ... diff --git a/mypy/typeshed/stdlib/asyncio/selector_events.pyi b/mypy/typeshed/stdlib/asyncio/selector_events.pyi index 698bfef351a1..c5468d4d72c7 100644 --- a/mypy/typeshed/stdlib/asyncio/selector_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/selector_events.pyi @@ -1,12 +1,8 @@ import selectors -import sys from . import base_events -if sys.version_info >= (3, 7): - __all__ = ("BaseSelectorEventLoop",) -else: - __all__ = ["BaseSelectorEventLoop"] +__all__ = ("BaseSelectorEventLoop",) class BaseSelectorEventLoop(base_events.BaseEventLoop): def __init__(self, selector: selectors.BaseSelector | None = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncio/sslproto.pyi b/mypy/typeshed/stdlib/asyncio/sslproto.pyi index 1d3d6d7c83ec..34414d649297 100644 --- a/mypy/typeshed/stdlib/asyncio/sslproto.pyi +++ b/mypy/typeshed/stdlib/asyncio/sslproto.pyi @@ -57,8 +57,8 @@ if sys.version_info < (3, 11): def need_ssldata(self) -> bool: ... @property def wrapped(self) -> bool: ... - def do_handshake(self, callback: Callable[[BaseException | None], None] | None = ...) -> list[bytes]: ... - def shutdown(self, callback: Callable[[], None] | None = ...) -> list[bytes]: ... + def do_handshake(self, callback: Callable[[BaseException | None], object] | None = ...) -> list[bytes]: ... + def shutdown(self, callback: Callable[[], object] | None = ...) -> list[bytes]: ... def feed_eof(self) -> None: ... def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> tuple[list[bytes], list[bytes]]: ... def feed_appdata(self, data: bytes, offset: int = ...) -> tuple[list[bytes], int]: ... @@ -76,17 +76,13 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): def get_protocol(self) -> protocols.BaseProtocol: ... def is_closing(self) -> bool: ... def close(self) -> None: ... - if sys.version_info >= (3, 7): - def is_reading(self) -> bool: ... - + def is_reading(self) -> bool: ... def pause_reading(self) -> None: ... def resume_reading(self) -> None: ... def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ... def get_write_buffer_size(self) -> int: ... - if sys.version_info >= (3, 7): - @property - def _protocol_paused(self) -> bool: ... - + @property + def _protocol_paused(self) -> bool: ... def write(self, data: bytes) -> None: ... def can_write_eof(self) -> Literal[False]: ... def abort(self) -> None: ... @@ -138,18 +134,6 @@ class SSLProtocol(_SSLProtocolBase): ssl_handshake_timeout: int | None = ..., ssl_shutdown_timeout: float | None = ..., ) -> None: ... - elif sys.version_info >= (3, 7): - def __init__( - self, - loop: events.AbstractEventLoop, - app_protocol: protocols.BaseProtocol, - sslcontext: ssl.SSLContext, - waiter: futures.Future[Any], - server_side: bool = ..., - server_hostname: str | None = ..., - call_connection_made: bool = ..., - ssl_handshake_timeout: int | None = ..., - ) -> None: ... else: def __init__( self, @@ -160,10 +144,10 @@ class SSLProtocol(_SSLProtocolBase): server_side: bool = ..., server_hostname: str | None = ..., call_connection_made: bool = ..., + ssl_handshake_timeout: int | None = ..., ) -> None: ... - if sys.version_info >= (3, 7): - def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ... + def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ... def _wakeup_waiter(self, exc: BaseException | None = ...) -> None: ... def connection_made(self, transport: transports.BaseTransport) -> None: ... def connection_lost(self, exc: BaseException | None) -> None: ... @@ -178,9 +162,7 @@ class SSLProtocol(_SSLProtocolBase): def _write_appdata(self, data: bytes) -> None: ... def _start_handshake(self) -> None: ... - if sys.version_info >= (3, 7): - def _check_handshake_timeout(self) -> None: ... - + def _check_handshake_timeout(self) -> None: ... def _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ... def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ... def _abort(self) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncio/streams.pyi b/mypy/typeshed/stdlib/asyncio/streams.pyi index 0f24d01d50cf..5bf2d3620dbe 100644 --- a/mypy/typeshed/stdlib/asyncio/streams.pyi +++ b/mypy/typeshed/stdlib/asyncio/streams.pyi @@ -11,7 +11,7 @@ from .base_events import Server if sys.platform == "win32": if sys.version_info >= (3, 8): __all__ = ("StreamReader", "StreamWriter", "StreamReaderProtocol", "open_connection", "start_server") - elif sys.version_info >= (3, 7): + else: __all__ = ( "StreamReader", "StreamWriter", @@ -21,16 +21,6 @@ if sys.platform == "win32": "IncompleteReadError", "LimitOverrunError", ) - else: - __all__ = [ - "StreamReader", - "StreamWriter", - "StreamReaderProtocol", - "open_connection", - "start_server", - "IncompleteReadError", - "LimitOverrunError", - ] else: if sys.version_info >= (3, 8): __all__ = ( @@ -42,7 +32,7 @@ else: "open_unix_connection", "start_unix_server", ) - elif sys.version_info >= (3, 7): + else: __all__ = ( "StreamReader", "StreamWriter", @@ -54,18 +44,6 @@ else: "open_unix_connection", "start_unix_server", ) - else: - __all__ = [ - "StreamReader", - "StreamWriter", - "StreamReaderProtocol", - "open_connection", - "start_server", - "IncompleteReadError", - "LimitOverrunError", - "open_unix_connection", - "start_unix_server", - ] _ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None] @@ -120,24 +98,20 @@ else: ) -> Server: ... if sys.platform != "win32": - if sys.version_info >= (3, 7): - _PathType: TypeAlias = StrPath - else: - _PathType: TypeAlias = str if sys.version_info >= (3, 10): async def open_unix_connection( - path: _PathType | None = ..., *, limit: int = ..., **kwds: Any + path: StrPath | None = ..., *, limit: int = ..., **kwds: Any ) -> tuple[StreamReader, StreamWriter]: ... async def start_unix_server( - client_connected_cb: _ClientConnectedCallback, path: _PathType | None = ..., *, limit: int = ..., **kwds: Any + client_connected_cb: _ClientConnectedCallback, path: StrPath | None = ..., *, limit: int = ..., **kwds: Any ) -> Server: ... else: async def open_unix_connection( - path: _PathType | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any + path: StrPath | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any ) -> tuple[StreamReader, StreamWriter]: ... async def start_unix_server( client_connected_cb: _ClientConnectedCallback, - path: _PathType | None = ..., + path: StrPath | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., @@ -174,10 +148,8 @@ class StreamWriter: def write_eof(self) -> None: ... def can_write_eof(self) -> bool: ... def close(self) -> None: ... - if sys.version_info >= (3, 7): - def is_closing(self) -> bool: ... - async def wait_closed(self) -> None: ... - + def is_closing(self) -> bool: ... + async def wait_closed(self) -> None: ... def get_extra_info(self, name: str, default: Any = ...) -> Any: ... async def drain(self) -> None: ... if sys.version_info >= (3, 11): diff --git a/mypy/typeshed/stdlib/asyncio/subprocess.pyi b/mypy/typeshed/stdlib/asyncio/subprocess.pyi index 55093a3ebd9f..5b62c20bd07f 100644 --- a/mypy/typeshed/stdlib/asyncio/subprocess.pyi +++ b/mypy/typeshed/stdlib/asyncio/subprocess.pyi @@ -6,10 +6,7 @@ from collections.abc import Callable from typing import IO, Any from typing_extensions import Literal, TypeAlias -if sys.version_info >= (3, 7): - __all__ = ("create_subprocess_exec", "create_subprocess_shell") -else: - __all__ = ["create_subprocess_exec", "create_subprocess_shell"] +__all__ = ("create_subprocess_exec", "create_subprocess_shell") if sys.version_info >= (3, 8): _ExecArg: TypeAlias = StrOrBytesPath diff --git a/mypy/typeshed/stdlib/asyncio/tasks.pyi b/mypy/typeshed/stdlib/asyncio/tasks.pyi index 8442090f11ea..d919a0299b99 100644 --- a/mypy/typeshed/stdlib/asyncio/tasks.pyi +++ b/mypy/typeshed/stdlib/asyncio/tasks.pyi @@ -13,43 +13,27 @@ if sys.version_info >= (3, 9): if sys.version_info >= (3, 11): from contextvars import Context -if sys.version_info >= (3, 7): - __all__ = ( - "Task", - "create_task", - "FIRST_COMPLETED", - "FIRST_EXCEPTION", - "ALL_COMPLETED", - "wait", - "wait_for", - "as_completed", - "sleep", - "gather", - "shield", - "ensure_future", - "run_coroutine_threadsafe", - "current_task", - "all_tasks", - "_register_task", - "_unregister_task", - "_enter_task", - "_leave_task", - ) -else: - __all__ = [ - "Task", - "FIRST_COMPLETED", - "FIRST_EXCEPTION", - "ALL_COMPLETED", - "wait", - "wait_for", - "as_completed", - "sleep", - "gather", - "shield", - "ensure_future", - "run_coroutine_threadsafe", - ] +__all__ = ( + "Task", + "create_task", + "FIRST_COMPLETED", + "FIRST_EXCEPTION", + "ALL_COMPLETED", + "wait", + "wait_for", + "as_completed", + "sleep", + "gather", + "shield", + "ensure_future", + "run_coroutine_threadsafe", + "current_task", + "all_tasks", + "_register_task", + "_unregister_task", + "_enter_task", + "_leave_task", +) _T = TypeVar("_T") _T1 = TypeVar("_T1") @@ -78,24 +62,22 @@ def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = ...) @overload def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = ...) -> Task[_T]: ... -# Prior to Python 3.7 'async' was an alias for 'ensure_future'. -# It became a keyword in 3.7. - # `gather()` actually returns a list with length equal to the number # of tasks passed; however, Tuple is used similar to the annotation for # zip() because typing does not support variadic type variables. See # typing PR #1550 for discussion. +# +# The many type: ignores here are because the overloads overlap, +# but having overlapping overloads is the only way to get acceptable type inference in all edge cases. if sys.version_info >= (3, 10): @overload - def gather(*, return_exceptions: bool = ...) -> Future[tuple[()]]: ... + def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]: ... # type: ignore[misc] @overload - def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]: ... - @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: Literal[False] = ... ) -> Future[tuple[_T1, _T2]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -103,7 +85,7 @@ if sys.version_info >= (3, 10): return_exceptions: Literal[False] = ..., ) -> Future[tuple[_T1, _T2, _T3]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -112,7 +94,7 @@ if sys.version_info >= (3, 10): return_exceptions: Literal[False] = ..., ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -122,13 +104,13 @@ if sys.version_info >= (3, 10): return_exceptions: Literal[False] = ..., ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload - def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... + def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[misc] @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: bool ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -136,7 +118,7 @@ if sys.version_info >= (3, 10): return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -145,7 +127,7 @@ if sys.version_info >= (3, 10): return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -157,26 +139,15 @@ if sys.version_info >= (3, 10): tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] ]: ... @overload - def gather( - __coro_or_future1: _FutureLike[Any], - __coro_or_future2: _FutureLike[Any], - __coro_or_future3: _FutureLike[Any], - __coro_or_future4: _FutureLike[Any], - __coro_or_future5: _FutureLike[Any], - __coro_or_future6: _FutureLike[Any], - *coros_or_futures: _FutureLike[Any], - return_exceptions: bool = ..., - ) -> Future[list[Any]]: ... + def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = ...) -> Future[list[Any]]: ... # type: ignore[misc] else: @overload - def gather(*, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ...) -> Future[tuple[()]]: ... - @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ... ) -> Future[tuple[_T1]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, @@ -184,7 +155,7 @@ else: return_exceptions: Literal[False] = ..., ) -> Future[tuple[_T1, _T2]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -193,7 +164,7 @@ else: return_exceptions: Literal[False] = ..., ) -> Future[tuple[_T1, _T2, _T3]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -203,7 +174,7 @@ else: return_exceptions: Literal[False] = ..., ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -214,11 +185,11 @@ else: return_exceptions: Literal[False] = ..., ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: bool ) -> Future[tuple[_T1 | BaseException]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, @@ -226,7 +197,7 @@ else: return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -235,7 +206,7 @@ else: return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -245,7 +216,7 @@ else: return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload - def gather( + def gather( # type: ignore[misc] __coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], __coro_or_future3: _FutureLike[_T3], @@ -258,16 +229,8 @@ else: tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] ]: ... @overload - def gather( - __coro_or_future1: _FutureLike[Any], - __coro_or_future2: _FutureLike[Any], - __coro_or_future3: _FutureLike[Any], - __coro_or_future4: _FutureLike[Any], - __coro_or_future5: _FutureLike[Any], - __coro_or_future6: _FutureLike[Any], - *coros_or_futures: _FutureLike[Any], - loop: AbstractEventLoop | None = ..., - return_exceptions: bool = ..., + def gather( # type: ignore[misc] + *coros_or_futures: _FutureLike[Any], loop: AbstractEventLoop | None = ..., return_exceptions: bool = ... ) -> Future[list[Any]]: ... def run_coroutine_threadsafe(coro: _FutureLike[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... @@ -334,24 +297,24 @@ class Task(Future[_T], Generic[_T]): def current_task(cls, loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... @classmethod def all_tasks(cls, loop: AbstractEventLoop | None = ...) -> set[Task[Any]]: ... - if sys.version_info < (3, 7): - def _wakeup(self, fut: Future[Any]) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -if sys.version_info >= (3, 7): - def all_tasks(loop: AbstractEventLoop | None = ...) -> set[Task[Any]]: ... - if sys.version_info >= (3, 11): - def create_task( - coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ..., context: Context | None = ... - ) -> Task[_T]: ... - elif sys.version_info >= (3, 8): - def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ...) -> Task[_T]: ... - else: - def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T]) -> Task[_T]: ... +def all_tasks(loop: AbstractEventLoop | None = ...) -> set[Task[Any]]: ... + +if sys.version_info >= (3, 11): + def create_task( + coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ..., context: Context | None = ... + ) -> Task[_T]: ... + +elif sys.version_info >= (3, 8): + def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T], *, name: str | None = ...) -> Task[_T]: ... + +else: + def create_task(coro: Generator[Any, None, _T] | Coroutine[Any, Any, _T]) -> Task[_T]: ... - def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... - def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ... - def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ... - def _register_task(task: Task[Any]) -> None: ... - def _unregister_task(task: Task[Any]) -> None: ... +def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... +def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ... +def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ... +def _register_task(task: Task[Any]) -> None: ... +def _unregister_task(task: Task[Any]) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncio/transports.pyi b/mypy/typeshed/stdlib/asyncio/transports.pyi index 7e17beb9f630..be68cad5f894 100644 --- a/mypy/typeshed/stdlib/asyncio/transports.pyi +++ b/mypy/typeshed/stdlib/asyncio/transports.pyi @@ -1,14 +1,10 @@ -import sys from asyncio.events import AbstractEventLoop from asyncio.protocols import BaseProtocol from collections.abc import Mapping from socket import _Address from typing import Any -if sys.version_info >= (3, 7): - __all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport") -else: - __all__ = ["BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport"] +__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport") class BaseTransport: def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ... @@ -19,9 +15,7 @@ class BaseTransport: def get_protocol(self) -> BaseProtocol: ... class ReadTransport(BaseTransport): - if sys.version_info >= (3, 7): - def is_reading(self) -> bool: ... - + def is_reading(self) -> bool: ... def pause_reading(self) -> None: ... def resume_reading(self) -> None: ... diff --git a/mypy/typeshed/stdlib/asyncio/unix_events.pyi b/mypy/typeshed/stdlib/asyncio/unix_events.pyi index ca28ee04125a..54e663ece192 100644 --- a/mypy/typeshed/stdlib/asyncio/unix_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/unix_events.pyi @@ -3,12 +3,10 @@ import types from _typeshed import Self from abc import ABCMeta, abstractmethod from collections.abc import Callable -from socket import socket from typing import Any from typing_extensions import Literal -from .base_events import Server -from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext +from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy from .selector_events import BaseSelectorEventLoop # This is also technically not available on Win, @@ -16,7 +14,7 @@ from .selector_events import BaseSelectorEventLoop # So, it is special cased. class AbstractChildWatcher: @abstractmethod - def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ... + def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ... @abstractmethod def remove_child_handler(self, pid: int) -> bool: ... @abstractmethod @@ -53,10 +51,8 @@ if sys.platform != "win32": "ThreadedChildWatcher", "DefaultEventLoopPolicy", ) - elif sys.version_info >= (3, 7): - __all__ = ("SelectorEventLoop", "AbstractChildWatcher", "SafeChildWatcher", "FastChildWatcher", "DefaultEventLoopPolicy") else: - __all__ = ["SelectorEventLoop", "AbstractChildWatcher", "SafeChildWatcher", "FastChildWatcher", "DefaultEventLoopPolicy"] + __all__ = ("SelectorEventLoop", "AbstractChildWatcher", "SafeChildWatcher", "FastChildWatcher", "DefaultEventLoopPolicy") # Doesn't actually have ABCMeta metaclass at runtime, but mypy complains if we don't have it in the stub. # See discussion in #7412 @@ -71,26 +67,16 @@ if sys.platform != "win32": class SafeChildWatcher(BaseChildWatcher): def __enter__(self: Self) -> Self: ... def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ... - def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ... + def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ... def remove_child_handler(self, pid: int) -> bool: ... class FastChildWatcher(BaseChildWatcher): def __enter__(self: Self) -> Self: ... def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ... - def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ... + def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ... def remove_child_handler(self, pid: int) -> bool: ... - class _UnixSelectorEventLoop(BaseSelectorEventLoop): - if sys.version_info < (3, 7): - async def create_unix_server( - self, - protocol_factory: _ProtocolFactory, - path: str | None = ..., - *, - sock: socket | None = ..., - backlog: int = ..., - ssl: _SSLContext = ..., - ) -> Server: ... + class _UnixSelectorEventLoop(BaseSelectorEventLoop): ... class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy): def get_child_watcher(self) -> AbstractChildWatcher: ... @@ -106,7 +92,7 @@ if sys.platform != "win32": class _Warn(Protocol): def __call__( self, message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... - ) -> None: ... + ) -> object: ... class MultiLoopChildWatcher(AbstractChildWatcher): def __init__(self) -> None: ... @@ -116,7 +102,7 @@ if sys.platform != "win32": def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... - def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ... + def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ... def remove_child_handler(self, pid: int) -> bool: ... def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... @@ -129,7 +115,7 @@ if sys.platform != "win32": self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def __del__(self, _warn: _Warn = ...) -> None: ... - def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ... + def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ... def remove_child_handler(self, pid: int) -> bool: ... def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... @@ -143,5 +129,5 @@ if sys.platform != "win32": def is_active(self) -> bool: ... def close(self) -> None: ... def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... - def add_child_handler(self, pid: int, callback: Callable[..., Any], *args: Any) -> None: ... + def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ... def remove_child_handler(self, pid: int) -> bool: ... diff --git a/mypy/typeshed/stdlib/asyncio/windows_events.pyi b/mypy/typeshed/stdlib/asyncio/windows_events.pyi index d33210bc1297..ffb487fff03a 100644 --- a/mypy/typeshed/stdlib/asyncio/windows_events.pyi +++ b/mypy/typeshed/stdlib/asyncio/windows_events.pyi @@ -8,17 +8,14 @@ from typing_extensions import Literal from . import events, futures, proactor_events, selector_events, streams, windows_utils if sys.platform == "win32": - if sys.version_info >= (3, 7): - __all__ = ( - "SelectorEventLoop", - "ProactorEventLoop", - "IocpProactor", - "DefaultEventLoopPolicy", - "WindowsSelectorEventLoopPolicy", - "WindowsProactorEventLoopPolicy", - ) - else: - __all__ = ["SelectorEventLoop", "ProactorEventLoop", "IocpProactor", "DefaultEventLoopPolicy"] + __all__ = ( + "SelectorEventLoop", + "ProactorEventLoop", + "IocpProactor", + "DefaultEventLoopPolicy", + "WindowsSelectorEventLoopPolicy", + "WindowsProactorEventLoopPolicy", + ) NULL: Literal[0] INFINITE: Literal[0xFFFFFFFF] @@ -50,35 +47,24 @@ if sys.platform == "win32": def set_loop(self, loop: events.AbstractEventLoop) -> None: ... def select(self, timeout: int | None = ...) -> list[futures.Future[Any]]: ... def recv(self, conn: socket.socket, nbytes: int, flags: int = ...) -> futures.Future[bytes]: ... - if sys.version_info >= (3, 7): - def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = ...) -> futures.Future[Any]: ... - + def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = ...) -> futures.Future[Any]: ... def send(self, conn: socket.socket, buf: WriteableBuffer, flags: int = ...) -> futures.Future[Any]: ... def accept(self, listener: socket.socket) -> futures.Future[Any]: ... def connect(self, conn: socket.socket, address: bytes) -> futures.Future[Any]: ... - if sys.version_info >= (3, 7): - def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ... - + def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ... def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ... async def connect_pipe(self, address: bytes) -> windows_utils.PipeHandle: ... def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = ...) -> bool: ... def close(self) -> None: ... SelectorEventLoop = _WindowsSelectorEventLoop - if sys.version_info >= (3, 7): - class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[type[SelectorEventLoop]] - def get_child_watcher(self) -> NoReturn: ... - def set_child_watcher(self, watcher: Any) -> NoReturn: ... + class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): + _loop_factory: ClassVar[type[SelectorEventLoop]] + def get_child_watcher(self) -> NoReturn: ... + def set_child_watcher(self, watcher: Any) -> NoReturn: ... - class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[type[ProactorEventLoop]] - def get_child_watcher(self) -> NoReturn: ... - def set_child_watcher(self, watcher: Any) -> NoReturn: ... - DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy - else: - class _WindowsDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[type[SelectorEventLoop]] - def get_child_watcher(self) -> NoReturn: ... - def set_child_watcher(self, watcher: Any) -> NoReturn: ... - DefaultEventLoopPolicy = _WindowsDefaultEventLoopPolicy + class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): + _loop_factory: ClassVar[type[ProactorEventLoop]] + def get_child_watcher(self) -> NoReturn: ... + def set_child_watcher(self, watcher: Any) -> NoReturn: ... + DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy diff --git a/mypy/typeshed/stdlib/asyncio/windows_utils.pyi b/mypy/typeshed/stdlib/asyncio/windows_utils.pyi index db34356cd16d..6e170dcb073a 100644 --- a/mypy/typeshed/stdlib/asyncio/windows_utils.pyi +++ b/mypy/typeshed/stdlib/asyncio/windows_utils.pyi @@ -7,18 +7,12 @@ from typing import Any, AnyStr, Protocol from typing_extensions import Literal if sys.platform == "win32": - if sys.version_info >= (3, 7): - __all__ = ("pipe", "Popen", "PIPE", "PipeHandle") - else: - __all__ = ["socketpair", "pipe", "Popen", "PIPE", "PipeHandle"] - import socket - - socketpair = socket.socketpair + __all__ = ("pipe", "Popen", "PIPE", "PipeHandle") class _WarnFunction(Protocol): def __call__( self, message: str, category: type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ... - ) -> None: ... + ) -> object: ... BUFSIZE: Literal[8192] PIPE = subprocess.PIPE STDOUT = subprocess.STDOUT diff --git a/mypy/typeshed/stdlib/atexit.pyi b/mypy/typeshed/stdlib/atexit.pyi index 095ab5f9b26d..ea041d7b5e46 100644 --- a/mypy/typeshed/stdlib/atexit.pyi +++ b/mypy/typeshed/stdlib/atexit.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Any, TypeVar +from typing import TypeVar from typing_extensions import ParamSpec _T = TypeVar("_T") @@ -9,4 +9,4 @@ def _clear() -> None: ... def _ncallbacks() -> int: ... def _run_exitfuncs() -> None: ... def register(func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> Callable[_P, _T]: ... -def unregister(func: Callable[..., Any]) -> None: ... +def unregister(func: Callable[..., object]) -> None: ... diff --git a/mypy/typeshed/stdlib/bdb.pyi b/mypy/typeshed/stdlib/bdb.pyi index f4d1875efb69..58808632b31d 100644 --- a/mypy/typeshed/stdlib/bdb.pyi +++ b/mypy/typeshed/stdlib/bdb.pyi @@ -1,15 +1,14 @@ import sys -from _typeshed import ExcInfo +from _typeshed import ExcInfo, TraceFunction from collections.abc import Callable, Iterable, Mapping from types import CodeType, FrameType, TracebackType from typing import IO, Any, SupportsInt, TypeVar -from typing_extensions import Literal, ParamSpec, TypeAlias +from typing_extensions import Literal, ParamSpec __all__ = ["BdbQuit", "Bdb", "Breakpoint"] _T = TypeVar("_T") _P = ParamSpec("_P") -_TraceDispatch: TypeAlias = Callable[[FrameType, str, Any], Any] # TODO: Recursive type GENERATOR_AND_COROUTINE_FLAGS: Literal[672] @@ -28,11 +27,11 @@ class Bdb: def __init__(self, skip: Iterable[str] | None = ...) -> None: ... def canonic(self, filename: str) -> str: ... def reset(self) -> None: ... - def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ... - def dispatch_line(self, frame: FrameType) -> _TraceDispatch: ... - def dispatch_call(self, frame: FrameType, arg: None) -> _TraceDispatch: ... - def dispatch_return(self, frame: FrameType, arg: Any) -> _TraceDispatch: ... - def dispatch_exception(self, frame: FrameType, arg: ExcInfo) -> _TraceDispatch: ... + def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> TraceFunction: ... + def dispatch_line(self, frame: FrameType) -> TraceFunction: ... + def dispatch_call(self, frame: FrameType, arg: None) -> TraceFunction: ... + def dispatch_return(self, frame: FrameType, arg: Any) -> TraceFunction: ... + def dispatch_exception(self, frame: FrameType, arg: ExcInfo) -> TraceFunction: ... def is_skipped_module(self, module_name: str) -> bool: ... def stop_here(self, frame: FrameType) -> bool: ... def break_here(self, frame: FrameType) -> bool: ... diff --git a/mypy/typeshed/stdlib/binascii.pyi b/mypy/typeshed/stdlib/binascii.pyi index 0656794d39d9..6f834f7868c3 100644 --- a/mypy/typeshed/stdlib/binascii.pyi +++ b/mypy/typeshed/stdlib/binascii.pyi @@ -7,12 +7,7 @@ from typing_extensions import TypeAlias _AsciiBuffer: TypeAlias = str | ReadableBuffer def a2b_uu(__data: _AsciiBuffer) -> bytes: ... - -if sys.version_info >= (3, 7): - def b2a_uu(__data: ReadableBuffer, *, backtick: bool = ...) -> bytes: ... - -else: - def b2a_uu(__data: ReadableBuffer) -> bytes: ... +def b2a_uu(__data: ReadableBuffer, *, backtick: bool = ...) -> bytes: ... if sys.version_info >= (3, 11): def a2b_base64(__data: _AsciiBuffer, *, strict_mode: bool = ...) -> bytes: ... diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi index 381d3358b7ec..e0d584a387fb 100644 --- a/mypy/typeshed/stdlib/builtins.pyi +++ b/mypy/typeshed/stdlib/builtins.pyi @@ -85,7 +85,7 @@ class object: def __class__(self: Self) -> type[Self]: ... # Ignore errors about type mismatch between property getter and setter @__class__.setter - def __class__(self, __type: type[object]) -> None: ... # type: ignore # noqa: F811 + def __class__(self, __type: type[object]) -> None: ... # noqa: F811 def __init__(self) -> None: ... def __new__(cls: type[Self]) -> Self: ... # N.B. `object.__setattr__` and `object.__delattr__` are heavily special-cased by type checkers. @@ -205,11 +205,11 @@ class int: @property def real(self) -> int: ... @property - def imag(self) -> int: ... + def imag(self) -> Literal[0]: ... @property def numerator(self) -> int: ... @property - def denominator(self) -> int: ... + def denominator(self) -> Literal[1]: ... def conjugate(self) -> int: ... def bit_length(self) -> int: ... if sys.version_info >= (3, 10): @@ -420,9 +420,7 @@ class str(Sequence[str]): def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... - if sys.version_info >= (3, 7): - def isascii(self) -> bool: ... - + def isascii(self) -> bool: ... def isdecimal(self) -> bool: ... def isdigit(self) -> bool: ... def isidentifier(self) -> bool: ... @@ -524,9 +522,7 @@ class bytes(ByteString): ) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... - if sys.version_info >= (3, 7): - def isascii(self) -> bool: ... - + def isascii(self) -> bool: ... def isdigit(self) -> bool: ... def islower(self) -> bool: ... def isspace(self) -> bool: ... @@ -636,9 +632,7 @@ class bytearray(MutableSequence[int], ByteString): def insert(self, __index: SupportsIndex, __item: SupportsIndex) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... - if sys.version_info >= (3, 7): - def isascii(self) -> bool: ... - + def isascii(self) -> bool: ... def isdigit(self) -> bool: ... def islower(self) -> bool: ... def isspace(self) -> bool: ... @@ -818,12 +812,7 @@ class slice: def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ... class tuple(Sequence[_T_co], Generic[_T_co]): - # overloads are ordered this way to pass `isinstance` checks - # see: https://github.com/python/typeshed/pull/7454#issuecomment-1061490888 - @overload - def __new__(cls: type[Self], __iterable: Iterable[_T_co]) -> Self: ... - @overload - def __new__(cls) -> tuple[()]: ... + def __new__(cls: type[Self], __iterable: Iterable[_T_co] = ...) -> Self: ... def __len__(self) -> int: ... def __contains__(self, __x: object) -> bool: ... @overload @@ -905,8 +894,12 @@ class list(MutableSequence[_T], Generic[_T]): @overload def __setitem__(self, __s: slice, __o: Iterable[_T]) -> None: ... def __delitem__(self, __i: SupportsIndex | slice) -> None: ... + # Overloading looks unnecessary, but is needed to work around complex mypy problems + @overload def __add__(self, __x: list[_T]) -> list[_T]: ... - def __iadd__(self: Self, __x: Iterable[_T]) -> Self: ... + @overload + def __add__(self, __x: list[_S]) -> list[_S | _T]: ... + def __iadd__(self: Self, __x: Iterable[_T]) -> Self: ... # type: ignore[misc] def __mul__(self, __n: SupportsIndex) -> list[_T]: ... def __rmul__(self, __n: SupportsIndex) -> list[_T]: ... def __imul__(self: Self, __n: SupportsIndex) -> Self: ... @@ -1103,10 +1096,7 @@ def all(__iterable: Iterable[object]) -> bool: ... def any(__iterable: Iterable[object]) -> bool: ... def ascii(__obj: object) -> str: ... def bin(__number: int | SupportsIndex) -> str: ... - -if sys.version_info >= (3, 7): - def breakpoint(*args: Any, **kws: Any) -> None: ... - +def breakpoint(*args: Any, **kws: Any) -> None: ... def callable(__obj: object) -> TypeGuard[Callable[..., object]]: ... def chr(__i: int) -> str: ... diff --git a/mypy/typeshed/stdlib/calendar.pyi b/mypy/typeshed/stdlib/calendar.pyi index 00b7054ba60a..4faee805333b 100644 --- a/mypy/typeshed/stdlib/calendar.pyi +++ b/mypy/typeshed/stdlib/calendar.pyi @@ -62,9 +62,8 @@ class Calendar: def yeardatescalendar(self, year: int, width: int = ...) -> list[list[int]]: ... def yeardays2calendar(self, year: int, width: int = ...) -> list[list[tuple[int, int]]]: ... def yeardayscalendar(self, year: int, width: int = ...) -> list[list[int]]: ... - if sys.version_info >= (3, 7): - def itermonthdays3(self, year: int, month: int) -> Iterable[tuple[int, int, int]]: ... - def itermonthdays4(self, year: int, month: int) -> Iterable[tuple[int, int, int, int]]: ... + def itermonthdays3(self, year: int, month: int) -> Iterable[tuple[int, int, int]]: ... + def itermonthdays4(self, year: int, month: int) -> Iterable[tuple[int, int, int, int]]: ... class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... @@ -97,14 +96,13 @@ class HTMLCalendar(Calendar): def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... def formatyear(self, theyear: int, width: int = ...) -> str: ... def formatyearpage(self, theyear: int, width: int = ..., css: str | None = ..., encoding: str | None = ...) -> str: ... - if sys.version_info >= (3, 7): - cssclasses: list[str] - cssclass_noday: str - cssclasses_weekday_head: list[str] - cssclass_month_head: str - cssclass_month: str - cssclass_year: str - cssclass_year_head: str + cssclasses: list[str] + cssclass_noday: str + cssclasses_weekday_head: list[str] + cssclass_month_head: str + cssclass_month: str + cssclass_year: str + cssclass_year_head: str class different_locale: def __init__(self, locale: _LocaleType) -> None: ... diff --git a/mypy/typeshed/stdlib/cgi.pyi b/mypy/typeshed/stdlib/cgi.pyi index 59c0a27067f1..523b44793941 100644 --- a/mypy/typeshed/stdlib/cgi.pyi +++ b/mypy/typeshed/stdlib/cgi.pyi @@ -35,13 +35,9 @@ if sys.version_info < (3, 8): def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> dict[str, list[str]]: ... def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> list[tuple[str, str]]: ... -if sys.version_info >= (3, 7): - def parse_multipart( - fp: IO[Any], pdict: SupportsGetItem[str, bytes], encoding: str = ..., errors: str = ..., separator: str = ... - ) -> dict[str, list[Any]]: ... - -else: - def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> dict[str, list[bytes]]: ... +def parse_multipart( + fp: IO[Any], pdict: SupportsGetItem[str, bytes], encoding: str = ..., errors: str = ..., separator: str = ... +) -> dict[str, list[Any]]: ... class _Environ(Protocol): def __getitem__(self, __k: str) -> str: ... diff --git a/mypy/typeshed/stdlib/collections/__init__.pyi b/mypy/typeshed/stdlib/collections/__init__.pyi index 5fff9f48c489..b546c45ab364 100644 --- a/mypy/typeshed/stdlib/collections/__init__.pyi +++ b/mypy/typeshed/stdlib/collections/__init__.pyi @@ -14,35 +14,6 @@ else: __all__ = ["ChainMap", "Counter", "OrderedDict", "UserDict", "UserList", "UserString", "defaultdict", "deque", "namedtuple"] -if sys.version_info < (3, 7): - __all__ += [ - "Awaitable", - "Coroutine", - "AsyncIterable", - "AsyncIterator", - "AsyncGenerator", - "Hashable", - "Iterable", - "Iterator", - "Generator", - "Reversible", - "Sized", - "Container", - "Callable", - "Collection", - "Set", - "MutableSet", - "Mapping", - "MutableMapping", - "MappingView", - "KeysView", - "ItemsView", - "ValuesView", - "Sequence", - "MutableSequence", - "ByteString", - ] - _S = TypeVar("_S") _T = TypeVar("_T") _T1 = TypeVar("_T1") @@ -53,20 +24,14 @@ _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) # namedtuple is special-cased in the type checker; the initializer is ignored. -if sys.version_info >= (3, 7): - def namedtuple( - typename: str, - field_names: str | Iterable[str], - *, - rename: bool = ..., - module: str | None = ..., - defaults: Iterable[Any] | None = ..., - ) -> type[tuple[Any, ...]]: ... - -else: - def namedtuple( - typename: str, field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., module: str | None = ... - ) -> type[tuple[Any, ...]]: ... +def namedtuple( + typename: str, + field_names: str | Iterable[str], + *, + rename: bool = ..., + module: str | None = ..., + defaults: Iterable[Any] | None = ..., +) -> type[tuple[Any, ...]]: ... class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): data: dict[_KT, _VT] @@ -88,8 +53,7 @@ class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __iter__(self) -> Iterator[_KT]: ... def __contains__(self, key: object) -> bool: ... def copy(self: Self) -> Self: ... - if sys.version_info >= (3, 7): - def __copy__(self: Self) -> Self: ... + def __copy__(self: Self) -> Self: ... # `UserDict.fromkeys` has the same semantics as `dict.fromkeys`, so should be kept in line with `dict.fromkeys`. # TODO: Much like `dict.fromkeys`, the true signature of `UserDict.fromkeys` is inexpressible in the current type system. @@ -142,9 +106,7 @@ class UserList(MutableSequence[_T]): def pop(self, i: int = ...) -> _T: ... def remove(self, item: _T) -> None: ... def copy(self: Self) -> Self: ... - if sys.version_info >= (3, 7): - def __copy__(self: Self) -> Self: ... - + def __copy__(self: Self) -> Self: ... def count(self, item: _T) -> int: ... # All arguments are passed to `list.index` at runtime, so the signature should be kept in line with `list.index`. def index(self, item: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ... @@ -208,9 +170,7 @@ class UserString(Sequence[UserString]): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - if sys.version_info >= (3, 7): - def isascii(self) -> bool: ... - + def isascii(self) -> bool: ... def join(self, seq: Iterable[str]) -> str: ... def ljust(self: Self, width: int, *args: Any) -> Self: ... def lower(self: Self) -> Self: ... diff --git a/mypy/typeshed/stdlib/compileall.pyi b/mypy/typeshed/stdlib/compileall.pyi index 7101fd05f717..dd1de3f496e7 100644 --- a/mypy/typeshed/stdlib/compileall.pyi +++ b/mypy/typeshed/stdlib/compileall.pyi @@ -1,10 +1,8 @@ import sys from _typeshed import StrPath +from py_compile import PycInvalidationMode from typing import Any, Protocol -if sys.version_info >= (3, 7): - from py_compile import PycInvalidationMode - __all__ = ["compile_dir", "compile_file", "compile_path"] class _SupportsSearch(Protocol): @@ -44,30 +42,6 @@ if sys.version_info >= (3, 9): hardlink_dupes: bool = ..., ) -> int: ... -elif sys.version_info >= (3, 7): - def compile_dir( - dir: StrPath, - maxlevels: int = ..., - ddir: StrPath | None = ..., - force: bool = ..., - rx: _SupportsSearch | None = ..., - quiet: int = ..., - legacy: bool = ..., - optimize: int = ..., - workers: int = ..., - invalidation_mode: PycInvalidationMode | None = ..., - ) -> int: ... - def compile_file( - fullname: StrPath, - ddir: StrPath | None = ..., - force: bool = ..., - rx: _SupportsSearch | None = ..., - quiet: int = ..., - legacy: bool = ..., - optimize: int = ..., - invalidation_mode: PycInvalidationMode | None = ..., - ) -> int: ... - else: def compile_dir( dir: StrPath, @@ -79,6 +53,7 @@ else: legacy: bool = ..., optimize: int = ..., workers: int = ..., + invalidation_mode: PycInvalidationMode | None = ..., ) -> int: ... def compile_file( fullname: StrPath, @@ -88,25 +63,15 @@ else: quiet: int = ..., legacy: bool = ..., optimize: int = ..., - ) -> int: ... - -if sys.version_info >= (3, 7): - def compile_path( - skip_curdir: bool = ..., - maxlevels: int = ..., - force: bool = ..., - quiet: int = ..., - legacy: bool = ..., - optimize: int = ..., invalidation_mode: PycInvalidationMode | None = ..., ) -> int: ... -else: - def compile_path( - skip_curdir: bool = ..., - maxlevels: int = ..., - force: bool = ..., - quiet: int = ..., - legacy: bool = ..., - optimize: int = ..., - ) -> int: ... +def compile_path( + skip_curdir: bool = ..., + maxlevels: int = ..., + force: bool = ..., + quiet: int = ..., + legacy: bool = ..., + optimize: int = ..., + invalidation_mode: PycInvalidationMode | None = ..., +) -> int: ... diff --git a/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi b/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi index dbf8ea3df857..3c9e53d62d6c 100644 --- a/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi +++ b/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi @@ -1,25 +1,10 @@ import sys -if sys.version_info >= (3, 7): - __all__ = ( - "FIRST_COMPLETED", - "FIRST_EXCEPTION", - "ALL_COMPLETED", - "CancelledError", - "TimeoutError", - "BrokenExecutor", - "Future", - "Executor", - "wait", - "as_completed", - "ProcessPoolExecutor", - "ThreadPoolExecutor", - ) - from ._base import ( ALL_COMPLETED as ALL_COMPLETED, FIRST_COMPLETED as FIRST_COMPLETED, FIRST_EXCEPTION as FIRST_EXCEPTION, + BrokenExecutor as BrokenExecutor, CancelledError as CancelledError, Executor as Executor, Future as Future, @@ -32,5 +17,18 @@ from .thread import ThreadPoolExecutor as ThreadPoolExecutor if sys.version_info >= (3, 8): from ._base import InvalidStateError as InvalidStateError -if sys.version_info >= (3, 7): - from ._base import BrokenExecutor as BrokenExecutor + +__all__ = ( + "FIRST_COMPLETED", + "FIRST_EXCEPTION", + "ALL_COMPLETED", + "CancelledError", + "TimeoutError", + "BrokenExecutor", + "Future", + "Executor", + "wait", + "as_completed", + "ProcessPoolExecutor", + "ThreadPoolExecutor", +) diff --git a/mypy/typeshed/stdlib/concurrent/futures/_base.pyi b/mypy/typeshed/stdlib/concurrent/futures/_base.pyi index 5b756d87d118..9dd9be4d647e 100644 --- a/mypy/typeshed/stdlib/concurrent/futures/_base.pyi +++ b/mypy/typeshed/stdlib/concurrent/futures/_base.pyi @@ -30,8 +30,7 @@ class TimeoutError(Error): ... if sys.version_info >= (3, 8): class InvalidStateError(Error): ... -if sys.version_info >= (3, 7): - class BrokenExecutor(RuntimeError): ... +class BrokenExecutor(RuntimeError): ... _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) @@ -50,7 +49,7 @@ class Future(Generic[_T]): def cancelled(self) -> bool: ... def running(self) -> bool: ... def done(self) -> bool: ... - def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ... + def add_done_callback(self, fn: Callable[[Future[_T]], object]) -> None: ... def result(self, timeout: float | None = ...) -> _T: ... def set_running_or_notify_cancel(self) -> bool: ... def set_result(self, result: _T) -> None: ... diff --git a/mypy/typeshed/stdlib/concurrent/futures/process.pyi b/mypy/typeshed/stdlib/concurrent/futures/process.pyi index 0c3bea26c31f..211107cf357d 100644 --- a/mypy/typeshed/stdlib/concurrent/futures/process.pyi +++ b/mypy/typeshed/stdlib/concurrent/futures/process.pyi @@ -8,7 +8,9 @@ from types import TracebackType from typing import Any, Generic, TypeVar from weakref import ref -from ._base import Executor, Future +from ._base import BrokenExecutor, Executor, Future + +_T = TypeVar("_T") _threads_wakeups: MutableMapping[Any, Any] _global_shutdown: bool @@ -40,14 +42,12 @@ class _ExceptionWithTraceback: def _rebuild_exc(exc: Exception, tb: str) -> Exception: ... -_S = TypeVar("_S") - -class _WorkItem(Generic[_S]): - future: Future[_S] - fn: Callable[..., _S] +class _WorkItem(Generic[_T]): + future: Future[_T] + fn: Callable[..., _T] args: Iterable[Any] kwargs: Mapping[str, Any] - def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ... + def __init__(self, future: Future[_T], fn: Callable[..., _T], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ... class _ResultItem: work_id: int @@ -68,30 +68,29 @@ class _CallItem: kwargs: Mapping[str, Any] def __init__(self, work_id: int, fn: Callable[..., Any], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ... -if sys.version_info >= (3, 7): - class _SafeQueue(Queue[Future[Any]]): - pending_work_items: dict[int, _WorkItem[Any]] - shutdown_lock: Lock - thread_wakeup: _ThreadWakeup - if sys.version_info >= (3, 9): - def __init__( - self, - max_size: int | None = ..., - *, - ctx: BaseContext, - pending_work_items: dict[int, _WorkItem[Any]], - shutdown_lock: Lock, - thread_wakeup: _ThreadWakeup, - ) -> None: ... - else: - def __init__( - self, max_size: int | None = ..., *, ctx: BaseContext, pending_work_items: dict[int, _WorkItem[Any]] - ) -> None: ... - - def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ... +class _SafeQueue(Queue[Future[Any]]): + pending_work_items: dict[int, _WorkItem[Any]] + shutdown_lock: Lock + thread_wakeup: _ThreadWakeup + if sys.version_info >= (3, 9): + def __init__( + self, + max_size: int | None = ..., + *, + ctx: BaseContext, + pending_work_items: dict[int, _WorkItem[Any]], + shutdown_lock: Lock, + thread_wakeup: _ThreadWakeup, + ) -> None: ... + else: + def __init__( + self, max_size: int | None = ..., *, ctx: BaseContext, pending_work_items: dict[int, _WorkItem[Any]] + ) -> None: ... + + def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ... def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ... -def _process_chunk(fn: Callable[..., Any], chunk: tuple[Any, None, None]) -> Generator[Any, None, None]: ... +def _process_chunk(fn: Callable[..., _T], chunk: Iterable[tuple[Any, ...]]) -> list[_T]: ... if sys.version_info >= (3, 11): def _sendback_result( @@ -116,7 +115,7 @@ if sys.version_info >= (3, 11): max_tasks: int | None = ..., ) -> None: ... -elif sys.version_info >= (3, 7): +else: def _process_worker( call_queue: Queue[_CallItem], result_queue: SimpleQueue[_ResultItem], @@ -124,9 +123,6 @@ elif sys.version_info >= (3, 7): initargs: tuple[Any, ...], ) -> None: ... -else: - def _process_worker(call_queue: Queue[_CallItem], result_queue: SimpleQueue[_ResultItem]) -> None: ... - if sys.version_info >= (3, 9): class _ExecutorManagerThread(Thread): thread_wakeup: _ThreadWakeup @@ -155,13 +151,7 @@ _system_limited: bool | None def _check_system_limits() -> None: ... def _chain_from_iterable_of_lists(iterable: Iterable[MutableSequence[Any]]) -> Any: ... -if sys.version_info >= (3, 7): - from ._base import BrokenExecutor - - class BrokenProcessPool(BrokenExecutor): ... - -else: - class BrokenProcessPool(RuntimeError): ... +class BrokenProcessPool(BrokenExecutor): ... class ProcessPoolExecutor(Executor): _mp_context: BaseContext | None = ... @@ -189,7 +179,7 @@ class ProcessPoolExecutor(Executor): *, max_tasks_per_child: int | None = ..., ) -> None: ... - elif sys.version_info >= (3, 7): + else: def __init__( self, max_workers: int | None = ..., @@ -197,8 +187,6 @@ class ProcessPoolExecutor(Executor): initializer: Callable[..., object] | None = ..., initargs: tuple[Any, ...] = ..., ) -> None: ... - else: - def __init__(self, max_workers: int | None = ...) -> None: ... if sys.version_info >= (3, 9): def _start_executor_manager_thread(self) -> None: ... diff --git a/mypy/typeshed/stdlib/concurrent/futures/thread.pyi b/mypy/typeshed/stdlib/concurrent/futures/thread.pyi index 3579c17dbc6c..387ce0d7e438 100644 --- a/mypy/typeshed/stdlib/concurrent/futures/thread.pyi +++ b/mypy/typeshed/stdlib/concurrent/futures/thread.pyi @@ -5,7 +5,7 @@ from threading import Lock, Semaphore, Thread from typing import Any, Generic, TypeVar from weakref import ref -from ._base import Executor, Future +from ._base import BrokenExecutor, Executor, Future _threads_queues: Mapping[Any, Any] _shutdown: bool @@ -28,21 +28,14 @@ class _WorkItem(Generic[_S]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -if sys.version_info >= (3, 7): - def _worker( - executor_reference: ref[Any], - work_queue: queue.SimpleQueue[Any], - initializer: Callable[..., object], - initargs: tuple[Any, ...], - ) -> None: ... - -else: - def _worker(executor_reference: ref[Any], work_queue: queue.Queue[Any]) -> None: ... - -if sys.version_info >= (3, 7): - from ._base import BrokenExecutor +def _worker( + executor_reference: ref[Any], + work_queue: queue.SimpleQueue[Any], + initializer: Callable[..., object], + initargs: tuple[Any, ...], +) -> None: ... - class BrokenThreadPool(BrokenExecutor): ... +class BrokenThreadPool(BrokenExecutor): ... class ThreadPoolExecutor(Executor): _max_workers: int @@ -54,21 +47,13 @@ class ThreadPoolExecutor(Executor): _thread_name_prefix: str | None = ... _initializer: Callable[..., None] | None = ... _initargs: tuple[Any, ...] = ... - if sys.version_info >= (3, 7): - _work_queue: queue.SimpleQueue[_WorkItem[Any]] - else: - _work_queue: queue.Queue[_WorkItem[Any]] - if sys.version_info >= (3, 7): - def __init__( - self, - max_workers: int | None = ..., - thread_name_prefix: str = ..., - initializer: Callable[..., object] | None = ..., - initargs: tuple[Any, ...] = ..., - ) -> None: ... - else: - def __init__(self, max_workers: int | None = ..., thread_name_prefix: str = ...) -> None: ... - + _work_queue: queue.SimpleQueue[_WorkItem[Any]] + def __init__( + self, + max_workers: int | None = ..., + thread_name_prefix: str = ..., + initializer: Callable[..., object] | None = ..., + initargs: tuple[Any, ...] = ..., + ) -> None: ... def _adjust_thread_count(self) -> None: ... - if sys.version_info >= (3, 7): - def _initializer_failed(self) -> None: ... + def _initializer_failed(self) -> None: ... diff --git a/mypy/typeshed/stdlib/configparser.pyi b/mypy/typeshed/stdlib/configparser.pyi index 96145f48cd4b..00a23588b602 100644 --- a/mypy/typeshed/stdlib/configparser.pyi +++ b/mypy/typeshed/stdlib/configparser.pyi @@ -1,7 +1,8 @@ import sys -from _typeshed import StrOrBytesPath, StrPath, SupportsWrite +from _typeshed import StrOrBytesPath, SupportsWrite from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Any, ClassVar, Pattern, TypeVar, overload +from re import Pattern +from typing import Any, ClassVar, TypeVar, overload from typing_extensions import Literal, TypeAlias __all__ = [ @@ -34,11 +35,6 @@ _ConverterCallback: TypeAlias = Callable[[str], Any] _ConvertersMap: TypeAlias = dict[str, _ConverterCallback] _T = TypeVar("_T") -if sys.version_info >= (3, 7): - _Path: TypeAlias = StrOrBytesPath -else: - _Path: TypeAlias = StrPath - DEFAULTSECT: Literal["DEFAULT"] MAX_INTERPOLATION_DEPTH: Literal[10] @@ -110,7 +106,7 @@ class RawConfigParser(_Parser): def has_section(self, section: str) -> bool: ... def options(self, section: str) -> list[str]: ... def has_option(self, section: str, option: str) -> bool: ... - def read(self, filenames: _Path | Iterable[_Path], encoding: str | None = ...) -> list[str]: ... + def read(self, filenames: StrOrBytesPath | Iterable[StrOrBytesPath], encoding: str | None = ...) -> list[str]: ... def read_file(self, f: Iterable[str], source: str | None = ...) -> None: ... def read_string(self, string: str, source: str = ...) -> None: ... def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = ...) -> None: ... @@ -147,9 +143,9 @@ class RawConfigParser(_Parser): ) -> _T: ... # This is incompatible with MutableMapping so we ignore the type @overload # type: ignore[override] - def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> str: ... + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> str | Any: ... @overload - def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T) -> str | _T: ... + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T) -> str | _T | Any: ... @overload def items(self, *, raw: bool = ..., vars: _Section | None = ...) -> ItemsView[str, SectionProxy]: ... @overload @@ -160,7 +156,12 @@ class RawConfigParser(_Parser): def remove_section(self, section: str) -> bool: ... def optionxform(self, optionstr: str) -> str: ... -class ConfigParser(RawConfigParser): ... +class ConfigParser(RawConfigParser): + # This is incompatible with MutableMapping so we ignore the type + @overload # type: ignore[override] + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> str: ... + @overload + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T) -> str | _T: ... if sys.version_info < (3, 12): class SafeConfigParser(ConfigParser): ... # deprecated alias @@ -186,7 +187,7 @@ class SectionProxy(MutableMapping[str, str]): vars: _Section | None = ..., _impl: Any | None = ..., **kwargs: Any, - ) -> str: ... + ) -> str | Any: ... # can be None in RawConfigParser's sections # These are partially-applied version of the methods with the same names in # RawConfigParser; the stubs should be kept updated together @overload diff --git a/mypy/typeshed/stdlib/contextlib.pyi b/mypy/typeshed/stdlib/contextlib.pyi index 81213b954093..dde87c041b26 100644 --- a/mypy/typeshed/stdlib/contextlib.pyi +++ b/mypy/typeshed/stdlib/contextlib.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import Self, StrOrBytesPath from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator from types import TracebackType -from typing import IO, Any, ContextManager, Generic, Protocol, TypeVar, overload # noqa: Y027 +from typing import IO, Any, AsyncContextManager, ContextManager, Generic, Protocol, TypeVar, overload # noqa: Y022,Y027 from typing_extensions import ParamSpec, TypeAlias __all__ = [ @@ -14,23 +14,18 @@ __all__ = [ "redirect_stdout", "redirect_stderr", "suppress", + "AbstractAsyncContextManager", + "AsyncExitStack", + "asynccontextmanager", + "nullcontext", ] -if sys.version_info >= (3, 7): - __all__ += ["AbstractAsyncContextManager", "AsyncExitStack", "asynccontextmanager", "nullcontext"] - if sys.version_info >= (3, 10): __all__ += ["aclosing"] if sys.version_info >= (3, 11): __all__ += ["chdir"] -AbstractContextManager = ContextManager -if sys.version_info >= (3, 7): - from typing import AsyncContextManager # noqa: Y022 - - AbstractAsyncContextManager = AsyncContextManager - _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=IO[str] | None) @@ -40,12 +35,14 @@ _P = ParamSpec("_P") _ExitFunc: TypeAlias = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], bool | None] _CM_EF = TypeVar("_CM_EF", bound=AbstractContextManager[Any] | _ExitFunc) +AbstractContextManager = ContextManager +AbstractAsyncContextManager = AsyncContextManager + class ContextDecorator: def __call__(self, func: _F) -> _F: ... class _GeneratorContextManager(AbstractContextManager[_T_co], ContextDecorator, Generic[_T_co]): - # In Python <= 3.6, __init__ and all instance attributes are defined directly on this class. - # In Python >= 3.7, __init__ and all instance attributes are inherited from _GeneratorContextManagerBase + # __init__ and all instance attributes are actually inherited from _GeneratorContextManagerBase # _GeneratorContextManagerBase is more trouble than it's worth to include in the stub; see #6676 def __init__(self, func: Callable[..., Iterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ... gen: Generator[_T_co, Any, Any] @@ -76,7 +73,7 @@ if sys.version_info >= (3, 10): self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... -elif sys.version_info >= (3, 7): +else: class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]): def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ... gen: AsyncGenerator[_T_co, Any] @@ -87,8 +84,7 @@ elif sys.version_info >= (3, 7): self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... -if sys.version_info >= (3, 7): - def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... +def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... class _SupportsClose(Protocol): def close(self) -> object: ... @@ -135,26 +131,25 @@ class ExitStack: self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool: ... -if sys.version_info >= (3, 7): - _ExitCoroFunc: TypeAlias = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], Awaitable[bool]] - _ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any] | _ExitCoroFunc) - - class AsyncExitStack: - def __init__(self) -> None: ... - def enter_context(self, cm: AbstractContextManager[_T]) -> _T: ... - async def enter_async_context(self, cm: AbstractAsyncContextManager[_T]) -> _T: ... - def push(self, exit: _CM_EF) -> _CM_EF: ... - def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ... - def callback(self, __callback: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ... - def push_async_callback( - self, __callback: Callable[_P, Awaitable[_T]], *args: _P.args, **kwds: _P.kwargs - ) -> Callable[_P, Awaitable[_T]]: ... - def pop_all(self: Self) -> Self: ... - async def aclose(self) -> None: ... - async def __aenter__(self: Self) -> Self: ... - async def __aexit__( - self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None - ) -> bool: ... +_ExitCoroFunc: TypeAlias = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], Awaitable[bool]] +_ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any] | _ExitCoroFunc) + +class AsyncExitStack: + def __init__(self) -> None: ... + def enter_context(self, cm: AbstractContextManager[_T]) -> _T: ... + async def enter_async_context(self, cm: AbstractAsyncContextManager[_T]) -> _T: ... + def push(self, exit: _CM_EF) -> _CM_EF: ... + def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ... + def callback(self, __callback: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ... + def push_async_callback( + self, __callback: Callable[_P, Awaitable[_T]], *args: _P.args, **kwds: _P.kwargs + ) -> Callable[_P, Awaitable[_T]]: ... + def pop_all(self: Self) -> Self: ... + async def aclose(self) -> None: ... + async def __aenter__(self: Self) -> Self: ... + async def __aexit__( + self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None + ) -> bool: ... if sys.version_info >= (3, 10): class nullcontext(AbstractContextManager[_T], AbstractAsyncContextManager[_T]): @@ -168,7 +163,7 @@ if sys.version_info >= (3, 10): async def __aenter__(self) -> _T: ... async def __aexit__(self, *exctype: object) -> None: ... -elif sys.version_info >= (3, 7): +else: class nullcontext(AbstractContextManager[_T]): enter_result: _T @overload diff --git a/mypy/typeshed/stdlib/crypt.pyi b/mypy/typeshed/stdlib/crypt.pyi index 5083f1eebeed..83ad45d5c155 100644 --- a/mypy/typeshed/stdlib/crypt.pyi +++ b/mypy/typeshed/stdlib/crypt.pyi @@ -6,14 +6,7 @@ if sys.platform != "win32": METHOD_MD5: _Method METHOD_SHA256: _Method METHOD_SHA512: _Method - if sys.version_info >= (3, 7): - METHOD_BLOWFISH: _Method - + METHOD_BLOWFISH: _Method methods: list[_Method] - - if sys.version_info >= (3, 7): - def mksalt(method: _Method | None = ..., *, rounds: int | None = ...) -> str: ... - else: - def mksalt(method: _Method | None = ...) -> str: ... - + def mksalt(method: _Method | None = ..., *, rounds: int | None = ...) -> str: ... def crypt(word: str, salt: str | _Method | None = ...) -> str: ... diff --git a/mypy/typeshed/stdlib/ctypes/__init__.pyi b/mypy/typeshed/stdlib/ctypes/__init__.pyi index 00b2be01dc86..386c6a20cf3a 100644 --- a/mypy/typeshed/stdlib/ctypes/__init__.pyi +++ b/mypy/typeshed/stdlib/ctypes/__init__.pyi @@ -192,7 +192,7 @@ class _SimpleCData(Generic[_T], _CData): value: _T # The TypeVar can be unsolved here, # but we can't use overloads without creating many, many mypy false-positive errors - def __init__(self, value: _T = ...) -> None: ... # type: ignore + def __init__(self, value: _T = ...) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] class c_byte(_SimpleCData[int]): ... diff --git a/mypy/typeshed/stdlib/datetime.pyi b/mypy/typeshed/stdlib/datetime.pyi index bcd3413ac38b..4f93eb7205da 100644 --- a/mypy/typeshed/stdlib/datetime.pyi +++ b/mypy/typeshed/stdlib/datetime.pyi @@ -51,9 +51,8 @@ class date: def today(cls: type[Self]) -> Self: ... @classmethod def fromordinal(cls: type[Self], __n: int) -> Self: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: type[Self], __date_string: str) -> Self: ... + @classmethod + def fromisoformat(cls: type[Self], __date_string: str) -> Self: ... if sys.version_info >= (3, 8): @classmethod def fromisocalendar(cls: type[Self], year: int, week: int, day: int) -> Self: ... @@ -135,10 +134,8 @@ class time: def __gt__(self, __other: time) -> bool: ... def __hash__(self) -> int: ... def isoformat(self, timespec: str = ...) -> str: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: type[Self], __time_string: str) -> Self: ... - + @classmethod + def fromisoformat(cls: type[Self], __time_string: str) -> Self: ... def strftime(self, __format: str) -> str: ... def __format__(self, __fmt: str) -> str: ... def utcoffset(self) -> timedelta | None: ... @@ -256,10 +253,8 @@ class datetime(date): def utcnow(cls: type[Self]) -> Self: ... @classmethod def combine(cls, date: _Date, time: _Time, tzinfo: _TzInfo | None = ...) -> datetime: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: type[Self], __date_string: str) -> Self: ... - + @classmethod + def fromisoformat(cls: type[Self], __date_string: str) -> Self: ... def timestamp(self) -> float: ... def utctimetuple(self) -> struct_time: ... def date(self) -> _Date: ... diff --git a/mypy/typeshed/stdlib/dis.pyi b/mypy/typeshed/stdlib/dis.pyi index 0b78e17b360b..dd31d981071f 100644 --- a/mypy/typeshed/stdlib/dis.pyi +++ b/mypy/typeshed/stdlib/dis.pyi @@ -114,11 +114,8 @@ if sys.version_info >= (3, 11): adaptive: bool = ..., ) -> None: ... -elif sys.version_info >= (3, 7): - def dis(x: _HaveCodeOrStringType | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...) -> None: ... - else: - def dis(x: _HaveCodeOrStringType | None = ..., *, file: IO[str] | None = ...) -> None: ... + def dis(x: _HaveCodeOrStringType | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...) -> None: ... if sys.version_info >= (3, 11): def disassemble( diff --git a/mypy/typeshed/stdlib/distutils/cmd.pyi b/mypy/typeshed/stdlib/distutils/cmd.pyi index 8163ae78fd8f..e706bdbc5802 100644 --- a/mypy/typeshed/stdlib/distutils/cmd.pyi +++ b/mypy/typeshed/stdlib/distutils/cmd.pyi @@ -25,7 +25,7 @@ class Command: def run_command(self, command: str) -> None: ... def get_sub_commands(self) -> list[str]: ... def warn(self, msg: str) -> None: ... - def execute(self, func: Callable[..., Any], args: Iterable[Any], msg: str | None = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., object], args: Iterable[Any], msg: str | None = ..., level: int = ...) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... def copy_file( self, @@ -60,7 +60,7 @@ class Command: self, infiles: str | list[str] | tuple[str, ...], outfile: str, - func: Callable[..., Any], + func: Callable[..., object], args: list[Any], exec_msg: str | None = ..., skip_msg: str | None = ..., diff --git a/mypy/typeshed/stdlib/distutils/command/config.pyi b/mypy/typeshed/stdlib/distutils/command/config.pyi index 7ad71e185df8..03466ca72985 100644 --- a/mypy/typeshed/stdlib/distutils/command/config.pyi +++ b/mypy/typeshed/stdlib/distutils/command/config.pyi @@ -1,5 +1,6 @@ from collections.abc import Sequence -from typing import Any, Pattern +from re import Pattern +from typing import Any from ..ccompiler import CCompiler from ..cmd import Command diff --git a/mypy/typeshed/stdlib/distutils/filelist.pyi b/mypy/typeshed/stdlib/distutils/filelist.pyi index d8b87e251509..1cfdcf08dca9 100644 --- a/mypy/typeshed/stdlib/distutils/filelist.pyi +++ b/mypy/typeshed/stdlib/distutils/filelist.pyi @@ -1,5 +1,6 @@ from collections.abc import Iterable -from typing import Pattern, overload +from re import Pattern +from typing import overload from typing_extensions import Literal # class is entirely undocumented diff --git a/mypy/typeshed/stdlib/distutils/version.pyi b/mypy/typeshed/stdlib/distutils/version.pyi index 8745e8c9f680..627d45067b5c 100644 --- a/mypy/typeshed/stdlib/distutils/version.pyi +++ b/mypy/typeshed/stdlib/distutils/version.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from abc import abstractmethod -from typing import Pattern +from re import Pattern class Version: def __eq__(self, other: object) -> bool: ... diff --git a/mypy/typeshed/stdlib/doctest.pyi b/mypy/typeshed/stdlib/doctest.pyi index c767436c2be8..6bb1bf9d33c5 100644 --- a/mypy/typeshed/stdlib/doctest.pyi +++ b/mypy/typeshed/stdlib/doctest.pyi @@ -126,7 +126,7 @@ class DocTestFinder: extraglobs: dict[str, Any] | None = ..., ) -> list[DocTest]: ... -_Out: TypeAlias = Callable[[str], Any] +_Out: TypeAlias = Callable[[str], object] class DocTestRunner: DIVIDER: str @@ -201,8 +201,8 @@ class DocTestCase(unittest.TestCase): self, test: DocTest, optionflags: int = ..., - setUp: Callable[[DocTest], Any] | None = ..., - tearDown: Callable[[DocTest], Any] | None = ..., + setUp: Callable[[DocTest], object] | None = ..., + tearDown: Callable[[DocTest], object] | None = ..., checker: OutputChecker | None = ..., ) -> None: ... def setUp(self) -> None: ... diff --git a/mypy/typeshed/stdlib/email/_header_value_parser.pyi b/mypy/typeshed/stdlib/email/_header_value_parser.pyi index abe6ec63abb1..00d5c9882429 100644 --- a/mypy/typeshed/stdlib/email/_header_value_parser.pyi +++ b/mypy/typeshed/stdlib/email/_header_value_parser.pyi @@ -3,7 +3,8 @@ from _typeshed import Self from collections.abc import Iterable, Iterator from email.errors import HeaderParseError, MessageDefect from email.policy import Policy -from typing import Any, Pattern +from re import Pattern +from typing import Any from typing_extensions import Final WSP: Final[set[str]] @@ -20,8 +21,7 @@ EXTENDED_ATTRIBUTE_ENDS: Final[set[str]] def quote_string(value: Any) -> str: ... -if sys.version_info >= (3, 7): - rfc2047_matcher: Pattern[str] +rfc2047_matcher: Pattern[str] class TokenList(list[TokenList | Terminal]): token_type: str | None diff --git a/mypy/typeshed/stdlib/email/header.pyi b/mypy/typeshed/stdlib/email/header.pyi index bd851bcf8679..9248759168a9 100644 --- a/mypy/typeshed/stdlib/email/header.pyi +++ b/mypy/typeshed/stdlib/email/header.pyi @@ -1,4 +1,5 @@ from email.charset import Charset +from typing import Any __all__ = ["Header", "decode_header", "make_header"] @@ -17,7 +18,10 @@ class Header: def __eq__(self, other: object) -> bool: ... def __ne__(self, __other: object) -> bool: ... -def decode_header(header: Header | str) -> list[tuple[bytes, str | None]]: ... +# decode_header() either returns list[tuple[str, None]] if the header +# contains no encoded parts, or list[tuple[bytes, str | None]] if the header +# contains at least one encoded part. +def decode_header(header: Header | str) -> list[tuple[Any, Any | None]]: ... def make_header( decoded_seq: list[tuple[bytes, str | None]], maxlinelen: int | None = ..., diff --git a/mypy/typeshed/stdlib/email/message.pyi b/mypy/typeshed/stdlib/email/message.pyi index 6544f8fc2385..4e8f600f7ffd 100644 --- a/mypy/typeshed/stdlib/email/message.pyi +++ b/mypy/typeshed/stdlib/email/message.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from collections.abc import Generator, Iterator, Sequence from email import _ParamsType, _ParamType from email.charset import Charset @@ -55,7 +56,7 @@ class Message: def set_boundary(self, boundary: str) -> None: ... def get_content_charset(self, failobj: _T = ...) -> _T | str: ... def get_charsets(self, failobj: _T = ...) -> _T | list[str]: ... - def walk(self) -> Generator[Message, None, None]: ... + def walk(self: Self) -> Generator[Self, None, None]: ... def get_content_disposition(self) -> str | None: ... def as_string(self, unixfrom: bool = ..., maxheaderlen: int = ..., policy: Policy | None = ...) -> str: ... def as_bytes(self, unixfrom: bool = ..., policy: Policy | None = ...) -> bytes: ... diff --git a/mypy/typeshed/stdlib/enum.pyi b/mypy/typeshed/stdlib/enum.pyi index 6063dc47b004..2ec13714c99e 100644 --- a/mypy/typeshed/stdlib/enum.pyi +++ b/mypy/typeshed/stdlib/enum.pyi @@ -80,7 +80,7 @@ class _EnumDict(dict[str, Any]): class EnumMeta(ABCMeta): if sys.version_info >= (3, 11): def __new__( - metacls: type[Self], # type: ignore + metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, @@ -90,9 +90,9 @@ class EnumMeta(ABCMeta): **kwds: Any, ) -> Self: ... elif sys.version_info >= (3, 9): - def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> Self: ... # type: ignore + def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> Self: ... else: - def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> Self: ... # type: ignore + def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> Self: ... if sys.version_info >= (3, 9): @classmethod @@ -161,8 +161,7 @@ class Enum(metaclass=EnumMeta): def value(self) -> Any: ... _name_: str _value_: Any - if sys.version_info >= (3, 7): - _ignore_: str | list[str] + _ignore_: str | list[str] _order_: str __order__: str @classmethod @@ -182,6 +181,8 @@ class Enum(metaclass=EnumMeta): if sys.version_info >= (3, 11): class ReprEnum(Enum): ... + +if sys.version_info >= (3, 11): _IntEnumBase = ReprEnum else: _IntEnumBase = Enum @@ -223,14 +224,26 @@ class Flag(Enum): __rand__ = __and__ __rxor__ = __xor__ -class IntFlag(int, Flag): - def __new__(cls: type[Self], value: int) -> Self: ... - def __or__(self: Self, other: int) -> Self: ... - def __and__(self: Self, other: int) -> Self: ... - def __xor__(self: Self, other: int) -> Self: ... - __ror__ = __or__ - __rand__ = __and__ - __rxor__ = __xor__ +if sys.version_info >= (3, 11): + # The body of the class is the same, but the base classes are different. + class IntFlag(int, ReprEnum, Flag, boundary=KEEP): + def __new__(cls: type[Self], value: int) -> Self: ... + def __or__(self: Self, other: int) -> Self: ... + def __and__(self: Self, other: int) -> Self: ... + def __xor__(self: Self, other: int) -> Self: ... + __ror__ = __or__ + __rand__ = __and__ + __rxor__ = __xor__ + +else: + class IntFlag(int, Flag): + def __new__(cls: type[Self], value: int) -> Self: ... + def __or__(self: Self, other: int) -> Self: ... + def __and__(self: Self, other: int) -> Self: ... + def __xor__(self: Self, other: int) -> Self: ... + __ror__ = __or__ + __rand__ = __and__ + __rxor__ = __xor__ if sys.version_info >= (3, 11): class StrEnum(str, ReprEnum): diff --git a/mypy/typeshed/stdlib/fractions.pyi b/mypy/typeshed/stdlib/fractions.pyi index fb64c659224a..e05f59e3d191 100644 --- a/mypy/typeshed/stdlib/fractions.pyi +++ b/mypy/typeshed/stdlib/fractions.pyi @@ -37,112 +37,112 @@ class Fraction(Rational): def as_integer_ratio(self) -> tuple[int, int]: ... @property - def numerator(self) -> int: ... + def numerator(a) -> int: ... @property - def denominator(self) -> int: ... + def denominator(a) -> int: ... @overload - def __add__(self, b: int | Fraction) -> Fraction: ... + def __add__(a, b: int | Fraction) -> Fraction: ... @overload - def __add__(self, b: float) -> float: ... + def __add__(a, b: float) -> float: ... @overload - def __add__(self, b: complex) -> complex: ... + def __add__(a, b: complex) -> complex: ... @overload - def __radd__(self, a: int | Fraction) -> Fraction: ... + def __radd__(b, a: int | Fraction) -> Fraction: ... @overload - def __radd__(self, a: float) -> float: ... + def __radd__(b, a: float) -> float: ... @overload - def __radd__(self, a: complex) -> complex: ... + def __radd__(b, a: complex) -> complex: ... @overload - def __sub__(self, b: int | Fraction) -> Fraction: ... + def __sub__(a, b: int | Fraction) -> Fraction: ... @overload - def __sub__(self, b: float) -> float: ... + def __sub__(a, b: float) -> float: ... @overload - def __sub__(self, b: complex) -> complex: ... + def __sub__(a, b: complex) -> complex: ... @overload - def __rsub__(self, a: int | Fraction) -> Fraction: ... + def __rsub__(b, a: int | Fraction) -> Fraction: ... @overload - def __rsub__(self, a: float) -> float: ... + def __rsub__(b, a: float) -> float: ... @overload - def __rsub__(self, a: complex) -> complex: ... + def __rsub__(b, a: complex) -> complex: ... @overload - def __mul__(self, b: int | Fraction) -> Fraction: ... + def __mul__(a, b: int | Fraction) -> Fraction: ... @overload - def __mul__(self, b: float) -> float: ... + def __mul__(a, b: float) -> float: ... @overload - def __mul__(self, b: complex) -> complex: ... + def __mul__(a, b: complex) -> complex: ... @overload - def __rmul__(self, a: int | Fraction) -> Fraction: ... + def __rmul__(b, a: int | Fraction) -> Fraction: ... @overload - def __rmul__(self, a: float) -> float: ... + def __rmul__(b, a: float) -> float: ... @overload - def __rmul__(self, a: complex) -> complex: ... + def __rmul__(b, a: complex) -> complex: ... @overload - def __truediv__(self, b: int | Fraction) -> Fraction: ... + def __truediv__(a, b: int | Fraction) -> Fraction: ... @overload - def __truediv__(self, b: float) -> float: ... + def __truediv__(a, b: float) -> float: ... @overload - def __truediv__(self, b: complex) -> complex: ... + def __truediv__(a, b: complex) -> complex: ... @overload - def __rtruediv__(self, a: int | Fraction) -> Fraction: ... + def __rtruediv__(b, a: int | Fraction) -> Fraction: ... @overload - def __rtruediv__(self, a: float) -> float: ... + def __rtruediv__(b, a: float) -> float: ... @overload - def __rtruediv__(self, a: complex) -> complex: ... + def __rtruediv__(b, a: complex) -> complex: ... @overload - def __floordiv__(self, b: int | Fraction) -> int: ... + def __floordiv__(a, b: int | Fraction) -> int: ... @overload - def __floordiv__(self, b: float) -> float: ... + def __floordiv__(a, b: float) -> float: ... @overload - def __rfloordiv__(self, a: int | Fraction) -> int: ... + def __rfloordiv__(b, a: int | Fraction) -> int: ... @overload - def __rfloordiv__(self, a: float) -> float: ... + def __rfloordiv__(b, a: float) -> float: ... @overload - def __mod__(self, b: int | Fraction) -> Fraction: ... + def __mod__(a, b: int | Fraction) -> Fraction: ... @overload - def __mod__(self, b: float) -> float: ... + def __mod__(a, b: float) -> float: ... @overload - def __rmod__(self, a: int | Fraction) -> Fraction: ... + def __rmod__(b, a: int | Fraction) -> Fraction: ... @overload - def __rmod__(self, a: float) -> float: ... + def __rmod__(b, a: float) -> float: ... @overload - def __divmod__(self, b: int | Fraction) -> tuple[int, Fraction]: ... + def __divmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __divmod__(self, b: float) -> tuple[float, Fraction]: ... + def __divmod__(a, b: float) -> tuple[float, Fraction]: ... @overload - def __rdivmod__(self, a: int | Fraction) -> tuple[int, Fraction]: ... + def __rdivmod__(b, a: int | Fraction) -> tuple[int, Fraction]: ... @overload - def __rdivmod__(self, a: float) -> tuple[float, Fraction]: ... + def __rdivmod__(b, a: float) -> tuple[float, Fraction]: ... @overload - def __pow__(self, b: int) -> Fraction: ... + def __pow__(a, b: int) -> Fraction: ... @overload - def __pow__(self, b: float | Fraction) -> float: ... + def __pow__(a, b: float | Fraction) -> float: ... @overload - def __pow__(self, b: complex) -> complex: ... + def __pow__(a, b: complex) -> complex: ... @overload - def __rpow__(self, a: float | Fraction) -> float: ... + def __rpow__(b, a: float | Fraction) -> float: ... @overload - def __rpow__(self, a: complex) -> complex: ... - def __pos__(self) -> Fraction: ... - def __neg__(self) -> Fraction: ... - def __abs__(self) -> Fraction: ... - def __trunc__(self) -> int: ... - def __floor__(self) -> int: ... - def __ceil__(self) -> int: ... + def __rpow__(b, a: complex) -> complex: ... + def __pos__(a) -> Fraction: ... + def __neg__(a) -> Fraction: ... + def __abs__(a) -> Fraction: ... + def __trunc__(a) -> int: ... + def __floor__(a) -> int: ... + def __ceil__(a) -> int: ... @overload def __round__(self, ndigits: None = ...) -> int: ... @overload def __round__(self, ndigits: int) -> Fraction: ... def __hash__(self) -> int: ... - def __eq__(self, b: object) -> bool: ... - def __lt__(self, b: _ComparableNum) -> bool: ... - def __gt__(self, b: _ComparableNum) -> bool: ... - def __le__(self, b: _ComparableNum) -> bool: ... - def __ge__(self, b: _ComparableNum) -> bool: ... - def __bool__(self) -> bool: ... + def __eq__(a, b: object) -> bool: ... + def __lt__(a, b: _ComparableNum) -> bool: ... + def __gt__(a, b: _ComparableNum) -> bool: ... + def __le__(a, b: _ComparableNum) -> bool: ... + def __ge__(a, b: _ComparableNum) -> bool: ... + def __bool__(a) -> bool: ... def __copy__(self: Self) -> Self: ... def __deepcopy__(self: Self, memo: Any) -> Self: ... if sys.version_info >= (3, 11): - def __int__(self, _index: Callable[[SupportsIndex], int] = ...) -> int: ... + def __int__(a, _index: Callable[[SupportsIndex], int] = ...) -> int: ... # Not actually defined within fractions.py, but provides more useful # overrides @property diff --git a/mypy/typeshed/stdlib/ftplib.pyi b/mypy/typeshed/stdlib/ftplib.pyi index 49c680a6f0c7..3d284c597019 100644 --- a/mypy/typeshed/stdlib/ftplib.pyi +++ b/mypy/typeshed/stdlib/ftplib.pyi @@ -90,22 +90,22 @@ class FTP: def ntransfercmd(self, cmd: str, rest: int | str | None = ...) -> tuple[socket, int]: ... def transfercmd(self, cmd: str, rest: int | str | None = ...) -> socket: ... def retrbinary( - self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: int | str | None = ... + self, cmd: str, callback: Callable[[bytes], object], blocksize: int = ..., rest: int | str | None = ... ) -> str: ... def storbinary( self, cmd: str, fp: SupportsRead[bytes], blocksize: int = ..., - callback: Callable[[bytes], Any] | None = ..., + callback: Callable[[bytes], object] | None = ..., rest: int | str | None = ..., ) -> str: ... - def retrlines(self, cmd: str, callback: Callable[[str], Any] | None = ...) -> str: ... - def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Callable[[bytes], Any] | None = ...) -> str: ... + def retrlines(self, cmd: str, callback: Callable[[str], object] | None = ...) -> str: ... + def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Callable[[bytes], object] | None = ...) -> str: ... def acct(self, password: str) -> str: ... def nlst(self, *args: str) -> list[str]: ... # Technically only the last arg can be a Callable but ... - def dir(self, *args: str | Callable[[str], None]) -> None: ... + def dir(self, *args: str | Callable[[str], object]) -> None: ... def mlsd(self, path: str = ..., facts: Iterable[str] = ...) -> Iterator[tuple[str, dict[str, str]]]: ... def rename(self, fromname: str, toname: str) -> str: ... def delete(self, filename: str) -> str: ... diff --git a/mypy/typeshed/stdlib/functools.pyi b/mypy/typeshed/stdlib/functools.pyi index 3003ef061a84..5c3f662c3dd5 100644 --- a/mypy/typeshed/stdlib/functools.pyi +++ b/mypy/typeshed/stdlib/functools.pyi @@ -28,7 +28,7 @@ if sys.version_info >= (3, 8): if sys.version_info >= (3, 9): __all__ += ["cache"] -_AnyCallable: TypeAlias = Callable[..., Any] +_AnyCallable: TypeAlias = Callable[..., object] _T = TypeVar("_T") _S = TypeVar("_S") diff --git a/mypy/typeshed/stdlib/gc.pyi b/mypy/typeshed/stdlib/gc.pyi index 98b92e109f82..d24b7c1f4c7c 100644 --- a/mypy/typeshed/stdlib/gc.pyi +++ b/mypy/typeshed/stdlib/gc.pyi @@ -26,11 +26,9 @@ if sys.version_info >= (3, 8): else: def get_objects() -> list[Any]: ... -if sys.version_info >= (3, 7): - def freeze() -> None: ... - def unfreeze() -> None: ... - def get_freeze_count() -> int: ... - +def freeze() -> None: ... +def unfreeze() -> None: ... +def get_freeze_count() -> int: ... def get_referents(*objs: Any) -> list[Any]: ... def get_referrers(*objs: Any) -> list[Any]: ... def get_stats() -> list[dict[str, Any]]: ... diff --git a/mypy/typeshed/stdlib/heapq.pyi b/mypy/typeshed/stdlib/heapq.pyi index f07afc7af706..b280322685db 100644 --- a/mypy/typeshed/stdlib/heapq.pyi +++ b/mypy/typeshed/stdlib/heapq.pyi @@ -9,7 +9,9 @@ _S = TypeVar("_S") __about__: str -def merge(*iterables: Iterable[_S], key: Callable[[_S], Any] | None = ..., reverse: bool = ...) -> Iterable[_S]: ... +def merge( + *iterables: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = ..., reverse: bool = ... +) -> Iterable[_S]: ... def nlargest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = ...) -> list[_S]: ... def nsmallest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = ...) -> list[_S]: ... def _heapify_max(__x: list[Any]) -> None: ... # undocumented diff --git a/mypy/typeshed/stdlib/hmac.pyi b/mypy/typeshed/stdlib/hmac.pyi index a7bf15493f0b..af69fc7ea46d 100644 --- a/mypy/typeshed/stdlib/hmac.pyi +++ b/mypy/typeshed/stdlib/hmac.pyi @@ -40,6 +40,4 @@ class HMAC: def compare_digest(__a: ReadableBuffer, __b: ReadableBuffer) -> bool: ... @overload def compare_digest(__a: AnyStr, __b: AnyStr) -> bool: ... - -if sys.version_info >= (3, 7): - def digest(key: bytes, msg: ReadableBuffer, digest: _DigestMod) -> bytes: ... +def digest(key: bytes, msg: ReadableBuffer, digest: _DigestMod) -> bytes: ... diff --git a/mypy/typeshed/stdlib/html/parser.pyi b/mypy/typeshed/stdlib/html/parser.pyi index 1731a345920b..2948eadc9800 100644 --- a/mypy/typeshed/stdlib/html/parser.pyi +++ b/mypy/typeshed/stdlib/html/parser.pyi @@ -1,5 +1,5 @@ from _markupbase import ParserBase -from typing import Pattern +from re import Pattern __all__ = ["HTMLParser"] diff --git a/mypy/typeshed/stdlib/http/__init__.pyi b/mypy/typeshed/stdlib/http/__init__.pyi index 10c1d5926e84..d4b44f2eb99b 100644 --- a/mypy/typeshed/stdlib/http/__init__.pyi +++ b/mypy/typeshed/stdlib/http/__init__.pyi @@ -72,8 +72,7 @@ class HTTPStatus(IntEnum): LOOP_DETECTED: int NOT_EXTENDED: int NETWORK_AUTHENTICATION_REQUIRED: int - if sys.version_info >= (3, 7): - MISDIRECTED_REQUEST: int + MISDIRECTED_REQUEST: int if sys.version_info >= (3, 8): UNAVAILABLE_FOR_LEGAL_REASONS: int if sys.version_info >= (3, 9): diff --git a/mypy/typeshed/stdlib/http/client.pyi b/mypy/typeshed/stdlib/http/client.pyi index 235b6d6b4951..2c75e7b37c2e 100644 --- a/mypy/typeshed/stdlib/http/client.pyi +++ b/mypy/typeshed/stdlib/http/client.pyi @@ -1,7 +1,6 @@ import email.message import io import ssl -import sys import types from _typeshed import Self, WriteableBuffer from collections.abc import Callable, Iterable, Iterator, Mapping @@ -141,19 +140,14 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): # This is an API stub only for the class below, not a class itself. # urllib.request uses it for a parameter. class _HTTPConnectionProtocol(Protocol): - if sys.version_info >= (3, 7): - def __call__( - self, - host: str, - port: int | None = ..., - timeout: float = ..., - source_address: tuple[str, int] | None = ..., - blocksize: int = ..., - ) -> HTTPConnection: ... - else: - def __call__( - self, host: str, port: int | None = ..., timeout: float = ..., source_address: tuple[str, int] | None = ... - ) -> HTTPConnection: ... + def __call__( + self, + host: str, + port: int | None = ..., + timeout: float = ..., + source_address: tuple[str, int] | None = ..., + blocksize: int = ..., + ) -> HTTPConnection: ... class HTTPConnection: auto_open: int # undocumented @@ -163,21 +157,15 @@ class HTTPConnection: timeout: float | None host: str port: int - sock: Any - if sys.version_info >= (3, 7): - def __init__( - self, - host: str, - port: int | None = ..., - timeout: float | None = ..., - source_address: tuple[str, int] | None = ..., - blocksize: int = ..., - ) -> None: ... - else: - def __init__( - self, host: str, port: int | None = ..., timeout: float | None = ..., source_address: tuple[str, int] | None = ... - ) -> None: ... - + sock: socket | Any # can be `None` if `.connect()` was not called + def __init__( + self, + host: str, + port: int | None = ..., + timeout: float | None = ..., + source_address: tuple[str, int] | None = ..., + blocksize: int = ..., + ) -> None: ... def request( self, method: str, url: str, body: _DataType | None = ..., headers: Mapping[str, str] = ..., *, encode_chunked: bool = ... ) -> None: ... @@ -192,33 +180,21 @@ class HTTPConnection: def send(self, data: _DataType) -> None: ... class HTTPSConnection(HTTPConnection): - if sys.version_info >= (3, 7): - def __init__( - self, - host: str, - port: int | None = ..., - key_file: str | None = ..., - cert_file: str | None = ..., - timeout: float | None = ..., - source_address: tuple[str, int] | None = ..., - *, - context: ssl.SSLContext | None = ..., - check_hostname: bool | None = ..., - blocksize: int = ..., - ) -> None: ... - else: - def __init__( - self, - host: str, - port: int | None = ..., - key_file: str | None = ..., - cert_file: str | None = ..., - timeout: float | None = ..., - source_address: tuple[str, int] | None = ..., - *, - context: ssl.SSLContext | None = ..., - check_hostname: bool | None = ..., - ) -> None: ... + # Can be `None` if `.connect()` was not called: + sock: ssl.SSLSocket | Any # type: ignore[override] + def __init__( + self, + host: str, + port: int | None = ..., + key_file: str | None = ..., + cert_file: str | None = ..., + timeout: float | None = ..., + source_address: tuple[str, int] | None = ..., + *, + context: ssl.SSLContext | None = ..., + check_hostname: bool | None = ..., + blocksize: int = ..., + ) -> None: ... class HTTPException(Exception): ... diff --git a/mypy/typeshed/stdlib/http/cookiejar.pyi b/mypy/typeshed/stdlib/http/cookiejar.pyi index af33472a32e3..dc3c0e17d336 100644 --- a/mypy/typeshed/stdlib/http/cookiejar.pyi +++ b/mypy/typeshed/stdlib/http/cookiejar.pyi @@ -2,7 +2,8 @@ import sys from _typeshed import StrPath from collections.abc import Iterable, Iterator, Sequence from http.client import HTTPResponse -from typing import ClassVar, Pattern, TypeVar, overload +from re import Pattern +from typing import ClassVar, TypeVar, overload from urllib.request import Request __all__ = [ diff --git a/mypy/typeshed/stdlib/http/cookies.pyi b/mypy/typeshed/stdlib/http/cookies.pyi index e5aa2c1609db..e2fe44d305ef 100644 --- a/mypy/typeshed/stdlib/http/cookies.pyi +++ b/mypy/typeshed/stdlib/http/cookies.pyi @@ -30,11 +30,7 @@ class Morsel(dict[str, Any], Generic[_T]): @property def key(self) -> str: ... def __init__(self) -> None: ... - if sys.version_info >= (3, 7): - def set(self, key: str, val: str, coded_val: _T) -> None: ... - else: - def set(self, key: str, val: str, coded_val: _T, LegalChars: str = ...) -> None: ... - + def set(self, key: str, val: str, coded_val: _T) -> None: ... def setdefault(self, key: str, val: str | None = ...) -> str: ... # The dict update can also get a keywords argument so this is incompatible @overload # type: ignore[override] diff --git a/mypy/typeshed/stdlib/http/server.pyi b/mypy/typeshed/stdlib/http/server.pyi index ad314cec1541..e73497bb18bc 100644 --- a/mypy/typeshed/stdlib/http/server.pyi +++ b/mypy/typeshed/stdlib/http/server.pyi @@ -1,23 +1,18 @@ import email.message import io import socketserver -import sys from _typeshed import StrPath, SupportsRead, SupportsWrite from collections.abc import Mapping, Sequence from typing import Any, AnyStr, BinaryIO, ClassVar -if sys.version_info >= (3, 7): - __all__ = ["HTTPServer", "ThreadingHTTPServer", "BaseHTTPRequestHandler", "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler"] -else: - __all__ = ["HTTPServer", "BaseHTTPRequestHandler", "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler"] +__all__ = ["HTTPServer", "ThreadingHTTPServer", "BaseHTTPRequestHandler", "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler"] class HTTPServer(socketserver.TCPServer): server_name: str server_port: int -if sys.version_info >= (3, 7): - class ThreadingHTTPServer(socketserver.ThreadingMixIn, HTTPServer): - daemon_threads: bool # undocumented +class ThreadingHTTPServer(socketserver.ThreadingMixIn, HTTPServer): + daemon_threads: bool # undocumented class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): client_address: tuple[str, int] @@ -60,13 +55,9 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): server_version: str extensions_map: dict[str, str] - if sys.version_info >= (3, 7): - def __init__( - self, request: bytes, client_address: tuple[str, int], server: socketserver.BaseServer, directory: str | None = ... - ) -> None: ... - else: - def __init__(self, request: bytes, client_address: tuple[str, int], server: socketserver.BaseServer) -> None: ... - + def __init__( + self, request: bytes, client_address: tuple[str, int], server: socketserver.BaseServer, directory: str | None = ... + ) -> None: ... def do_GET(self) -> None: ... def do_HEAD(self) -> None: ... def send_head(self) -> io.BytesIO | BinaryIO | None: ... # undocumented diff --git a/mypy/typeshed/stdlib/imaplib.pyi b/mypy/typeshed/stdlib/imaplib.pyi index 347fee386717..a313b20a999f 100644 --- a/mypy/typeshed/stdlib/imaplib.pyi +++ b/mypy/typeshed/stdlib/imaplib.pyi @@ -4,10 +4,11 @@ import time from _typeshed import Self from builtins import list as _list # conflicts with a method named "list" from collections.abc import Callable +from re import Pattern from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Pattern +from typing import IO, Any from typing_extensions import Literal, TypeAlias __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] @@ -18,6 +19,8 @@ _CommandResults: TypeAlias = tuple[str, list[Any]] _AnyResponseData: TypeAlias = list[None] | list[bytes | tuple[bytes, bytes]] +Commands: dict[str, tuple[str, ...]] + class IMAP4: class error(Exception): ... class abort(error): ... diff --git a/mypy/typeshed/stdlib/importlib/abc.pyi b/mypy/typeshed/stdlib/importlib/abc.pyi index 805910329b64..42b56d88d75b 100644 --- a/mypy/typeshed/stdlib/importlib/abc.pyi +++ b/mypy/typeshed/stdlib/importlib/abc.pyi @@ -96,21 +96,20 @@ class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta): def get_filename(self, name: str | None = ...) -> _Path: ... def load_module(self, name: str | None = ...) -> types.ModuleType: ... -if sys.version_info >= (3, 7): - class ResourceReader(metaclass=ABCMeta): +class ResourceReader(metaclass=ABCMeta): + @abstractmethod + def open_resource(self, resource: StrOrBytesPath) -> IO[bytes]: ... + @abstractmethod + def resource_path(self, resource: StrOrBytesPath) -> str: ... + if sys.version_info >= (3, 10): @abstractmethod - def open_resource(self, resource: StrOrBytesPath) -> IO[bytes]: ... + def is_resource(self, path: str) -> bool: ... + else: @abstractmethod - def resource_path(self, resource: StrOrBytesPath) -> str: ... - if sys.version_info >= (3, 10): - @abstractmethod - def is_resource(self, path: str) -> bool: ... - else: - @abstractmethod - def is_resource(self, name: str) -> bool: ... + def is_resource(self, name: str) -> bool: ... - @abstractmethod - def contents(self) -> Iterator[str]: ... + @abstractmethod + def contents(self) -> Iterator[str]: ... if sys.version_info >= (3, 9): @runtime_checkable diff --git a/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi b/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi index 6466ce0a23ac..99fecb41497d 100644 --- a/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi +++ b/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi @@ -7,7 +7,8 @@ from email.message import Message from importlib.abc import MetaPathFinder from os import PathLike from pathlib import Path -from typing import Any, ClassVar, NamedTuple, Pattern, overload +from re import Pattern +from typing import Any, ClassVar, NamedTuple, overload __all__ = [ "Distribution", @@ -169,7 +170,7 @@ class MetadataPathFinder(DistributionFinder): def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ... if sys.version_info >= (3, 10): # Yes, this is an instance method that has argumend named "cls" - def invalidate_caches(cls) -> None: ... # type: ignore + def invalidate_caches(cls) -> None: ... class PathDistribution(Distribution): def __init__(self, path: Path) -> None: ... diff --git a/mypy/typeshed/stdlib/importlib/util.pyi b/mypy/typeshed/stdlib/importlib/util.pyi index 2546c2c7882f..dca4778fd416 100644 --- a/mypy/typeshed/stdlib/importlib/util.pyi +++ b/mypy/typeshed/stdlib/importlib/util.pyi @@ -1,6 +1,5 @@ import importlib.abc import importlib.machinery -import sys import types from _typeshed import StrOrBytesPath from collections.abc import Callable @@ -39,5 +38,4 @@ class LazyLoader(importlib.abc.Loader): def create_module(self, spec: importlib.machinery.ModuleSpec) -> types.ModuleType | None: ... def exec_module(self, module: types.ModuleType) -> None: ... -if sys.version_info >= (3, 7): - def source_hash(source_bytes: bytes) -> int: ... +def source_hash(source_bytes: bytes) -> int: ... diff --git a/mypy/typeshed/stdlib/inspect.pyi b/mypy/typeshed/stdlib/inspect.pyi index 53c0c0f6f08e..7f9667c6ebed 100644 --- a/mypy/typeshed/stdlib/inspect.pyi +++ b/mypy/typeshed/stdlib/inspect.pyi @@ -4,11 +4,12 @@ import sys import types from _typeshed import Self from collections import OrderedDict -from collections.abc import Awaitable, Callable, Coroutine, Generator, Mapping, Sequence, Set as AbstractSet +from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator, Mapping, Sequence, Set as AbstractSet from types import ( AsyncGeneratorType, BuiltinFunctionType, BuiltinMethodType, + ClassMethodDescriptorType, CodeType, CoroutineType, FrameType, @@ -16,23 +17,16 @@ from types import ( GeneratorType, GetSetDescriptorType, LambdaType, + MemberDescriptorType, + MethodDescriptorType, MethodType, + MethodWrapperType, ModuleType, TracebackType, + WrapperDescriptorType, ) -from typing_extensions import TypeAlias - -if sys.version_info >= (3, 7): - from types import ( - ClassMethodDescriptorType, - WrapperDescriptorType, - MemberDescriptorType, - MethodDescriptorType, - MethodWrapperType, - ) - -from typing import Any, ClassVar, NamedTuple, Protocol, TypeVar, Union -from typing_extensions import Literal, ParamSpec, TypeGuard +from typing import Any, ClassVar, NamedTuple, Protocol, TypeVar, Union, overload +from typing_extensions import Literal, ParamSpec, TypeAlias, TypeGuard if sys.version_info >= (3, 11): __all__ = [ @@ -135,6 +129,7 @@ if sys.version_info >= (3, 11): ] _P = ParamSpec("_P") +_T = TypeVar("_T") _T_cont = TypeVar("_T_cont", contravariant=True) _V_cont = TypeVar("_V_cont", contravariant=True) @@ -182,22 +177,56 @@ def ismethod(object: object) -> TypeGuard[MethodType]: ... def isfunction(object: object) -> TypeGuard[FunctionType]: ... if sys.version_info >= (3, 8): - def isgeneratorfunction(obj: object) -> bool: ... - def iscoroutinefunction(obj: object) -> bool: ... + @overload + def isgeneratorfunction(obj: Callable[..., Generator[Any, Any, Any]]) -> bool: ... + @overload + def isgeneratorfunction(obj: Callable[_P, Any]) -> TypeGuard[Callable[_P, GeneratorType[Any, Any, Any]]]: ... + @overload + def isgeneratorfunction(obj: object) -> TypeGuard[Callable[..., GeneratorType[Any, Any, Any]]]: ... + @overload + def iscoroutinefunction(obj: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ... + @overload + def iscoroutinefunction(obj: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, CoroutineType[Any, Any, _T]]]: ... + @overload + def iscoroutinefunction(obj: Callable[_P, object]) -> TypeGuard[Callable[_P, CoroutineType[Any, Any, Any]]]: ... + @overload + def iscoroutinefunction(obj: object) -> TypeGuard[Callable[..., CoroutineType[Any, Any, Any]]]: ... else: - def isgeneratorfunction(object: object) -> bool: ... - def iscoroutinefunction(object: object) -> bool: ... + @overload + def isgeneratorfunction(object: Callable[..., Generator[Any, Any, Any]]) -> bool: ... + @overload + def isgeneratorfunction(object: Callable[_P, Any]) -> TypeGuard[Callable[_P, GeneratorType[Any, Any, Any]]]: ... + @overload + def isgeneratorfunction(object: object) -> TypeGuard[Callable[..., GeneratorType[Any, Any, Any]]]: ... + @overload + def iscoroutinefunction(object: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ... + @overload + def iscoroutinefunction(object: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, CoroutineType[Any, Any, _T]]]: ... + @overload + def iscoroutinefunction(object: Callable[_P, Any]) -> TypeGuard[Callable[_P, CoroutineType[Any, Any, Any]]]: ... + @overload + def iscoroutinefunction(object: object) -> TypeGuard[Callable[..., CoroutineType[Any, Any, Any]]]: ... def isgenerator(object: object) -> TypeGuard[GeneratorType[Any, Any, Any]]: ... def iscoroutine(object: object) -> TypeGuard[CoroutineType[Any, Any, Any]]: ... def isawaitable(object: object) -> TypeGuard[Awaitable[Any]]: ... if sys.version_info >= (3, 8): - def isasyncgenfunction(obj: object) -> bool: ... + @overload + def isasyncgenfunction(obj: Callable[..., AsyncGenerator[Any, Any]]) -> bool: ... + @overload + def isasyncgenfunction(obj: Callable[_P, Any]) -> TypeGuard[Callable[_P, AsyncGeneratorType[Any, Any]]]: ... + @overload + def isasyncgenfunction(obj: object) -> TypeGuard[Callable[..., AsyncGeneratorType[Any, Any]]]: ... else: - def isasyncgenfunction(object: object) -> bool: ... + @overload + def isasyncgenfunction(object: Callable[..., AsyncGenerator[Any, Any]]) -> bool: ... + @overload + def isasyncgenfunction(object: Callable[_P, Any]) -> TypeGuard[Callable[_P, AsyncGeneratorType[Any, Any]]]: ... + @overload + def isasyncgenfunction(object: object) -> TypeGuard[Callable[..., AsyncGeneratorType[Any, Any]]]: ... class _SupportsSet(Protocol[_T_cont, _V_cont]): def __set__(self, __instance: _T_cont, __value: _V_cont) -> None: ... @@ -214,29 +243,20 @@ def isbuiltin(object: object) -> TypeGuard[BuiltinFunctionType]: ... if sys.version_info >= (3, 11): def ismethodwrapper(object: object) -> TypeGuard[MethodWrapperType]: ... -if sys.version_info >= (3, 7): - def isroutine( - object: object, - ) -> TypeGuard[ - FunctionType - | LambdaType - | MethodType - | BuiltinFunctionType - | BuiltinMethodType - | WrapperDescriptorType - | MethodDescriptorType - | ClassMethodDescriptorType - ]: ... - def ismethoddescriptor(object: object) -> TypeGuard[MethodDescriptorType]: ... - def ismemberdescriptor(object: object) -> TypeGuard[MemberDescriptorType]: ... - -else: - def isroutine( - object: object, - ) -> TypeGuard[FunctionType | LambdaType | MethodType | BuiltinFunctionType | BuiltinMethodType]: ... - def ismethoddescriptor(object: object) -> bool: ... - def ismemberdescriptor(object: object) -> bool: ... - +def isroutine( + object: object, +) -> TypeGuard[ + FunctionType + | LambdaType + | MethodType + | BuiltinFunctionType + | BuiltinMethodType + | WrapperDescriptorType + | MethodDescriptorType + | ClassMethodDescriptorType +]: ... +def ismethoddescriptor(object: object) -> TypeGuard[MethodDescriptorType]: ... +def ismemberdescriptor(object: object) -> TypeGuard[MemberDescriptorType]: ... def isabstract(object: object) -> bool: ... def isgetsetdescriptor(object: object) -> TypeGuard[GetSetDescriptorType]: ... def isdatadescriptor(object: object) -> TypeGuard[_SupportsSet[Any, Any] | _SupportsDelete[Any]]: ... diff --git a/mypy/typeshed/stdlib/io.pyi b/mypy/typeshed/stdlib/io.pyi index 0670b65fe359..c92fe1644053 100644 --- a/mypy/typeshed/stdlib/io.pyi +++ b/mypy/typeshed/stdlib/io.pyi @@ -110,19 +110,13 @@ class BytesIO(BufferedIOBase, BinaryIO): def __enter__(self: Self) -> Self: ... def getvalue(self) -> bytes: ... def getbuffer(self) -> memoryview: ... - if sys.version_info >= (3, 7): - def read1(self, __size: int | None = ...) -> bytes: ... - else: - def read1(self, __size: int | None) -> bytes: ... # type: ignore[override] + def read1(self, __size: int | None = ...) -> bytes: ... class BufferedReader(BufferedIOBase, BinaryIO): def __enter__(self: Self) -> Self: ... def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... def peek(self, __size: int = ...) -> bytes: ... - if sys.version_info >= (3, 7): - def read1(self, __size: int = ...) -> bytes: ... - else: - def read1(self, __size: int) -> bytes: ... # type: ignore[override] + def read1(self, __size: int = ...) -> bytes: ... class BufferedWriter(BufferedIOBase, BinaryIO): def __enter__(self: Self) -> Self: ... @@ -133,10 +127,7 @@ class BufferedRandom(BufferedReader, BufferedWriter): def __enter__(self: Self) -> Self: ... def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... def seek(self, __target: int, __whence: int = ...) -> int: ... - if sys.version_info >= (3, 7): - def read1(self, __size: int = ...) -> bytes: ... - else: - def read1(self, __size: int) -> bytes: ... # type: ignore[override] + def read1(self, __size: int = ...) -> bytes: ... class BufferedRWPair(BufferedIOBase): def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = ...) -> None: ... @@ -172,18 +163,17 @@ class TextIOWrapper(TextIOBase, TextIO): def closed(self) -> bool: ... @property def line_buffering(self) -> bool: ... - if sys.version_info >= (3, 7): - @property - def write_through(self) -> bool: ... - def reconfigure( - self, - *, - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., - line_buffering: bool | None = ..., - write_through: bool | None = ..., - ) -> None: ... + @property + def write_through(self) -> bool: ... + def reconfigure( + self, + *, + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., + line_buffering: bool | None = ..., + write_through: bool | None = ..., + ) -> None: ... # These are inherited from TextIOBase, but must exist in the stub to satisfy mypy. def __enter__(self: Self) -> Self: ... def __iter__(self) -> Iterator[str]: ... # type: ignore[override] diff --git a/mypy/typeshed/stdlib/ipaddress.pyi b/mypy/typeshed/stdlib/ipaddress.pyi index 1fdc6c57d8a8..4f9109363b53 100644 --- a/mypy/typeshed/stdlib/ipaddress.pyi +++ b/mypy/typeshed/stdlib/ipaddress.pyi @@ -109,10 +109,8 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): def overlaps(self, other: _BaseNetwork[IPv4Address] | _BaseNetwork[IPv6Address]) -> bool: ... @property def prefixlen(self) -> int: ... - if sys.version_info >= (3, 7): - def subnet_of(self: Self, other: Self) -> bool: ... - def supernet_of(self: Self, other: Self) -> bool: ... - + def subnet_of(self: Self, other: Self) -> bool: ... + def supernet_of(self: Self, other: Self) -> bool: ... def subnets(self: Self, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> Iterator[Self]: ... def supernet(self: Self, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> Self: ... @property diff --git a/mypy/typeshed/stdlib/json/encoder.pyi b/mypy/typeshed/stdlib/json/encoder.pyi index ecd1fa78ad99..60e82061946b 100644 --- a/mypy/typeshed/stdlib/json/encoder.pyi +++ b/mypy/typeshed/stdlib/json/encoder.pyi @@ -1,5 +1,6 @@ from collections.abc import Callable, Iterator -from typing import Any, Pattern +from re import Pattern +from typing import Any ESCAPE: Pattern[str] ESCAPE_ASCII: Pattern[str] diff --git a/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi b/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi index 551ece19abd3..c3fabe8a5177 100644 --- a/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi @@ -1,4 +1,4 @@ -from typing import Match +from re import Match simple_escapes: dict[str, str] diff --git a/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi b/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi index 2f944c40a02c..debcb2193987 100644 --- a/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi @@ -1,5 +1,3 @@ -import sys - ENDMARKER: int NAME: int NUMBER: int @@ -59,8 +57,7 @@ ATEQUAL: int AWAIT: int ASYNC: int ERRORTOKEN: int -if sys.version_info >= (3, 7): - COLONEQUAL: int +COLONEQUAL: int N_TOKENS: int NT_OFFSET: int tok_name: dict[int, str] diff --git a/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi b/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi index e9da31ed1a0a..c9ad1e7bb411 100644 --- a/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Callable, Iterable, Iterator from lib2to3.pgen2.token import * from typing_extensions import TypeAlias @@ -72,11 +71,9 @@ __all__ = [ "tokenize", "generate_tokens", "untokenize", + "COLONEQUAL", ] -if sys.version_info >= (3, 7): - __all__ += ["COLONEQUAL"] - _Coord: TypeAlias = tuple[int, int] _TokenEater: TypeAlias = Callable[[int, str, _Coord, _Coord, str], object] _TokenInfo: TypeAlias = tuple[int, str, _Coord, _Coord, str] diff --git a/mypy/typeshed/stdlib/lib2to3/pytree.pyi b/mypy/typeshed/stdlib/lib2to3/pytree.pyi index fa0cb9e34f75..208a87da8e4e 100644 --- a/mypy/typeshed/stdlib/lib2to3/pytree.pyi +++ b/mypy/typeshed/stdlib/lib2to3/pytree.pyi @@ -8,6 +8,8 @@ _NL: TypeAlias = Node | Leaf _Context: TypeAlias = tuple[str, int, int] _Results: TypeAlias = dict[str, _NL] _RawNode: TypeAlias = tuple[int, str, _Context, list[_NL] | None] +# This alias isn't used in this file, +# but is imported in other lib2to3 submodules _Convert: TypeAlias = Callable[[Grammar, _RawNode], Any] HUGE: int diff --git a/mypy/typeshed/stdlib/locale.pyi b/mypy/typeshed/stdlib/locale.pyi index 393ddcbda841..9a3ea65d1b8b 100644 --- a/mypy/typeshed/stdlib/locale.pyi +++ b/mypy/typeshed/stdlib/locale.pyi @@ -122,13 +122,7 @@ def resetlocale(category: int = ...) -> None: ... def strcoll(__os1: _str, __os2: _str) -> int: ... def strxfrm(__string: _str) -> _str: ... def format(percent: _str, value: float | Decimal, grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... - -if sys.version_info >= (3, 7): - def format_string(f: _str, val: Any, grouping: bool = ..., monetary: bool = ...) -> _str: ... - -else: - def format_string(f: _str, val: Any, grouping: bool = ...) -> _str: ... - +def format_string(f: _str, val: Any, grouping: bool = ..., monetary: bool = ...) -> _str: ... def currency(val: float | Decimal, symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ... def delocalize(string: _str) -> _str: ... def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... diff --git a/mypy/typeshed/stdlib/logging/__init__.pyi b/mypy/typeshed/stdlib/logging/__init__.pyi index 6a8f66871a67..0d3e80ddcf00 100644 --- a/mypy/typeshed/stdlib/logging/__init__.pyi +++ b/mypy/typeshed/stdlib/logging/__init__.pyi @@ -3,10 +3,11 @@ import threading from _typeshed import Self, StrPath, SupportsWrite from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from io import TextIOWrapper +from re import Pattern from string import Template from time import struct_time from types import FrameType, TracebackType -from typing import Any, ClassVar, Generic, Pattern, TextIO, TypeVar, Union, overload +from typing import Any, ClassVar, Generic, TextIO, TypeVar, Union, overload from typing_extensions import Literal, TypeAlias if sys.version_info >= (3, 11): @@ -708,12 +709,7 @@ else: fatal = critical -if sys.version_info >= (3, 7): - def disable(level: int = ...) -> None: ... - -else: - def disable(level: int) -> None: ... - +def disable(level: int = ...) -> None: ... def addLevelName(level: int, levelName: str) -> None: ... def getLevelName(level: _Level) -> Any: ... @@ -781,8 +777,7 @@ class StreamHandler(Handler, Generic[_StreamT]): def __init__(self: StreamHandler[TextIO], stream: None = ...) -> None: ... @overload def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ... - if sys.version_info >= (3, 7): - def setStream(self, stream: _StreamT) -> _StreamT | None: ... + def setStream(self, stream: _StreamT) -> _StreamT | None: ... if sys.version_info >= (3, 11): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/mypy/typeshed/stdlib/logging/config.pyi b/mypy/typeshed/stdlib/logging/config.pyi index 5993ba97df4b..12e222680d2e 100644 --- a/mypy/typeshed/stdlib/logging/config.pyi +++ b/mypy/typeshed/stdlib/logging/config.pyi @@ -1,10 +1,10 @@ import sys -from _typeshed import StrOrBytesPath, StrPath +from _typeshed import StrOrBytesPath from collections.abc import Callable, Sequence from configparser import RawConfigParser +from re import Pattern from threading import Thread -from typing import IO, Any, Pattern -from typing_extensions import TypeAlias +from typing import IO, Any from . import _Level @@ -13,11 +13,6 @@ if sys.version_info >= (3, 8): else: from typing_extensions import Literal, TypedDict -if sys.version_info >= (3, 7): - _Path: TypeAlias = StrOrBytesPath -else: - _Path: TypeAlias = StrPath - DEFAULT_LOGGING_CONFIG_PORT: int RESET_ERROR: int # undocumented IDENTIFIER: Pattern[str] # undocumented @@ -53,7 +48,7 @@ def dictConfig(config: _DictConfigArgs | dict[str, Any]) -> None: ... if sys.version_info >= (3, 10): def fileConfig( - fname: _Path | IO[str] | RawConfigParser, + fname: StrOrBytesPath | IO[str] | RawConfigParser, defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ..., encoding: str | None = ..., @@ -61,7 +56,9 @@ if sys.version_info >= (3, 10): else: def fileConfig( - fname: _Path | IO[str] | RawConfigParser, defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ... + fname: StrOrBytesPath | IO[str] | RawConfigParser, + defaults: dict[str, str] | None = ..., + disable_existing_loggers: bool = ..., ) -> None: ... def valid_ident(s: str) -> Literal[True]: ... # undocumented diff --git a/mypy/typeshed/stdlib/logging/handlers.pyi b/mypy/typeshed/stdlib/logging/handlers.pyi index d3ea29075b81..eec4ed96953a 100644 --- a/mypy/typeshed/stdlib/logging/handlers.pyi +++ b/mypy/typeshed/stdlib/logging/handlers.pyi @@ -5,13 +5,10 @@ import sys from _typeshed import StrPath from collections.abc import Callable from logging import FileHandler, Handler, LogRecord +from queue import Queue, SimpleQueue +from re import Pattern from socket import SocketKind, socket -from typing import Any, ClassVar, Pattern - -if sys.version_info >= (3, 7): - from queue import Queue, SimpleQueue -else: - from queue import Queue +from typing import Any, ClassVar DEFAULT_TCP_LOGGING_PORT: int DEFAULT_UDP_LOGGING_PORT: int @@ -251,28 +248,16 @@ class HTTPHandler(Handler): def getConnection(self, host: str, secure: bool) -> http.client.HTTPConnection: ... # undocumented class QueueHandler(Handler): - if sys.version_info >= (3, 7): - queue: SimpleQueue[Any] | Queue[Any] # undocumented - def __init__(self, queue: SimpleQueue[Any] | Queue[Any]) -> None: ... - else: - queue: Queue[Any] # undocumented - def __init__(self, queue: Queue[Any]) -> None: ... - + queue: SimpleQueue[Any] | Queue[Any] # undocumented + def __init__(self, queue: SimpleQueue[Any] | Queue[Any]) -> None: ... def prepare(self, record: LogRecord) -> Any: ... def enqueue(self, record: LogRecord) -> None: ... class QueueListener: handlers: tuple[Handler, ...] # undocumented respect_handler_level: bool # undocumented - if sys.version_info >= (3, 7): - queue: SimpleQueue[Any] | Queue[Any] # undocumented - def __init__( - self, queue: SimpleQueue[Any] | Queue[Any], *handlers: Handler, respect_handler_level: bool = ... - ) -> None: ... - else: - queue: Queue[Any] # undocumented - def __init__(self, queue: Queue[Any], *handlers: Handler, respect_handler_level: bool = ...) -> None: ... - + queue: SimpleQueue[Any] | Queue[Any] # undocumented + def __init__(self, queue: SimpleQueue[Any] | Queue[Any], *handlers: Handler, respect_handler_level: bool = ...) -> None: ... def dequeue(self, block: bool) -> LogRecord: ... def prepare(self, record: LogRecord) -> Any: ... def start(self) -> None: ... diff --git a/mypy/typeshed/stdlib/macurl2path.pyi b/mypy/typeshed/stdlib/macurl2path.pyi deleted file mode 100644 index af74b11c7850..000000000000 --- a/mypy/typeshed/stdlib/macurl2path.pyi +++ /dev/null @@ -1,5 +0,0 @@ -__all__ = ["url2pathname", "pathname2url"] - -def url2pathname(pathname: str) -> str: ... -def pathname2url(pathname: str) -> str: ... -def _pncomp2url(component: str | bytes) -> str: ... diff --git a/mypy/typeshed/stdlib/math.pyi b/mypy/typeshed/stdlib/math.pyi index ada510d629ed..58eda98d8977 100644 --- a/mypy/typeshed/stdlib/math.pyi +++ b/mypy/typeshed/stdlib/math.pyi @@ -113,10 +113,7 @@ if sys.version_info >= (3, 8): def prod(__iterable: Iterable[_SupportsFloatOrIndex], *, start: _SupportsFloatOrIndex = ...) -> float: ... def radians(__x: _SupportsFloatOrIndex) -> float: ... - -if sys.version_info >= (3, 7): - def remainder(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... - +def remainder(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ... def sin(__x: _SupportsFloatOrIndex) -> float: ... def sinh(__x: _SupportsFloatOrIndex) -> float: ... def sqrt(__x: _SupportsFloatOrIndex) -> float: ... diff --git a/mypy/typeshed/stdlib/msilib/__init__.pyi b/mypy/typeshed/stdlib/msilib/__init__.pyi index 968efbec7a6c..0e18350b226e 100644 --- a/mypy/typeshed/stdlib/msilib/__init__.pyi +++ b/mypy/typeshed/stdlib/msilib/__init__.pyi @@ -5,17 +5,10 @@ from typing import Any from typing_extensions import Literal if sys.platform == "win32": - from _msi import ( - CreateRecord as CreateRecord, - FCICreate as FCICreate, - OpenDatabase as OpenDatabase, - UuidCreate as UuidCreate, - _Database, - ) + from _msi import * + from _msi import _Database AMD64: bool - if sys.version_info < (3, 7): - Itanium: bool Win64: bool datasizemask: Literal[0x00FF] diff --git a/mypy/typeshed/stdlib/msvcrt.pyi b/mypy/typeshed/stdlib/msvcrt.pyi index 35841c62f67a..0bea8ce22b06 100644 --- a/mypy/typeshed/stdlib/msvcrt.pyi +++ b/mypy/typeshed/stdlib/msvcrt.pyi @@ -8,6 +8,10 @@ if sys.platform == "win32": LK_NBLCK: Literal[2] LK_RLCK: Literal[3] LK_NBRLCK: Literal[4] + SEM_FAILCRITICALERRORS: int + SEM_NOALIGNMENTFAULTEXCEPT: int + SEM_NOGPFAULTERRORBOX: int + SEM_NOOPENFILEERRORBOX: int def locking(__fd: int, __mode: int, __nbytes: int) -> None: ... def setmode(__fd: int, __mode: int) -> int: ... def open_osfhandle(__handle: int, __flags: int) -> int: ... diff --git a/mypy/typeshed/stdlib/multiprocessing/context.pyi b/mypy/typeshed/stdlib/multiprocessing/context.pyi index ed52325915c4..7215955da535 100644 --- a/mypy/typeshed/stdlib/multiprocessing/context.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/context.pyi @@ -76,20 +76,20 @@ class BaseContext: @overload def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[False]) -> _CT: ... @overload - def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[_CT]: ... + def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = ...) -> SynchronizedBase[_CT]: ... @overload - def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[Any]: ... + def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = ...) -> SynchronizedBase[Any]: ... @overload def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ... @overload def Array(self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ... @overload def Array( - self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike + self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = ... ) -> SynchronizedArray[_CT]: ... @overload def Array( - self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike + self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = ... ) -> SynchronizedArray[Any]: ... @overload def Array( diff --git a/mypy/typeshed/stdlib/multiprocessing/forkserver.pyi b/mypy/typeshed/stdlib/multiprocessing/forkserver.pyi new file mode 100644 index 000000000000..93777d926ca2 --- /dev/null +++ b/mypy/typeshed/stdlib/multiprocessing/forkserver.pyi @@ -0,0 +1,32 @@ +from _typeshed import FileDescriptorLike +from collections.abc import Sequence +from struct import Struct +from typing import Any + +__all__ = ["ensure_running", "get_inherited_fds", "connect_to_new_process", "set_forkserver_preload"] + +MAXFDS_TO_SEND: int +SIGNED_STRUCT: Struct + +class ForkServer: + def __init__(self) -> None: ... + def set_forkserver_preload(self, modules_names: list[str]) -> None: ... + def get_inherited_fds(self) -> list[int] | None: ... + def connect_to_new_process(self, fds: Sequence[int]) -> tuple[int, int]: ... + def ensure_running(self) -> None: ... + +def main( + listener_fd: int | None, + alive_r: FileDescriptorLike, + preload: Sequence[str], + main_path: str | None = ..., + sys_path: object | None = ..., +) -> None: ... +def read_signed(fd: int) -> Any: ... +def write_signed(fd: int, n: int) -> None: ... + +_forkserver: ForkServer = ... +ensure_running = _forkserver.ensure_running +get_inherited_fds = _forkserver.get_inherited_fds +connect_to_new_process = _forkserver.connect_to_new_process +set_forkserver_preload = _forkserver.set_forkserver_preload diff --git a/mypy/typeshed/stdlib/multiprocessing/managers.pyi b/mypy/typeshed/stdlib/multiprocessing/managers.pyi index 5537ea937bae..dfbcb395ef1a 100644 --- a/mypy/typeshed/stdlib/multiprocessing/managers.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/managers.pyi @@ -84,8 +84,6 @@ class DictProxy(BaseProxy, MutableMapping[_KT, _VT]): def keys(self) -> list[_KT]: ... # type: ignore[override] def values(self) -> list[tuple[_KT, _VT]]: ... # type: ignore[override] def items(self) -> list[_VT]: ... # type: ignore[override] - if sys.version_info < (3, 7): - def has_key(self, k: _KT) -> bool: ... class BaseListProxy(BaseProxy, MutableSequence[_T]): __builtins__: ClassVar[dict[str, Any]] diff --git a/mypy/typeshed/stdlib/multiprocessing/process.pyi b/mypy/typeshed/stdlib/multiprocessing/process.pyi index f903cef6fa72..7c8422e391c2 100644 --- a/mypy/typeshed/stdlib/multiprocessing/process.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/process.pyi @@ -25,10 +25,8 @@ class BaseProcess: def run(self) -> None: ... def start(self) -> None: ... def terminate(self) -> None: ... - if sys.version_info >= (3, 7): - def kill(self) -> None: ... - def close(self) -> None: ... - + def kill(self) -> None: ... + def close(self) -> None: ... def join(self, timeout: float | None = ...) -> None: ... def is_alive(self) -> bool: ... @property diff --git a/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi b/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi new file mode 100644 index 000000000000..98abb075fb3d --- /dev/null +++ b/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete, StrOrBytesPath +from collections.abc import Sized + +__all__ = ["ensure_running", "register", "unregister"] + +class ResourceTracker: + def __init__(self) -> None: ... + def getfd(self) -> int | None: ... + def ensure_running(self) -> None: ... + def register(self, name: Sized, rtype: Incomplete) -> None: ... + def unregister(self, name: Sized, rtype: Incomplete) -> None: ... + +_resource_tracker: ResourceTracker = ... +ensure_running = _resource_tracker.ensure_running +register = _resource_tracker.register +unregister = _resource_tracker.unregister +getfd = _resource_tracker.getfd + +def main(fd: StrOrBytesPath | int) -> None: ... diff --git a/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi b/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi index 8b1b1c1cee6e..e988cda322f4 100644 --- a/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi @@ -24,11 +24,11 @@ def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> def Value(typecode_or_type: type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ... @overload def Value( - typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... + typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = ..., ctx: BaseContext | None = ... ) -> SynchronizedBase[_CT]: ... @overload def Value( - typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... + typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = ..., ctx: BaseContext | None = ... ) -> SynchronizedBase[Any]: ... @overload def Value( @@ -43,7 +43,7 @@ def Array( typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, - lock: Literal[True] | _LockLike, + lock: Literal[True] | _LockLike = ..., ctx: BaseContext | None = ..., ) -> SynchronizedArray[_CT]: ... @overload @@ -51,7 +51,7 @@ def Array( typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, - lock: Literal[True] | _LockLike, + lock: Literal[True] | _LockLike = ..., ctx: BaseContext | None = ..., ) -> SynchronizedArray[Any]: ... @overload diff --git a/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi b/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi index 7a86935f7d18..c89142f2cd3b 100644 --- a/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi @@ -1,4 +1,3 @@ -import sys import threading from collections.abc import Callable from contextlib import AbstractContextManager @@ -20,11 +19,7 @@ class BoundedSemaphore(Semaphore): class Condition(AbstractContextManager[bool]): def __init__(self, lock: _LockLike | None = ..., *, ctx: BaseContext) -> None: ... - if sys.version_info >= (3, 7): - def notify(self, n: int = ...) -> None: ... - else: - def notify(self) -> None: ... - + def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def wait(self, timeout: float | None = ...) -> bool: ... def wait_for(self, predicate: Callable[[], bool], timeout: float | None = ...) -> bool: ... diff --git a/mypy/typeshed/stdlib/ntpath.pyi b/mypy/typeshed/stdlib/ntpath.pyi index 78aa2346835c..0cd3e446475b 100644 --- a/mypy/typeshed/stdlib/ntpath.pyi +++ b/mypy/typeshed/stdlib/ntpath.pyi @@ -86,11 +86,6 @@ __all__ = [ "commonpath", ] -if sys.version_info < (3, 7): - __all__ += ["splitunc"] - - def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated - altsep: LiteralString # First parameter is not actually pos-only, diff --git a/mypy/typeshed/stdlib/os/__init__.pyi b/mypy/typeshed/stdlib/os/__init__.pyi index 68c7634272e3..e3d428555462 100644 --- a/mypy/typeshed/stdlib/os/__init__.pyi +++ b/mypy/typeshed/stdlib/os/__init__.pyi @@ -388,13 +388,8 @@ class DirEntry(Generic[AnyStr]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -if sys.version_info >= (3, 7): - _StatVfsTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int, int] -else: - _StatVfsTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int] - @final -class statvfs_result(structseq[int], _StatVfsTuple): +class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int, int]): if sys.version_info >= (3, 10): __match_args__: Final = ( "f_bsize", @@ -428,9 +423,8 @@ class statvfs_result(structseq[int], _StatVfsTuple): def f_flag(self) -> int: ... @property def f_namemax(self) -> int: ... - if sys.version_info >= (3, 7): - @property - def f_fsid(self) -> int: ... + @property + def f_fsid(self) -> int: ... # ----- os function stubs ----- def fsencode(filename: StrOrBytesPath) -> bytes: ... @@ -595,13 +589,7 @@ def close(fd: int) -> None: ... def closerange(__fd_low: int, __fd_high: int) -> None: ... def device_encoding(fd: int) -> str | None: ... def dup(__fd: int) -> int: ... - -if sys.version_info >= (3, 7): - def dup2(fd: int, fd2: int, inheritable: bool = ...) -> int: ... - -else: - def dup2(fd: int, fd2: int, inheritable: bool = ...) -> None: ... - +def dup2(fd: int, fd2: int, inheritable: bool = ...) -> int: ... def fstat(fd: int) -> stat_result: ... def ftruncate(__fd: int, __length: int) -> None: ... def fsync(fd: FileDescriptorLike) -> None: ... @@ -628,21 +616,20 @@ if sys.platform != "win32": if sys.platform != "darwin": def fdatasync(fd: FileDescriptorLike) -> None: ... def pipe2(__flags: int) -> tuple[int, int]: ... # some flavors of Unix - def posix_fallocate(fd: int, offset: int, length: int) -> None: ... - def posix_fadvise(fd: int, offset: int, length: int, advice: int) -> None: ... + def posix_fallocate(__fd: int, __offset: int, __length: int) -> None: ... + def posix_fadvise(__fd: int, __offset: int, __length: int, __advice: int) -> None: ... def pread(__fd: int, __length: int, __offset: int) -> bytes: ... def pwrite(__fd: int, __buffer: bytes, __offset: int) -> int: ... if sys.platform != "darwin": if sys.version_info >= (3, 10): RWF_APPEND: int # docs say available on 3.7+, stubtest says otherwise - if sys.version_info >= (3, 7): - def preadv(__fd: int, __buffers: Iterable[bytes], __offset: int, __flags: int = ...) -> int: ... - def pwritev(__fd: int, __buffers: Iterable[bytes], __offset: int, __flags: int = ...) -> int: ... - RWF_DSYNC: int - RWF_SYNC: int - RWF_HIPRI: int - RWF_NOWAIT: int + def preadv(__fd: int, __buffers: Iterable[bytes], __offset: int, __flags: int = ...) -> int: ... + def pwritev(__fd: int, __buffers: Iterable[bytes], __offset: int, __flags: int = ...) -> int: ... + RWF_DSYNC: int + RWF_SYNC: int + RWF_HIPRI: int + RWF_NOWAIT: int @overload def sendfile(out_fd: int, in_fd: int, offset: int | None, count: int) -> int: ... @overload @@ -667,7 +654,7 @@ class terminal_size(structseq[int], tuple[int, int]): @property def lines(self) -> int: ... -def get_terminal_size(fd: int = ...) -> terminal_size: ... +def get_terminal_size(__fd: int = ...) -> terminal_size: ... def get_inheritable(__fd: int) -> bool: ... def set_inheritable(__fd: int, __inheritable: bool) -> None: ... @@ -742,21 +729,12 @@ class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_Scand @overload def scandir(path: None = ...) -> _ScandirIterator[str]: ... - -if sys.version_info >= (3, 7): - @overload - def scandir(path: int) -> _ScandirIterator[str]: ... - +@overload +def scandir(path: int) -> _ScandirIterator[str]: ... @overload def scandir(path: GenericPath[AnyStr]) -> _ScandirIterator[AnyStr]: ... def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ... -if sys.version_info < (3, 7): - @overload - def stat_float_times() -> bool: ... - @overload - def stat_float_times(__newvalue: bool) -> None: ... - if sys.platform != "win32": def statvfs(path: _FdOrAnyPath) -> statvfs_result: ... # Unix only @@ -776,41 +754,26 @@ def utime( follow_symlinks: bool = ..., ) -> None: ... -_OnError: TypeAlias = Callable[[OSError], Any] +_OnError: TypeAlias = Callable[[OSError], object] def walk( top: GenericPath[AnyStr], topdown: bool = ..., onerror: _OnError | None = ..., followlinks: bool = ... ) -> Iterator[tuple[AnyStr, list[AnyStr], list[AnyStr]]]: ... if sys.platform != "win32": - if sys.version_info >= (3, 7): - @overload - def fwalk( - top: StrPath = ..., - topdown: bool = ..., - onerror: _OnError | None = ..., - *, - follow_symlinks: bool = ..., - dir_fd: int | None = ..., - ) -> Iterator[tuple[str, list[str], list[str], int]]: ... - @overload - def fwalk( - top: bytes, - topdown: bool = ..., - onerror: _OnError | None = ..., - *, - follow_symlinks: bool = ..., - dir_fd: int | None = ..., - ) -> Iterator[tuple[bytes, list[bytes], list[bytes], int]]: ... - else: - def fwalk( - top: StrPath = ..., - topdown: bool = ..., - onerror: _OnError | None = ..., - *, - follow_symlinks: bool = ..., - dir_fd: int | None = ..., - ) -> Iterator[tuple[str, list[str], list[str], int]]: ... + @overload + def fwalk( + top: StrPath = ..., + topdown: bool = ..., + onerror: _OnError | None = ..., + *, + follow_symlinks: bool = ..., + dir_fd: int | None = ..., + ) -> Iterator[tuple[str, list[str], list[str], int]]: ... + @overload + def fwalk( + top: bytes, topdown: bool = ..., onerror: _OnError | None = ..., *, follow_symlinks: bool = ..., dir_fd: int | None = ... + ) -> Iterator[tuple[bytes, list[bytes], list[bytes], int]]: ... if sys.platform == "linux": def getxattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> bytes: ... def listxattr(path: _FdOrAnyPath | None = ..., *, follow_symlinks: bool = ...) -> list[str]: ... @@ -860,7 +823,7 @@ if sys.platform != "win32": def killpg(__pgid: int, __signal: int) -> None: ... def nice(__increment: int) -> int: ... if sys.platform != "darwin": - def plock(op: int) -> None: ... # ???op is int? + def plock(__op: int) -> None: ... # ???op is int? class _wrap_close(_TextIOWrapper): def __init__(self, stream: _TextIOWrapper, proc: Popen[str]) -> None: ... @@ -922,7 +885,7 @@ else: @property def si_code(self) -> int: ... - def waitid(idtype: int, ident: int, options: int) -> waitid_result: ... + def waitid(__idtype: int, __ident: int, __options: int) -> waitid_result: ... def wait3(options: int) -> tuple[int, int, Any]: ... def wait4(pid: int, options: int) -> tuple[int, int, Any]: ... @@ -978,13 +941,13 @@ if sys.platform != "win32": def sched_get_priority_max(policy: int) -> int: ... # some flavors of Unix def sched_yield() -> None: ... # some flavors of Unix if sys.platform != "darwin": - def sched_setscheduler(pid: int, policy: int, param: sched_param) -> None: ... # some flavors of Unix - def sched_getscheduler(pid: int) -> int: ... # some flavors of Unix - def sched_rr_get_interval(pid: int) -> float: ... # some flavors of Unix - def sched_setparam(pid: int, param: sched_param) -> None: ... # some flavors of Unix - def sched_getparam(pid: int) -> sched_param: ... # some flavors of Unix - def sched_setaffinity(pid: int, mask: Iterable[int]) -> None: ... # some flavors of Unix - def sched_getaffinity(pid: int) -> set[int]: ... # some flavors of Unix + def sched_setscheduler(__pid: int, __policy: int, __param: sched_param) -> None: ... # some flavors of Unix + def sched_getscheduler(__pid: int) -> int: ... # some flavors of Unix + def sched_rr_get_interval(__pid: int) -> float: ... # some flavors of Unix + def sched_setparam(__pid: int, __param: sched_param) -> None: ... # some flavors of Unix + def sched_getparam(__pid: int) -> sched_param: ... # some flavors of Unix + def sched_setaffinity(__pid: int, __mask: Iterable[int]) -> None: ... # some flavors of Unix + def sched_getaffinity(__pid: int) -> set[int]: ... # some flavors of Unix def cpu_count() -> int | None: ... @@ -999,7 +962,7 @@ if sys.platform == "linux": def urandom(__size: int) -> bytes: ... -if sys.version_info >= (3, 7) and sys.platform != "win32": +if sys.platform != "win32": def register_at_fork( *, before: Callable[..., Any] | None = ..., @@ -1011,7 +974,7 @@ if sys.version_info >= (3, 8): if sys.platform == "win32": class _AddedDllDirectory: path: str | None - def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ... + def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], object]) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, *args: object) -> None: ... diff --git a/mypy/typeshed/stdlib/pathlib.pyi b/mypy/typeshed/stdlib/pathlib.pyi index 65aead6cb4de..05ad3c55086b 100644 --- a/mypy/typeshed/stdlib/pathlib.pyi +++ b/mypy/typeshed/stdlib/pathlib.pyi @@ -159,8 +159,7 @@ class Path(PurePath): # so it's safer to pretend they don't exist def owner(self) -> str: ... def group(self) -> str: ... - if sys.version_info >= (3, 7): - def is_mount(self) -> bool: ... + def is_mount(self) -> bool: ... if sys.version_info >= (3, 9): def readlink(self: Self) -> Self: ... diff --git a/mypy/typeshed/stdlib/pdb.pyi b/mypy/typeshed/stdlib/pdb.pyi index 3c2cabe8abe2..6e95dcff6ee2 100644 --- a/mypy/typeshed/stdlib/pdb.pyi +++ b/mypy/typeshed/stdlib/pdb.pyi @@ -22,13 +22,7 @@ def run(statement: str, globals: dict[str, Any] | None = ..., locals: Mapping[st def runeval(expression: str, globals: dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> Any: ... def runctx(statement: str, globals: dict[str, Any], locals: Mapping[str, Any]) -> None: ... def runcall(func: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> _T | None: ... - -if sys.version_info >= (3, 7): - def set_trace(*, header: str | None = ...) -> None: ... - -else: - def set_trace() -> None: ... - +def set_trace(*, header: str | None = ...) -> None: ... def post_mortem(t: TracebackType | None = ...) -> None: ... def pm() -> None: ... @@ -167,7 +161,7 @@ class Pdb(Bdb, Cmd): complete_whatis = _complete_expression complete_display = _complete_expression - if sys.version_info >= (3, 7) and sys.version_info < (3, 11): + if sys.version_info < (3, 11): def _runmodule(self, module_name: str) -> None: ... # undocumented diff --git a/mypy/typeshed/stdlib/plistlib.pyi b/mypy/typeshed/stdlib/plistlib.pyi index de5fe1b75ca0..89acc5b53851 100644 --- a/mypy/typeshed/stdlib/plistlib.pyi +++ b/mypy/typeshed/stdlib/plistlib.pyi @@ -23,30 +23,13 @@ elif sys.version_info >= (3, 8): "dumps", "UID", ] -elif sys.version_info >= (3, 7): - __all__ = [ - "readPlist", - "writePlist", - "readPlistFromBytes", - "writePlistToBytes", - "Data", - "InvalidFileException", - "FMT_XML", - "FMT_BINARY", - "load", - "dump", - "loads", - "dumps", - ] else: __all__ = [ "readPlist", "writePlist", "readPlistFromBytes", "writePlistToBytes", - "Plist", "Data", - "Dict", "InvalidFileException", "FMT_XML", "FMT_BINARY", @@ -105,21 +88,6 @@ if sys.version_info < (3, 9): def readPlistFromBytes(data: bytes) -> Any: ... def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... -if sys.version_info < (3, 7): - class _InternalDict(dict[str, Any]): - def __getattr__(self, attr: str) -> Any: ... - def __setattr__(self, attr: str, value: Any) -> None: ... - def __delattr__(self, attr: str) -> None: ... - - class Dict(_InternalDict): # deprecated - def __init__(self, **kwargs: Any) -> None: ... - - class Plist(_InternalDict): # deprecated - def __init__(self, **kwargs: Any) -> None: ... - @classmethod - def fromFile(cls: type[Self], pathOrFile: str | IO[bytes]) -> Self: ... - def write(self, pathOrFile: str | IO[bytes]) -> None: ... - if sys.version_info < (3, 9): class Data: data: bytes diff --git a/mypy/typeshed/stdlib/poplib.pyi b/mypy/typeshed/stdlib/poplib.pyi index 487a7266694c..fd7afedaad05 100644 --- a/mypy/typeshed/stdlib/poplib.pyi +++ b/mypy/typeshed/stdlib/poplib.pyi @@ -1,7 +1,8 @@ import socket import ssl from builtins import list as _list # conflicts with a method named "list" -from typing import Any, BinaryIO, NoReturn, Pattern, overload +from re import Pattern +from typing import Any, BinaryIO, NoReturn, overload from typing_extensions import Literal, TypeAlias __all__ = ["POP3", "error_proto", "POP3_SSL"] diff --git a/mypy/typeshed/stdlib/posix.pyi b/mypy/typeshed/stdlib/posix.pyi index e248db397ab8..7055f15f3d67 100644 --- a/mypy/typeshed/stdlib/posix.pyi +++ b/mypy/typeshed/stdlib/posix.pyi @@ -309,18 +309,17 @@ if sys.platform != "win32": copy_file_range as copy_file_range, memfd_create as memfd_create, ) - if sys.version_info >= (3, 7): - from os import register_at_fork as register_at_fork + from os import register_at_fork as register_at_fork - if sys.platform != "darwin": - from os import ( - RWF_DSYNC as RWF_DSYNC, - RWF_HIPRI as RWF_HIPRI, - RWF_NOWAIT as RWF_NOWAIT, - RWF_SYNC as RWF_SYNC, - preadv as preadv, - pwritev as pwritev, - ) + if sys.platform != "darwin": + from os import ( + RWF_DSYNC as RWF_DSYNC, + RWF_HIPRI as RWF_HIPRI, + RWF_NOWAIT as RWF_NOWAIT, + RWF_SYNC as RWF_SYNC, + preadv as preadv, + pwritev as pwritev, + ) # Not same as os.environ or os.environb # Because of this variable, we can't do "from posix import *" in os/__init__.pyi diff --git a/mypy/typeshed/stdlib/pstats.pyi b/mypy/typeshed/stdlib/pstats.pyi index 7868512e5ab9..7629cd63438f 100644 --- a/mypy/typeshed/stdlib/pstats.pyi +++ b/mypy/typeshed/stdlib/pstats.pyi @@ -2,32 +2,28 @@ import sys from _typeshed import Self, StrOrBytesPath from collections.abc import Iterable from cProfile import Profile as _cProfile +from enum import Enum from profile import Profile from typing import IO, Any, overload from typing_extensions import Literal, TypeAlias if sys.version_info >= (3, 9): __all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"] -elif sys.version_info >= (3, 7): - __all__ = ["Stats", "SortKey"] else: - __all__ = ["Stats"] + __all__ = ["Stats", "SortKey"] _Selector: TypeAlias = str | float | int -if sys.version_info >= (3, 7): - from enum import Enum - - class SortKey(str, Enum): - CALLS: str - CUMULATIVE: str - FILENAME: str - LINE: str - NAME: str - NFL: str - PCALLS: str - STDNAME: str - TIME: str +class SortKey(str, Enum): + CALLS: str + CUMULATIVE: str + FILENAME: str + LINE: str + NAME: str + NFL: str + PCALLS: str + STDNAME: str + TIME: str if sys.version_info >= (3, 9): from dataclasses import dataclass diff --git a/mypy/typeshed/stdlib/py_compile.pyi b/mypy/typeshed/stdlib/py_compile.pyi index c544a7941981..1e9b6c2cb209 100644 --- a/mypy/typeshed/stdlib/py_compile.pyi +++ b/mypy/typeshed/stdlib/py_compile.pyi @@ -1,10 +1,8 @@ +import enum import sys from typing import AnyStr -if sys.version_info >= (3, 7): - __all__ = ["compile", "main", "PyCompileError", "PycInvalidationMode"] -else: - __all__ = ["compile", "main", "PyCompileError"] +__all__ = ["compile", "main", "PyCompileError", "PycInvalidationMode"] class PyCompileError(Exception): exc_type_name: str @@ -13,14 +11,12 @@ class PyCompileError(Exception): msg: str def __init__(self, exc_type: type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... -if sys.version_info >= (3, 7): - import enum +class PycInvalidationMode(enum.Enum): + TIMESTAMP: int + CHECKED_HASH: int + UNCHECKED_HASH: int - class PycInvalidationMode(enum.Enum): - TIMESTAMP: int - CHECKED_HASH: int - UNCHECKED_HASH: int - def _get_default_invalidation_mode() -> PycInvalidationMode: ... +def _get_default_invalidation_mode() -> PycInvalidationMode: ... if sys.version_info >= (3, 8): def compile( @@ -33,7 +29,7 @@ if sys.version_info >= (3, 8): quiet: int = ..., ) -> AnyStr | None: ... -elif sys.version_info >= (3, 7): +else: def compile( file: AnyStr, cfile: AnyStr | None = ..., @@ -43,11 +39,6 @@ elif sys.version_info >= (3, 7): invalidation_mode: PycInvalidationMode | None = ..., ) -> AnyStr | None: ... -else: - def compile( - file: AnyStr, cfile: AnyStr | None = ..., dfile: AnyStr | None = ..., doraise: bool = ..., optimize: int = ... - ) -> AnyStr | None: ... - if sys.version_info >= (3, 10): def main() -> None: ... diff --git a/mypy/typeshed/stdlib/pyclbr.pyi b/mypy/typeshed/stdlib/pyclbr.pyi index 3033833a8162..ab19b44d7d79 100644 --- a/mypy/typeshed/stdlib/pyclbr.pyi +++ b/mypy/typeshed/stdlib/pyclbr.pyi @@ -14,9 +14,8 @@ class Class: if sys.version_info >= (3, 10): end_lineno: int | None - if sys.version_info >= (3, 7): - parent: Class | None - children: dict[str, Class | Function] + parent: Class | None + children: dict[str, Class | Function] if sys.version_info >= (3, 10): def __init__( @@ -30,12 +29,10 @@ class Class: *, end_lineno: int | None = ..., ) -> None: ... - elif sys.version_info >= (3, 7): + else: def __init__( self, module: str, name: str, super: list[Class | str] | None, file: str, lineno: int, parent: Class | None = ... ) -> None: ... - else: - def __init__(self, module: str, name: str, super: list[Class | str] | None, file: str, lineno: int) -> None: ... class Function: module: str @@ -47,9 +44,8 @@ class Function: end_lineno: int | None is_async: bool - if sys.version_info >= (3, 7): - parent: Function | Class | None - children: dict[str, Class | Function] + parent: Function | Class | None + children: dict[str, Class | Function] if sys.version_info >= (3, 10): def __init__( @@ -63,10 +59,8 @@ class Function: *, end_lineno: int | None = ..., ) -> None: ... - elif sys.version_info >= (3, 7): - def __init__(self, module: str, name: str, file: str, lineno: int, parent: Function | Class | None = ...) -> None: ... else: - def __init__(self, module: str, name: str, file: str, lineno: int) -> None: ... + def __init__(self, module: str, name: str, file: str, lineno: int, parent: Function | Class | None = ...) -> None: ... def readmodule(module: str, path: Sequence[str] | None = ...) -> dict[str, Class]: ... def readmodule_ex(module: str, path: Sequence[str] | None = ...) -> dict[str, Class | Function | list[str]]: ... diff --git a/mypy/typeshed/stdlib/queue.pyi b/mypy/typeshed/stdlib/queue.pyi index 532d5d98344d..7ea4beb664c5 100644 --- a/mypy/typeshed/stdlib/queue.pyi +++ b/mypy/typeshed/stdlib/queue.pyi @@ -5,10 +5,7 @@ from typing import Any, Generic, TypeVar if sys.version_info >= (3, 9): from types import GenericAlias -if sys.version_info >= (3, 7): - __all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue", "SimpleQueue"] -else: - __all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue"] +__all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue", "SimpleQueue"] _T = TypeVar("_T") @@ -49,14 +46,13 @@ class PriorityQueue(Queue[_T]): class LifoQueue(Queue[_T]): queue: list[_T] -if sys.version_info >= (3, 7): - class SimpleQueue(Generic[_T]): - def __init__(self) -> None: ... - def empty(self) -> bool: ... - def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... - def get_nowait(self) -> _T: ... - def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ... - def put_nowait(self, item: _T) -> None: ... - def qsize(self) -> int: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... +class SimpleQueue(Generic[_T]): + def __init__(self) -> None: ... + def empty(self) -> bool: ... + def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... + def get_nowait(self) -> _T: ... + def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ... + def put_nowait(self, item: _T) -> None: ... + def qsize(self) -> int: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/mypy/typeshed/stdlib/re.pyi b/mypy/typeshed/stdlib/re.pyi index bdabf32d895e..17b2ec011168 100644 --- a/mypy/typeshed/stdlib/re.pyi +++ b/mypy/typeshed/stdlib/re.pyi @@ -4,15 +4,9 @@ import sys from _typeshed import ReadableBuffer from collections.abc import Callable, Iterator from sre_constants import error as error -from typing import Any, AnyStr, overload +from typing import Any, AnyStr, Match as Match, Pattern as Pattern, overload from typing_extensions import TypeAlias -# ----- re variables and constants ----- -if sys.version_info >= (3, 7): - from typing import Match as Match, Pattern as Pattern -else: - from typing import Match, Pattern - __all__ = [ "match", "fullmatch", @@ -41,14 +35,15 @@ __all__ = [ "DOTALL", "VERBOSE", "UNICODE", + "Match", + "Pattern", ] -if sys.version_info >= (3, 7): - __all__ += ["Match", "Pattern"] - if sys.version_info >= (3, 11): __all__ += ["NOFLAG", "RegexFlag"] +# ----- re variables and constants ----- + class RegexFlag(enum.IntFlag): A = sre_compile.SRE_FLAG_ASCII ASCII = A @@ -91,10 +86,6 @@ if sys.version_info >= (3, 11): NOFLAG = RegexFlag.NOFLAG _FlagsType: TypeAlias = int | RegexFlag -if sys.version_info < (3, 7): - # undocumented - _pattern_type: type - # Type-wise the compile() overloads are unnecessary, they could also be modeled using # unions in the parameter types. However mypy has a bug regarding TypeVar # constraints (https://github.com/python/mypy/issues/11880), diff --git a/mypy/typeshed/stdlib/sched.pyi b/mypy/typeshed/stdlib/sched.pyi index 709d6f47ff65..29c84f951124 100644 --- a/mypy/typeshed/stdlib/sched.pyi +++ b/mypy/typeshed/stdlib/sched.pyi @@ -1,15 +1,18 @@ import sys from collections.abc import Callable from typing import Any, NamedTuple +from typing_extensions import TypeAlias __all__ = ["scheduler"] +_ActionCallback: TypeAlias = Callable[..., Any] + if sys.version_info >= (3, 10): class Event(NamedTuple): time: float priority: Any sequence: int - action: Callable[..., Any] + action: _ActionCallback argument: tuple[Any, ...] kwargs: dict[str, Any] @@ -17,7 +20,7 @@ else: class Event(NamedTuple): time: float priority: Any - action: Callable[..., Any] + action: _ActionCallback argument: tuple[Any, ...] kwargs: dict[str, Any] @@ -27,20 +30,10 @@ class scheduler: def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], object] = ...) -> None: ... def enterabs( - self, - time: float, - priority: Any, - action: Callable[..., Any], - argument: tuple[Any, ...] = ..., - kwargs: dict[str, Any] = ..., + self, time: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ... ) -> Event: ... def enter( - self, - delay: float, - priority: Any, - action: Callable[..., Any], - argument: tuple[Any, ...] = ..., - kwargs: dict[str, Any] = ..., + self, delay: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ... ) -> Event: ... def run(self, blocking: bool = ...) -> float | None: ... def cancel(self, event: Event) -> None: ... diff --git a/mypy/typeshed/stdlib/shlex.pyi b/mypy/typeshed/stdlib/shlex.pyi index fe0f80ba26c1..f9d660594a5a 100644 --- a/mypy/typeshed/stdlib/shlex.pyi +++ b/mypy/typeshed/stdlib/shlex.pyi @@ -30,11 +30,8 @@ class shlex(Iterable[str]): lineno: int token: str eof: str - if sys.version_info >= (3, 7): - @property - def punctuation_chars(self) -> str: ... - else: - punctuation_chars: str + @property + def punctuation_chars(self) -> str: ... def __init__( self, instream: str | TextIO | None = ..., diff --git a/mypy/typeshed/stdlib/shutil.pyi b/mypy/typeshed/stdlib/shutil.pyi index b6d0b9dbf7f3..13c706de1cf4 100644 --- a/mypy/typeshed/stdlib/shutil.pyi +++ b/mypy/typeshed/stdlib/shutil.pyi @@ -82,17 +82,15 @@ else: ignore_dangling_symlinks: bool = ..., ) -> _PathReturn: ... +_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], Any, Any], object] + if sys.version_info >= (3, 11): def rmtree( - path: StrOrBytesPath, - ignore_errors: bool = ..., - onerror: Callable[[Any, Any, Any], Any] | None = ..., - *, - dir_fd: int | None = ..., + path: StrOrBytesPath, ignore_errors: bool = ..., onerror: _OnErrorCallback | None = ..., *, dir_fd: int | None = ... ) -> None: ... else: - def rmtree(path: StrOrBytesPath, ignore_errors: bool = ..., onerror: Callable[[Any, Any, Any], Any] | None = ...) -> None: ... + def rmtree(path: StrOrBytesPath, ignore_errors: bool = ..., onerror: _OnErrorCallback | None = ...) -> None: ... _CopyFn: TypeAlias = Callable[[str, str], object] | Callable[[StrPath, StrPath], object] @@ -155,14 +153,7 @@ def register_archive_format( name: str, function: Callable[[str, str], object], extra_args: None = ..., description: str = ... ) -> None: ... def unregister_archive_format(name: str) -> None: ... - -if sys.version_info >= (3, 7): - def unpack_archive(filename: StrPath, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ... - -else: - # See http://bugs.python.org/issue30218 - def unpack_archive(filename: str, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ... - +def unpack_archive(filename: StrPath, extract_dir: StrPath | None = ..., format: str | None = ...) -> None: ... @overload def register_unpack_format( name: str, diff --git a/mypy/typeshed/stdlib/signal.pyi b/mypy/typeshed/stdlib/signal.pyi index a9d6ca28f8d7..8e9bd990a2c2 100644 --- a/mypy/typeshed/stdlib/signal.pyi +++ b/mypy/typeshed/stdlib/signal.pyi @@ -174,11 +174,7 @@ if sys.version_info >= (3, 8): def valid_signals() -> set[Signals]: ... def raise_signal(__signalnum: _SIGNUM) -> None: ... -if sys.version_info >= (3, 7): - def set_wakeup_fd(fd: int, *, warn_on_full_buffer: bool = ...) -> int: ... - -else: - def set_wakeup_fd(fd: int) -> int: ... +def set_wakeup_fd(fd: int, *, warn_on_full_buffer: bool = ...) -> int: ... if sys.version_info >= (3, 9): if sys.platform == "linux": diff --git a/mypy/typeshed/stdlib/smtplib.pyi b/mypy/typeshed/stdlib/smtplib.pyi index 65a85627b642..c42841c43e7f 100644 --- a/mypy/typeshed/stdlib/smtplib.pyi +++ b/mypy/typeshed/stdlib/smtplib.pyi @@ -2,10 +2,11 @@ import sys from _typeshed import Self from collections.abc import Sequence from email.message import Message as _Message +from re import Pattern from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Pattern, Protocol, overload +from typing import Any, Protocol, overload from typing_extensions import TypeAlias __all__ = [ @@ -22,11 +23,9 @@ __all__ = [ "quotedata", "SMTP", "SMTP_SSL", + "SMTPNotSupportedError", ] -if sys.version_info >= (3, 7): - __all__ += ["SMTPNotSupportedError"] - _Reply: TypeAlias = tuple[int, bytes] _SendErrs: TypeAlias = dict[str, _Reply] # Should match source_address for socket.create_connection diff --git a/mypy/typeshed/stdlib/socket.pyi b/mypy/typeshed/stdlib/socket.pyi index 0b06e888aeb6..a0f5708bf806 100644 --- a/mypy/typeshed/stdlib/socket.pyi +++ b/mypy/typeshed/stdlib/socket.pyi @@ -138,14 +138,10 @@ if sys.version_info >= (3, 10): elif sys.platform != "darwin" and sys.platform != "win32": from _socket import IP_RECVTOS as IP_RECVTOS -if sys.version_info >= (3, 7): - from _socket import close as close +from _socket import TCP_KEEPINTVL as TCP_KEEPINTVL, close as close -if sys.platform != "win32" or sys.version_info >= (3, 7): - from _socket import TCP_KEEPINTVL as TCP_KEEPINTVL - - if sys.platform != "darwin": - from _socket import TCP_KEEPIDLE as TCP_KEEPIDLE +if sys.platform != "darwin": + from _socket import TCP_KEEPIDLE as TCP_KEEPIDLE if sys.platform != "win32" or sys.version_info >= (3, 8): from _socket import ( @@ -358,7 +354,7 @@ if sys.platform == "linux": TIPC_WITHDRAWN as TIPC_WITHDRAWN, TIPC_ZONE_SCOPE as TIPC_ZONE_SCOPE, ) -if sys.platform == "linux" and sys.version_info >= (3, 7): +if sys.platform == "linux": from _socket import ( CAN_ISOTP as CAN_ISOTP, IOCTL_VM_SOCKETS_GET_LOCAL_CID as IOCTL_VM_SOCKETS_GET_LOCAL_CID, @@ -370,7 +366,7 @@ if sys.platform == "linux" and sys.version_info >= (3, 7): VMADDR_CID_HOST as VMADDR_CID_HOST, VMADDR_PORT_ANY as VMADDR_PORT_ANY, ) -if sys.platform != "win32" and sys.version_info >= (3, 7): +if sys.platform != "win32": from _socket import TCP_NOTSENT_LOWAT as TCP_NOTSENT_LOWAT if sys.platform == "linux" and sys.version_info >= (3, 8): from _socket import ( @@ -473,8 +469,7 @@ class AddressFamily(IntEnum): AF_TIPC: int AF_ALG: int AF_NETLINK: int - if sys.version_info >= (3, 7): - AF_VSOCK: int + AF_VSOCK: int if sys.version_info >= (3, 8): AF_QIPCRTR: int if sys.platform != "win32" or sys.version_info >= (3, 9): @@ -523,8 +518,7 @@ if sys.platform == "linux": AF_TIPC = AddressFamily.AF_TIPC AF_ALG = AddressFamily.AF_ALG AF_NETLINK = AddressFamily.AF_NETLINK - if sys.version_info >= (3, 7): - AF_VSOCK = AddressFamily.AF_VSOCK + AF_VSOCK = AddressFamily.AF_VSOCK if sys.version_info >= (3, 8): AF_QIPCRTR = AddressFamily.AF_QIPCRTR @@ -563,9 +557,7 @@ class MsgFlag(IntFlag): if sys.platform != "darwin": MSG_BCAST: int MSG_MCAST: int - - if sys.platform != "win32" or sys.version_info >= (3, 7): - MSG_ERRQUEUE: int + MSG_ERRQUEUE: int if sys.platform != "win32" and sys.platform != "darwin": MSG_BTAG: int @@ -592,9 +584,7 @@ MSG_WAITALL = MsgFlag.MSG_WAITALL if sys.platform != "darwin": MSG_BCAST = MsgFlag.MSG_BCAST MSG_MCAST = MsgFlag.MSG_MCAST - - if sys.platform != "win32" or sys.version_info >= (3, 7): - MSG_ERRQUEUE = MsgFlag.MSG_ERRQUEUE + MSG_ERRQUEUE = MsgFlag.MSG_ERRQUEUE if sys.platform != "win32": MSG_DONTWAIT = MsgFlag.MSG_DONTWAIT diff --git a/mypy/typeshed/stdlib/socketserver.pyi b/mypy/typeshed/stdlib/socketserver.pyi index 8e2a24e7edfd..f1d127ebe6a1 100644 --- a/mypy/typeshed/stdlib/socketserver.pyi +++ b/mypy/typeshed/stdlib/socketserver.pyi @@ -108,8 +108,7 @@ if sys.platform != "win32": timeout: float | None # undocumented active_children: set[int] | None # undocumented max_children: int # undocumented - if sys.version_info >= (3, 7): - block_on_close: bool + block_on_close: bool def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented def handle_timeout(self) -> None: ... # undocumented def service_actions(self) -> None: ... # undocumented @@ -118,8 +117,7 @@ if sys.platform != "win32": class ThreadingMixIn: daemon_threads: bool - if sys.version_info >= (3, 7): - block_on_close: bool + block_on_close: bool def process_request_thread(self, request: _RequestType, client_address: _AddressType) -> None: ... # undocumented def process_request(self, request: _RequestType, client_address: _AddressType) -> None: ... def server_close(self) -> None: ... @@ -155,7 +153,7 @@ class StreamRequestHandler(BaseRequestHandler): wbufsize: ClassVar[int] # undocumented timeout: ClassVar[float | None] # undocumented disable_nagle_algorithm: ClassVar[bool] # undocumented - connection: _socket # undocumented + connection: Any # undocumented rfile: BinaryIO wfile: BinaryIO diff --git a/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi b/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi index 3e98908db354..44595d5ae556 100644 --- a/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi +++ b/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi @@ -48,13 +48,11 @@ SQLITE_CREATE_TEMP_TRIGGER: int SQLITE_CREATE_TEMP_VIEW: int SQLITE_CREATE_TRIGGER: int SQLITE_CREATE_VIEW: int -if sys.version_info >= (3, 7): - SQLITE_CREATE_VTABLE: int +SQLITE_CREATE_VTABLE: int SQLITE_DELETE: int SQLITE_DENY: int SQLITE_DETACH: int -if sys.version_info >= (3, 7): - SQLITE_DONE: int +SQLITE_DONE: int SQLITE_DROP_INDEX: int SQLITE_DROP_TABLE: int SQLITE_DROP_TEMP_INDEX: int @@ -63,9 +61,8 @@ SQLITE_DROP_TEMP_TRIGGER: int SQLITE_DROP_TEMP_VIEW: int SQLITE_DROP_TRIGGER: int SQLITE_DROP_VIEW: int -if sys.version_info >= (3, 7): - SQLITE_DROP_VTABLE: int - SQLITE_FUNCTION: int +SQLITE_DROP_VTABLE: int +SQLITE_FUNCTION: int SQLITE_IGNORE: int SQLITE_INSERT: int SQLITE_OK: int @@ -85,9 +82,8 @@ if sys.version_info >= (3, 11): SQLITE_PRAGMA: int SQLITE_READ: int SQLITE_REINDEX: int -if sys.version_info >= (3, 7): - SQLITE_RECURSIVE: int - SQLITE_SAVEPOINT: int +SQLITE_RECURSIVE: int +SQLITE_SAVEPOINT: int SQLITE_SELECT: int SQLITE_TRANSACTION: int SQLITE_UPDATE: int @@ -207,14 +203,8 @@ def adapt(__obj: Any, __proto: Any) -> Any: ... @overload def adapt(__obj: Any, __proto: Any, __alt: _T) -> Any | _T: ... def complete_statement(statement: str) -> bool: ... - -if sys.version_info >= (3, 7): - _DatabaseArg: TypeAlias = StrOrBytesPath -else: - _DatabaseArg: TypeAlias = bytes | str - def connect( - database: _DatabaseArg, + database: StrOrBytesPath, timeout: float = ..., detect_types: int = ..., isolation_level: str | None = ..., @@ -227,8 +217,14 @@ def enable_callback_tracebacks(__enable: bool) -> None: ... # takes a pos-or-keyword argument because there is a C wrapper def enable_shared_cache(enable: int) -> None: ... -def register_adapter(__type: type[_T], __caster: _Adapter[_T]) -> None: ... -def register_converter(__name: str, __converter: _Converter) -> None: ... + +if sys.version_info >= (3, 11): + def register_adapter(__type: type[_T], __adapter: _Adapter[_T]) -> None: ... + def register_converter(__typename: str, __converter: _Converter) -> None: ... + +else: + def register_adapter(__type: type[_T], __caster: _Adapter[_T]) -> None: ... + def register_converter(__name: str, __converter: _Converter) -> None: ... if sys.version_info < (3, 8): class Cache: @@ -288,7 +284,7 @@ class Connection: text_factory: Any def __init__( self, - database: _DatabaseArg, + database: StrOrBytesPath, timeout: float = ..., detect_types: int = ..., isolation_level: str | None = ..., @@ -347,16 +343,15 @@ class Connection: # without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1 def enable_load_extension(self, __enabled: bool) -> None: ... def load_extension(self, __name: str) -> None: ... - if sys.version_info >= (3, 7): - def backup( - self, - target: Connection, - *, - pages: int = ..., - progress: Callable[[int, int, int], object] | None = ..., - name: str = ..., - sleep: float = ..., - ) -> None: ... + def backup( + self, + target: Connection, + *, + pages: int = ..., + progress: Callable[[int, int, int], object] | None = ..., + name: str = ..., + sleep: float = ..., + ) -> None: ... if sys.version_info >= (3, 11): def setlimit(self, __category: int, __limit: int) -> int: ... def getlimit(self, __category: int) -> int: ... diff --git a/mypy/typeshed/stdlib/sre_compile.pyi b/mypy/typeshed/stdlib/sre_compile.pyi index 98a9f4dad008..a9f4d577d5d1 100644 --- a/mypy/typeshed/stdlib/sre_compile.pyi +++ b/mypy/typeshed/stdlib/sre_compile.pyi @@ -1,7 +1,8 @@ +from re import Pattern from sre_constants import * from sre_constants import _NamedIntConstant from sre_parse import SubPattern -from typing import Any, Pattern +from typing import Any MAXCODE: int diff --git a/mypy/typeshed/stdlib/sre_constants.pyi b/mypy/typeshed/stdlib/sre_constants.pyi index 20a8437ed007..e7344fae3798 100644 --- a/mypy/typeshed/stdlib/sre_constants.pyi +++ b/mypy/typeshed/stdlib/sre_constants.pyi @@ -23,9 +23,8 @@ OPCODES: list[_NamedIntConstant] ATCODES: list[_NamedIntConstant] CHCODES: list[_NamedIntConstant] OP_IGNORE: dict[_NamedIntConstant, _NamedIntConstant] -if sys.version_info >= (3, 7): - OP_LOCALE_IGNORE: dict[_NamedIntConstant, _NamedIntConstant] - OP_UNICODE_IGNORE: dict[_NamedIntConstant, _NamedIntConstant] +OP_LOCALE_IGNORE: dict[_NamedIntConstant, _NamedIntConstant] +OP_UNICODE_IGNORE: dict[_NamedIntConstant, _NamedIntConstant] AT_MULTILINE: dict[_NamedIntConstant, _NamedIntConstant] AT_LOCALE: dict[_NamedIntConstant, _NamedIntConstant] AT_UNICODE: dict[_NamedIntConstant, _NamedIntConstant] @@ -80,18 +79,15 @@ REPEAT: _NamedIntConstant REPEAT_ONE: _NamedIntConstant SUBPATTERN: _NamedIntConstant MIN_REPEAT_ONE: _NamedIntConstant -if sys.version_info >= (3, 7): - RANGE_UNI_IGNORE: _NamedIntConstant - GROUPREF_LOC_IGNORE: _NamedIntConstant - GROUPREF_UNI_IGNORE: _NamedIntConstant - IN_LOC_IGNORE: _NamedIntConstant - IN_UNI_IGNORE: _NamedIntConstant - LITERAL_LOC_IGNORE: _NamedIntConstant - LITERAL_UNI_IGNORE: _NamedIntConstant - NOT_LITERAL_LOC_IGNORE: _NamedIntConstant - NOT_LITERAL_UNI_IGNORE: _NamedIntConstant -else: - RANGE_IGNORE: _NamedIntConstant +RANGE_UNI_IGNORE: _NamedIntConstant +GROUPREF_LOC_IGNORE: _NamedIntConstant +GROUPREF_UNI_IGNORE: _NamedIntConstant +IN_LOC_IGNORE: _NamedIntConstant +IN_UNI_IGNORE: _NamedIntConstant +LITERAL_LOC_IGNORE: _NamedIntConstant +LITERAL_UNI_IGNORE: _NamedIntConstant +NOT_LITERAL_LOC_IGNORE: _NamedIntConstant +NOT_LITERAL_UNI_IGNORE: _NamedIntConstant MIN_REPEAT: _NamedIntConstant MAX_REPEAT: _NamedIntConstant diff --git a/mypy/typeshed/stdlib/sre_parse.pyi b/mypy/typeshed/stdlib/sre_parse.pyi index 1e903028ba7e..e4d66d1baf52 100644 --- a/mypy/typeshed/stdlib/sre_parse.pyi +++ b/mypy/typeshed/stdlib/sre_parse.pyi @@ -1,8 +1,9 @@ import sys from collections.abc import Iterable +from re import Match, Pattern as _Pattern from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Match, Pattern as _Pattern, overload +from typing import Any, overload from typing_extensions import TypeAlias SPECIAL_CHARS: str @@ -15,8 +16,7 @@ WHITESPACE: frozenset[str] ESCAPES: dict[str, tuple[_NIC, int]] CATEGORIES: dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]] FLAGS: dict[str, int] -if sys.version_info >= (3, 7): - TYPE_FLAGS: int +TYPE_FLAGS: int GLOBAL_FLAGS: int if sys.version_info < (3, 11): diff --git a/mypy/typeshed/stdlib/ssl.pyi b/mypy/typeshed/stdlib/ssl.pyi index 9f0420029258..09c8d07780a7 100644 --- a/mypy/typeshed/stdlib/ssl.pyi +++ b/mypy/typeshed/stdlib/ssl.pyi @@ -38,13 +38,11 @@ class SSLWantWriteError(SSLError): ... class SSLSyscallError(SSLError): ... class SSLEOFError(SSLError): ... -if sys.version_info >= (3, 7): - class SSLCertVerificationError(SSLError, ValueError): - verify_code: int - verify_message: str - CertificateError = SSLCertVerificationError -else: - class CertificateError(ValueError): ... +class SSLCertVerificationError(SSLError, ValueError): + verify_code: int + verify_message: str + +CertificateError = SSLCertVerificationError def wrap_socket( sock: socket.socket, @@ -65,34 +63,18 @@ def create_default_context( capath: StrOrBytesPath | None = ..., cadata: str | bytes | None = ..., ) -> SSLContext: ... - -if sys.version_info >= (3, 7): - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: int = ..., - check_hostname: bool = ..., - purpose: Purpose = ..., - certfile: StrOrBytesPath | None = ..., - keyfile: StrOrBytesPath | None = ..., - cafile: StrOrBytesPath | None = ..., - capath: StrOrBytesPath | None = ..., - cadata: str | bytes | None = ..., - ) -> SSLContext: ... - -else: - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: int | None = ..., - check_hostname: bool = ..., - purpose: Purpose = ..., - certfile: StrOrBytesPath | None = ..., - keyfile: StrOrBytesPath | None = ..., - cafile: StrOrBytesPath | None = ..., - capath: StrOrBytesPath | None = ..., - cadata: str | bytes | None = ..., - ) -> SSLContext: ... +def _create_unverified_context( + protocol: int = ..., + *, + cert_reqs: int = ..., + check_hostname: bool = ..., + purpose: Purpose = ..., + certfile: StrOrBytesPath | None = ..., + keyfile: StrOrBytesPath | None = ..., + cafile: StrOrBytesPath | None = ..., + capath: StrOrBytesPath | None = ..., + cadata: str | bytes | None = ..., +) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] @@ -192,8 +174,7 @@ class Options(enum.IntFlag): OP_SINGLE_ECDH_USE: int OP_NO_COMPRESSION: int OP_NO_TICKET: int - if sys.version_info >= (3, 7): - OP_NO_RENEGOTIATION: int + OP_NO_RENEGOTIATION: int if sys.version_info >= (3, 8): OP_ENABLE_MIDDLEBOX_COMPAT: int @@ -209,18 +190,16 @@ OP_SINGLE_DH_USE: Options OP_SINGLE_ECDH_USE: Options OP_NO_COMPRESSION: Options OP_NO_TICKET: Options -if sys.version_info >= (3, 7): - OP_NO_RENEGOTIATION: Options +OP_NO_RENEGOTIATION: Options if sys.version_info >= (3, 8): OP_ENABLE_MIDDLEBOX_COMPAT: Options -if sys.version_info >= (3, 7): - HAS_NEVER_CHECK_COMMON_NAME: bool - HAS_SSLv2: bool - HAS_SSLv3: bool - HAS_TLSv1: bool - HAS_TLSv1_1: bool - HAS_TLSv1_2: bool +HAS_NEVER_CHECK_COMMON_NAME: bool +HAS_SSLv2: bool +HAS_SSLv3: bool +HAS_TLSv1: bool +HAS_TLSv1_1: bool +HAS_TLSv1_2: bool HAS_TLSv1_3: bool HAS_ALPN: bool HAS_ECDH: bool @@ -310,31 +289,7 @@ class SSLSocket(socket.socket): session: SSLSession | None @property def session_reused(self) -> bool | None: ... - if sys.version_info >= (3, 7): - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - else: - def __init__( - self, - sock: socket.socket | None = ..., - keyfile: str | None = ..., - certfile: str | None = ..., - server_side: bool = ..., - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: str | None = ..., - do_handshake_on_connect: bool = ..., - family: int = ..., - type: int = ..., - proto: int = ..., - fileno: int | None = ..., - suppress_ragged_eofs: bool = ..., - npn_protocols: Iterable[str] | None = ..., - ciphers: str | None = ..., - server_hostname: str | None = ..., - _context: SSLContext | None = ..., - _session: Any | None = ..., - ) -> None: ... - + def __init__(self, *args: Any, **kwargs: Any) -> None: ... def connect(self, addr: socket._Address | bytes) -> None: ... def connect_ex(self, addr: socket._Address | bytes) -> int: ... def recv(self, buflen: int = ..., flags: int = ...) -> bytes: ... @@ -372,15 +327,14 @@ class SSLSocket(socket.socket): if sys.version_info >= (3, 8): def verify_client_post_handshake(self) -> None: ... -if sys.version_info >= (3, 7): - class TLSVersion(enum.IntEnum): - MINIMUM_SUPPORTED: int - MAXIMUM_SUPPORTED: int - SSLv3: int - TLSv1: int - TLSv1_1: int - TLSv1_2: int - TLSv1_3: int +class TLSVersion(enum.IntEnum): + MINIMUM_SUPPORTED: int + MAXIMUM_SUPPORTED: int + SSLv3: int + TLSv1: int + TLSv1_1: int + TLSv1_2: int + TLSv1_3: int class SSLContext: check_hostname: bool @@ -389,16 +343,15 @@ class SSLContext: verify_mode: VerifyMode @property def protocol(self) -> _SSLMethod: ... - if sys.version_info >= (3, 7): - hostname_checks_common_name: bool - maximum_version: TLSVersion - minimum_version: TLSVersion - sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None - # The following two attributes have class-level defaults. - # However, the docs explicitly state that it's OK to override these attributes on instances, - # so making these ClassVars wouldn't be appropriate - sslobject_class: type[SSLObject] - sslsocket_class: type[SSLSocket] + hostname_checks_common_name: bool + maximum_version: TLSVersion + minimum_version: TLSVersion + sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None + # The following two attributes have class-level defaults. + # However, the docs explicitly state that it's OK to override these attributes on instances, + # so making these ClassVars wouldn't be appropriate + sslobject_class: type[SSLObject] + sslsocket_class: type[SSLSocket] if sys.version_info >= (3, 8): keylog_filename: str post_handshake_auth: bool @@ -423,11 +376,7 @@ class SSLContext: def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - if sys.version_info >= (3, 7): - def set_servername_callback(self, server_name_callback: _SrvnmeCbType | None) -> None: ... - else: - def set_servername_callback(self, __method: _SrvnmeCbType | None) -> None: ... - + def set_servername_callback(self, server_name_callback: _SrvnmeCbType | None) -> None: ... def load_dh_params(self, __path: str) -> None: ... def set_ecdh_curve(self, __name: str) -> None: ... def wrap_socket( @@ -458,11 +407,7 @@ class SSLObject: session: SSLSession | None @property def session_reused(self) -> bool: ... - if sys.version_info >= (3, 7): - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - else: - def __init__(self, sslobj: Any, owner: SSLSocket | SSLObject | None = ..., session: Any | None = ...) -> None: ... - + def __init__(self, *args: Any, **kwargs: Any) -> None: ... def read(self, len: int = ..., buffer: bytearray | None = ...) -> bytes: ... def write(self, data: bytes) -> int: ... @overload diff --git a/mypy/typeshed/stdlib/string.pyi b/mypy/typeshed/stdlib/string.pyi index 525806a74043..1b9ba5b58fa1 100644 --- a/mypy/typeshed/stdlib/string.pyi +++ b/mypy/typeshed/stdlib/string.pyi @@ -1,12 +1,9 @@ import sys +from _typeshed import StrOrLiteralStr from collections.abc import Iterable, Mapping, Sequence -from re import RegexFlag -from typing import Any - -if sys.version_info >= (3, 8): - from re import Pattern -else: - from typing import Pattern +from re import Pattern, RegexFlag +from typing import Any, overload +from typing_extensions import LiteralString __all__ = [ "ascii_letters", @@ -23,17 +20,17 @@ __all__ = [ "Template", ] -ascii_letters: str -ascii_lowercase: str -ascii_uppercase: str -digits: str -hexdigits: str -octdigits: str -punctuation: str -printable: str -whitespace: str +ascii_letters: LiteralString +ascii_lowercase: LiteralString +ascii_uppercase: LiteralString +digits: LiteralString +hexdigits: LiteralString +octdigits: LiteralString +punctuation: LiteralString +printable: LiteralString +whitespace: LiteralString -def capwords(s: str, sep: str | None = ...) -> str: ... +def capwords(s: StrOrLiteralStr, sep: StrOrLiteralStr | None = ...) -> StrOrLiteralStr: ... class Template: template: str @@ -49,11 +46,20 @@ class Template: def get_identifiers(self) -> list[str]: ... def is_valid(self) -> bool: ... -# TODO(MichalPokorny): This is probably badly and/or loosely typed. class Formatter: + @overload + def format(self, __format_string: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ... + @overload def format(self, __format_string: str, *args: Any, **kwargs: Any) -> str: ... + @overload + def vformat( + self, format_string: LiteralString, args: Sequence[LiteralString], kwargs: Mapping[LiteralString, LiteralString] + ) -> LiteralString: ... + @overload def vformat(self, format_string: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> str: ... - def parse(self, format_string: str) -> Iterable[tuple[str, str | None, str | None, str | None]]: ... + def parse( + self, format_string: StrOrLiteralStr + ) -> Iterable[tuple[StrOrLiteralStr, StrOrLiteralStr | None, StrOrLiteralStr | None, StrOrLiteralStr | None]]: ... def get_field(self, field_name: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def get_value(self, key: int | str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def check_unused_args(self, used_args: Sequence[int | str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... diff --git a/mypy/typeshed/stdlib/struct.pyi b/mypy/typeshed/stdlib/struct.pyi index 59c66ad2f167..f7eff2b76f14 100644 --- a/mypy/typeshed/stdlib/struct.pyi +++ b/mypy/typeshed/stdlib/struct.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterator from typing import Any @@ -15,10 +14,7 @@ def iter_unpack(__format: str | bytes, __buffer: ReadableBuffer) -> Iterator[tup def calcsize(__format: str | bytes) -> int: ... class Struct: - if sys.version_info >= (3, 7): - format: str - else: - format: bytes + format: str size: int def __init__(self, format: str | bytes) -> None: ... def pack(self, *v: Any) -> bytes: ... diff --git a/mypy/typeshed/stdlib/subprocess.pyi b/mypy/typeshed/stdlib/subprocess.pyi index 470069a96a80..fded3f74928e 100644 --- a/mypy/typeshed/stdlib/subprocess.pyi +++ b/mypy/typeshed/stdlib/subprocess.pyi @@ -36,22 +36,18 @@ if sys.platform == "win32": "STD_INPUT_HANDLE", "STD_OUTPUT_HANDLE", "SW_HIDE", + "ABOVE_NORMAL_PRIORITY_CLASS", + "BELOW_NORMAL_PRIORITY_CLASS", + "CREATE_BREAKAWAY_FROM_JOB", + "CREATE_DEFAULT_ERROR_MODE", + "CREATE_NO_WINDOW", + "DETACHED_PROCESS", + "HIGH_PRIORITY_CLASS", + "IDLE_PRIORITY_CLASS", + "NORMAL_PRIORITY_CLASS", + "REALTIME_PRIORITY_CLASS", ] - if sys.version_info >= (3, 7): - __all__ += [ - "ABOVE_NORMAL_PRIORITY_CLASS", - "BELOW_NORMAL_PRIORITY_CLASS", - "CREATE_BREAKAWAY_FROM_JOB", - "CREATE_DEFAULT_ERROR_MODE", - "CREATE_NO_WINDOW", - "DETACHED_PROCESS", - "HIGH_PRIORITY_CLASS", - "IDLE_PRIORITY_CLASS", - "NORMAL_PRIORITY_CLASS", - "REALTIME_PRIORITY_CLASS", - ] - # We prefer to annotate inputs to methods (eg subprocess.check_call) with these # union types. # For outputs we use laborious literal based overloads to try to determine @@ -71,7 +67,7 @@ _TXT: TypeAlias = bytes | str if sys.version_info >= (3, 8): _CMD: TypeAlias = StrOrBytesPath | Sequence[StrOrBytesPath] else: - # Python 3.6 doesn't support _CMD being a single PathLike. + # Python 3.7 doesn't support _CMD being a single PathLike. # See: https://bugs.python.org/issue31961 _CMD: TypeAlias = _TXT | Sequence[StrOrBytesPath] if sys.platform == "win32": @@ -95,8 +91,14 @@ class CompletedProcess(Generic[_T]): # and writing all the overloads would be horrific. stdout: _T stderr: _T - # type ignore on __init__ because the TypeVar can technically be unsolved, but see comment above - def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ... # type: ignore + # pyright ignore on __init__ because the TypeVar can technically be unsolved, but see comment above + def __init__( + self, + args: _CMD, + returncode: int, + stdout: _T | None = ..., # pyright: ignore[reportInvalidTypeVarUse] + stderr: _T | None = ..., # pyright: ignore[reportInvalidTypeVarUse] + ) -> None: ... def check_returncode(self) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -707,8 +709,7 @@ elif sys.version_info >= (3, 9): umask: int = ..., ) -> CompletedProcess[Any]: ... -elif sys.version_info >= (3, 7): - # Nearly the same args as for 3.6, except for capture_output and text +else: @overload def run( args: _CMD, @@ -879,140 +880,6 @@ elif sys.version_info >= (3, 7): timeout: float | None = ..., ) -> CompletedProcess[Any]: ... -else: - # Nearly same args as Popen.__init__ except for timeout, input, and check - @overload - def run( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: str, - errors: str | None = ..., - input: str | None = ..., - timeout: float | None = ..., - ) -> CompletedProcess[str]: ... - @overload - def run( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: str | None = ..., - errors: str, - input: str | None = ..., - timeout: float | None = ..., - ) -> CompletedProcess[str]: ... - @overload - def run( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - *, - universal_newlines: Literal[True], - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - # where the *real* keyword only args start - check: bool = ..., - encoding: str | None = ..., - errors: str | None = ..., - input: str | None = ..., - timeout: float | None = ..., - ) -> CompletedProcess[str]: ... - @overload - def run( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: Literal[False] = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: None = ..., - errors: None = ..., - input: bytes | None = ..., - timeout: float | None = ..., - ) -> CompletedProcess[bytes]: ... - @overload - def run( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - check: bool = ..., - encoding: str | None = ..., - errors: str | None = ..., - input: _TXT | None = ..., - timeout: float | None = ..., - ) -> CompletedProcess[Any]: ... - # Same args as Popen.__init__ if sys.version_info >= (3, 11): # 3.11 adds "process_group" argument @@ -1104,31 +971,6 @@ elif sys.version_info >= (3, 9): umask: int = ..., ) -> int: ... -elif sys.version_info >= (3, 7): - # 3.7 adds the "text" argument - def call( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - timeout: float | None = ..., - text: bool | None = ..., - ) -> int: ... - else: def call( args: _CMD, @@ -1150,6 +992,7 @@ else: pass_fds: Any = ..., *, timeout: float | None = ..., + text: bool | None = ..., ) -> int: ... # Same args as Popen.__init__ @@ -1243,8 +1086,7 @@ elif sys.version_info >= (3, 9): umask: int = ..., ) -> int: ... -elif sys.version_info >= (3, 7): - # 3.7 adds the "text" argument +else: def check_call( args: _CMD, bufsize: int = ..., @@ -1268,28 +1110,6 @@ elif sys.version_info >= (3, 7): text: bool | None = ..., ) -> int: ... -else: - def check_call( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - timeout: float | None = ..., - ) -> int: ... - if sys.version_info >= (3, 11): # 3.11 adds "process_group" argument @overload @@ -1842,8 +1662,7 @@ elif sys.version_info >= (3, 9): umask: int = ..., ) -> Any: ... # morally: -> _TXT -elif sys.version_info >= (3, 7): - # 3.7 added text +else: @overload def check_output( args: _CMD, @@ -1996,128 +1815,6 @@ elif sys.version_info >= (3, 7): text: bool | None = ..., ) -> Any: ... # morally: -> _TXT -else: - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - timeout: float | None = ..., - input: _TXT | None = ..., - encoding: str, - errors: str | None = ..., - ) -> str: ... - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - timeout: float | None = ..., - input: _TXT | None = ..., - encoding: str | None = ..., - errors: str, - ) -> str: ... - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - universal_newlines: Literal[True], - timeout: float | None = ..., - input: _TXT | None = ..., - encoding: str | None = ..., - errors: str | None = ..., - ) -> str: ... - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: Literal[False] = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - timeout: float | None = ..., - input: _TXT | None = ..., - encoding: None = ..., - errors: None = ..., - ) -> bytes: ... - @overload - def check_output( - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - timeout: float | None = ..., - input: _TXT | None = ..., - encoding: str | None = ..., - errors: str | None = ..., - ) -> Any: ... # morally: -> _TXT - PIPE: int STDOUT: int DEVNULL: int @@ -2704,8 +2401,7 @@ class Popen(Generic[AnyStr]): extra_groups: Iterable[str | int] | None = ..., umask: int = ..., ) -> None: ... - elif sys.version_info >= (3, 7): - # text is added in 3.7 + else: @overload def __init__( self: Popen[str], @@ -2857,134 +2553,9 @@ class Popen(Generic[AnyStr]): encoding: str | None = ..., errors: str | None = ..., ) -> None: ... - else: - @overload - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE | None = ..., - stdout: _FILE | None = ..., - stderr: _FILE | None = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any | None = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - encoding: str, - errors: str | None = ..., - ) -> None: ... - @overload - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE | None = ..., - stdout: _FILE | None = ..., - stderr: _FILE | None = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any | None = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - encoding: str | None = ..., - errors: str, - ) -> None: ... - @overload - def __init__( - self: Popen[str], - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE | None = ..., - stdout: _FILE | None = ..., - stderr: _FILE | None = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - *, - universal_newlines: Literal[True], - startupinfo: Any | None = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - # where the *real* keyword only args start - encoding: str | None = ..., - errors: str | None = ..., - ) -> None: ... - @overload - def __init__( - self: Popen[bytes], - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE | None = ..., - stdout: _FILE | None = ..., - stderr: _FILE | None = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: Literal[False] = ..., - startupinfo: Any | None = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - encoding: None = ..., - errors: None = ..., - ) -> None: ... - @overload - def __init__( - self: Popen[Any], - args: _CMD, - bufsize: int = ..., - executable: StrOrBytesPath | None = ..., - stdin: _FILE | None = ..., - stdout: _FILE | None = ..., - stderr: _FILE | None = ..., - preexec_fn: Callable[[], Any] | None = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: StrOrBytesPath | None = ..., - env: _ENV | None = ..., - universal_newlines: bool = ..., - startupinfo: Any | None = ..., - creationflags: int = ..., - restore_signals: bool = ..., - start_new_session: bool = ..., - pass_fds: Any = ..., - *, - encoding: str | None = ..., - errors: str | None = ..., - ) -> None: ... def poll(self) -> int | None: ... - if sys.version_info >= (3, 7): - def wait(self, timeout: float | None = ...) -> int: ... - else: - def wait(self, timeout: float | None = ..., endtime: float | None = ...) -> int: ... + def wait(self, timeout: float | None = ...) -> int: ... # Return str/bytes def communicate( self, @@ -3019,27 +2590,35 @@ else: if sys.platform == "win32": class STARTUPINFO: - if sys.version_info >= (3, 7): - def __init__( - self, - *, - dwFlags: int = ..., - hStdInput: Any | None = ..., - hStdOutput: Any | None = ..., - hStdError: Any | None = ..., - wShowWindow: int = ..., - lpAttributeList: Mapping[str, Any] | None = ..., - ) -> None: ... + def __init__( + self, + *, + dwFlags: int = ..., + hStdInput: Any | None = ..., + hStdOutput: Any | None = ..., + hStdError: Any | None = ..., + wShowWindow: int = ..., + lpAttributeList: Mapping[str, Any] | None = ..., + ) -> None: ... dwFlags: int hStdInput: Any | None hStdOutput: Any | None hStdError: Any | None wShowWindow: int - if sys.version_info >= (3, 7): - lpAttributeList: Mapping[str, Any] + lpAttributeList: Mapping[str, Any] from _winapi import ( + ABOVE_NORMAL_PRIORITY_CLASS as ABOVE_NORMAL_PRIORITY_CLASS, + BELOW_NORMAL_PRIORITY_CLASS as BELOW_NORMAL_PRIORITY_CLASS, + CREATE_BREAKAWAY_FROM_JOB as CREATE_BREAKAWAY_FROM_JOB, + CREATE_DEFAULT_ERROR_MODE as CREATE_DEFAULT_ERROR_MODE, CREATE_NEW_CONSOLE as CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP as CREATE_NEW_PROCESS_GROUP, + CREATE_NO_WINDOW as CREATE_NO_WINDOW, + DETACHED_PROCESS as DETACHED_PROCESS, + HIGH_PRIORITY_CLASS as HIGH_PRIORITY_CLASS, + IDLE_PRIORITY_CLASS as IDLE_PRIORITY_CLASS, + NORMAL_PRIORITY_CLASS as NORMAL_PRIORITY_CLASS, + REALTIME_PRIORITY_CLASS as REALTIME_PRIORITY_CLASS, STARTF_USESHOWWINDOW as STARTF_USESHOWWINDOW, STARTF_USESTDHANDLES as STARTF_USESTDHANDLES, STD_ERROR_HANDLE as STD_ERROR_HANDLE, @@ -3047,17 +2626,3 @@ if sys.platform == "win32": STD_OUTPUT_HANDLE as STD_OUTPUT_HANDLE, SW_HIDE as SW_HIDE, ) - - if sys.version_info >= (3, 7): - from _winapi import ( - ABOVE_NORMAL_PRIORITY_CLASS as ABOVE_NORMAL_PRIORITY_CLASS, - BELOW_NORMAL_PRIORITY_CLASS as BELOW_NORMAL_PRIORITY_CLASS, - CREATE_BREAKAWAY_FROM_JOB as CREATE_BREAKAWAY_FROM_JOB, - CREATE_DEFAULT_ERROR_MODE as CREATE_DEFAULT_ERROR_MODE, - CREATE_NO_WINDOW as CREATE_NO_WINDOW, - DETACHED_PROCESS as DETACHED_PROCESS, - HIGH_PRIORITY_CLASS as HIGH_PRIORITY_CLASS, - IDLE_PRIORITY_CLASS as IDLE_PRIORITY_CLASS, - NORMAL_PRIORITY_CLASS as NORMAL_PRIORITY_CLASS, - REALTIME_PRIORITY_CLASS as REALTIME_PRIORITY_CLASS, - ) diff --git a/mypy/typeshed/stdlib/symbol.pyi b/mypy/typeshed/stdlib/symbol.pyi index 234c814b55b5..bb6660374d16 100644 --- a/mypy/typeshed/stdlib/symbol.pyi +++ b/mypy/typeshed/stdlib/symbol.pyi @@ -86,8 +86,7 @@ comp_if: int encoding_decl: int yield_expr: int yield_arg: int -if sys.version_info >= (3, 7): - sync_comp_for: int +sync_comp_for: int if sys.version_info >= (3, 8): func_body_suite: int func_type: int diff --git a/mypy/typeshed/stdlib/sys.pyi b/mypy/typeshed/stdlib/sys.pyi index ef8dc085c7af..9b113e5ef674 100644 --- a/mypy/typeshed/stdlib/sys.pyi +++ b/mypy/typeshed/stdlib/sys.pyi @@ -81,10 +81,8 @@ flags: _flags if sys.version_info >= (3, 10): _FlagTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, bool, int, int] -elif sys.version_info >= (3, 7): - _FlagTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, bool, int] else: - _FlagTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int, int, int, int] + _FlagTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, bool, int] @final class _flags(_UninstantiableStructseq, _FlagTuple): @@ -114,11 +112,10 @@ class _flags(_UninstantiableStructseq, _FlagTuple): def hash_randomization(self) -> int: ... @property def isolated(self) -> int: ... - if sys.version_info >= (3, 7): - @property - def dev_mode(self) -> bool: ... - @property - def utf8_mode(self) -> int: ... + @property + def dev_mode(self) -> bool: ... + @property + def utf8_mode(self) -> int: ... if sys.version_info >= (3, 10): @property def warn_default_encoding(self) -> int: ... # undocumented @@ -276,9 +273,9 @@ if sys.platform == "win32": def intern(__string: str) -> str: ... def is_finalizing() -> bool: ... -if sys.version_info >= (3, 7): - __breakpointhook__: Any # contains the original value of breakpointhook - def breakpointhook(*args: Any, **kwargs: Any) -> Any: ... +__breakpointhook__: Any # contains the original value of breakpointhook + +def breakpointhook(*args: Any, **kwargs: Any) -> Any: ... if sys.platform != "win32": def setdlopenflags(__flags: int) -> None: ... @@ -323,9 +320,8 @@ def set_asyncgen_hooks(firstiter: _AsyncgenHook = ..., finalizer: _AsyncgenHook if sys.platform == "win32": def _enablelegacywindowsfsencoding() -> None: ... -if sys.version_info >= (3, 7): - def get_coroutine_origin_tracking_depth() -> int: ... - def set_coroutine_origin_tracking_depth(depth: int) -> None: ... +def get_coroutine_origin_tracking_depth() -> int: ... +def set_coroutine_origin_tracking_depth(depth: int) -> None: ... if sys.version_info < (3, 8): _CoroWrapper: TypeAlias = Callable[[Coroutine[Any, Any, Any]], Any] diff --git a/mypy/typeshed/stdlib/sysconfig.pyi b/mypy/typeshed/stdlib/sysconfig.pyi index 13c40b927f4e..03362b5caef9 100644 --- a/mypy/typeshed/stdlib/sysconfig.pyi +++ b/mypy/typeshed/stdlib/sysconfig.pyi @@ -1,4 +1,6 @@ +import sys from typing import IO, Any, overload +from typing_extensions import Literal __all__ = [ "get_config_h_filename", @@ -20,6 +22,11 @@ def get_config_vars() -> dict[str, Any]: ... @overload def get_config_vars(arg: str, *args: str) -> list[Any]: ... def get_scheme_names() -> tuple[str, ...]: ... + +if sys.version_info >= (3, 10): + def get_default_scheme() -> str: ... + def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> str: ... + def get_path_names() -> tuple[str, ...]: ... def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> str: ... def get_paths(scheme: str = ..., vars: dict[str, Any] | None = ..., expand: bool = ...) -> dict[str, str]: ... diff --git a/mypy/typeshed/stdlib/tarfile.pyi b/mypy/typeshed/stdlib/tarfile.pyi index 87c57311aa99..cf74899a8fb4 100644 --- a/mypy/typeshed/stdlib/tarfile.pyi +++ b/mypy/typeshed/stdlib/tarfile.pyi @@ -294,26 +294,14 @@ class TarFile: def chown(self, tarinfo: TarInfo, targetpath: StrOrBytesPath, numeric_owner: bool) -> None: ... # undocumented def chmod(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented def utime(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented - if sys.version_info >= (3, 7): - def add( - self, - name: StrPath, - arcname: StrPath | None = ..., - recursive: bool = ..., - *, - filter: Callable[[TarInfo], TarInfo | None] | None = ..., - ) -> None: ... - else: - def add( - self, - name: StrPath, - arcname: StrPath | None = ..., - recursive: bool = ..., - exclude: Callable[[str], bool] | None = ..., - *, - filter: Callable[[TarInfo], TarInfo | None] | None = ..., - ) -> None: ... - + def add( + self, + name: StrPath, + arcname: StrPath | None = ..., + recursive: bool = ..., + *, + filter: Callable[[TarInfo], TarInfo | None] | None = ..., + ) -> None: ... def addfile(self, tarinfo: TarInfo, fileobj: IO[bytes] | None = ...) -> None: ... def gettarinfo( self, name: StrOrBytesPath | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ... diff --git a/mypy/typeshed/stdlib/telnetlib.pyi b/mypy/typeshed/stdlib/telnetlib.pyi index 8edbd155f61c..67ae5fcc8055 100644 --- a/mypy/typeshed/stdlib/telnetlib.pyi +++ b/mypy/typeshed/stdlib/telnetlib.pyi @@ -1,8 +1,9 @@ import socket from _typeshed import Self from collections.abc import Callable, Sequence +from re import Match, Pattern from types import TracebackType -from typing import Any, Match, Pattern +from typing import Any __all__ = ["Telnet"] @@ -103,7 +104,7 @@ class Telnet: def read_lazy(self) -> bytes: ... def read_very_lazy(self) -> bytes: ... def read_sb_data(self) -> bytes: ... - def set_option_negotiation_callback(self, callback: Callable[[socket.socket, bytes, bytes], Any] | None) -> None: ... + def set_option_negotiation_callback(self, callback: Callable[[socket.socket, bytes, bytes], object] | None) -> None: ... def process_rawq(self) -> None: ... def rawq_getchar(self) -> bytes: ... def fill_rawq(self) -> None: ... diff --git a/mypy/typeshed/stdlib/textwrap.pyi b/mypy/typeshed/stdlib/textwrap.pyi index 5a61dfedb380..9e423cb5ce94 100644 --- a/mypy/typeshed/stdlib/textwrap.pyi +++ b/mypy/typeshed/stdlib/textwrap.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Pattern +from re import Pattern __all__ = ["TextWrapper", "wrap", "fill", "dedent", "indent", "shorten"] diff --git a/mypy/typeshed/stdlib/threading.pyi b/mypy/typeshed/stdlib/threading.pyi index 729def005831..289a86826ecd 100644 --- a/mypy/typeshed/stdlib/threading.pyi +++ b/mypy/typeshed/stdlib/threading.pyi @@ -75,7 +75,7 @@ class Thread: def __init__( self, group: None = ..., - target: Callable[..., Any] | None = ..., + target: Callable[..., object] | None = ..., name: str | None = ..., args: Iterable[Any] = ..., kwargs: Mapping[str, Any] | None = ..., @@ -106,7 +106,7 @@ class Lock: def __enter__(self) -> bool: ... def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... + ) -> None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -125,7 +125,7 @@ class Condition: def __enter__(self) -> bool: ... def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... + ) -> None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... def wait(self, timeout: float | None = ...) -> bool: ... @@ -171,7 +171,7 @@ class Timer(Thread): def __init__( self, interval: float, - function: Callable[..., Any], + function: Callable[..., object], args: Iterable[Any] | None = ..., kwargs: Mapping[str, Any] | None = ..., ) -> None: ... diff --git a/mypy/typeshed/stdlib/time.pyi b/mypy/typeshed/stdlib/time.pyi index cceb7c8ca874..035d78934f3a 100644 --- a/mypy/typeshed/stdlib/time.pyi +++ b/mypy/typeshed/stdlib/time.pyi @@ -10,12 +10,11 @@ daylight: int timezone: int tzname: tuple[str, str] -if sys.version_info >= (3, 7): - if sys.platform == "linux": - CLOCK_BOOTTIME: int - if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": - CLOCK_PROF: int # FreeBSD, NetBSD, OpenBSD - CLOCK_UPTIME: int # FreeBSD, OpenBSD +if sys.platform == "linux": + CLOCK_BOOTTIME: int +if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin": + CLOCK_PROF: int # FreeBSD, NetBSD, OpenBSD + CLOCK_UPTIME: int # FreeBSD, OpenBSD if sys.platform != "win32": CLOCK_MONOTONIC: int @@ -97,17 +96,16 @@ if sys.platform != "win32": def clock_gettime(clk_id: int) -> float: ... # Unix only def clock_settime(clk_id: int, time: float) -> None: ... # Unix only -if sys.version_info >= (3, 7): - if sys.platform != "win32": - def clock_gettime_ns(clock_id: int) -> int: ... - def clock_settime_ns(clock_id: int, time: int) -> int: ... - - if sys.platform == "linux": - def pthread_getcpuclockid(thread_id: int) -> int: ... - - def monotonic_ns() -> int: ... - def perf_counter_ns() -> int: ... - def process_time_ns() -> int: ... - def time_ns() -> int: ... - def thread_time() -> float: ... - def thread_time_ns() -> int: ... +if sys.platform != "win32": + def clock_gettime_ns(clock_id: int) -> int: ... + def clock_settime_ns(clock_id: int, time: int) -> int: ... + +if sys.platform == "linux": + def pthread_getcpuclockid(thread_id: int) -> int: ... + +def monotonic_ns() -> int: ... +def perf_counter_ns() -> int: ... +def process_time_ns() -> int: ... +def time_ns() -> int: ... +def thread_time() -> float: ... +def thread_time_ns() -> int: ... diff --git a/mypy/typeshed/stdlib/timeit.pyi b/mypy/typeshed/stdlib/timeit.pyi index 076b2c54f991..dda6cefed0f6 100644 --- a/mypy/typeshed/stdlib/timeit.pyi +++ b/mypy/typeshed/stdlib/timeit.pyi @@ -5,7 +5,7 @@ from typing_extensions import TypeAlias __all__ = ["Timer", "timeit", "repeat", "default_timer"] _Timer: TypeAlias = Callable[[], float] -_Stmt: TypeAlias = str | Callable[[], Any] +_Stmt: TypeAlias = str | Callable[[], object] default_timer: _Timer @@ -16,7 +16,7 @@ class Timer: def print_exc(self, file: IO[str] | None = ...) -> None: ... def timeit(self, number: int = ...) -> float: ... def repeat(self, repeat: int = ..., number: int = ...) -> list[float]: ... - def autorange(self, callback: Callable[[int, float], Any] | None = ...) -> tuple[int, float]: ... + def autorange(self, callback: Callable[[int, float], object] | None = ...) -> tuple[int, float]: ... def timeit( stmt: _Stmt = ..., setup: _Stmt = ..., timer: _Timer = ..., number: int = ..., globals: dict[str, Any] | None = ... diff --git a/mypy/typeshed/stdlib/tkinter/simpledialog.pyi b/mypy/typeshed/stdlib/tkinter/simpledialog.pyi index fbe78530721f..8ae8b6d286d0 100644 --- a/mypy/typeshed/stdlib/tkinter/simpledialog.pyi +++ b/mypy/typeshed/stdlib/tkinter/simpledialog.pyi @@ -1,10 +1,13 @@ -from tkinter import Event, Misc, Toplevel -from typing import Any +from tkinter import Event, Frame, Misc, Toplevel class Dialog(Toplevel): def __init__(self, parent: Misc | None, title: str | None = ...) -> None: ... - def body(self, master) -> None: ... + def body(self, master: Frame) -> Misc | None: ... def buttonbox(self) -> None: ... + def ok(self, event: Event[Misc] | None = ...) -> None: ... + def cancel(self, event: Event[Misc] | None = ...) -> None: ... + def validate(self) -> bool: ... + def apply(self) -> None: ... class SimpleDialog: def __init__( @@ -22,6 +25,30 @@ class SimpleDialog: def wm_delete_window(self) -> None: ... def done(self, num: int) -> None: ... -def askfloat(title: str | None, prompt: str, **kwargs: Any) -> float | None: ... -def askinteger(title: str | None, prompt: str, **kwargs: Any) -> int | None: ... -def askstring(title: str | None, prompt: str, **kwargs: Any) -> str | None: ... +def askfloat( + title: str | None, + prompt: str, + *, + initialvalue: float | None = ..., + minvalue: float | None = ..., + maxvalue: float | None = ..., + parent: Misc | None = ..., +) -> float | None: ... +def askinteger( + title: str | None, + prompt: str, + *, + initialvalue: int | None = ..., + minvalue: int | None = ..., + maxvalue: int | None = ..., + parent: Misc | None = ..., +) -> int | None: ... +def askstring( + title: str | None, + prompt: str, + *, + initialvalue: str | None = ..., + show: str | None = ..., + # minvalue/maxvalue is accepted but not useful. + parent: Misc | None = ..., +) -> str | None: ... diff --git a/mypy/typeshed/stdlib/tkinter/ttk.pyi b/mypy/typeshed/stdlib/tkinter/ttk.pyi index 0fe94ad30ff5..81077200289f 100644 --- a/mypy/typeshed/stdlib/tkinter/ttk.pyi +++ b/mypy/typeshed/stdlib/tkinter/ttk.pyi @@ -31,11 +31,9 @@ __all__ = [ "OptionMenu", "tclobjs_to_py", "setup_master", + "Spinbox", ] -if sys.version_info >= (3, 7): - __all__ += ["Spinbox"] - def tclobjs_to_py(adict: dict[Any, Any]) -> dict[Any, Any]: ... def setup_master(master: Any | None = ...): ... @@ -853,71 +851,70 @@ class Sizegrip(Widget): def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure -if sys.version_info >= (3, 7): - class Spinbox(Entry): - def __init__( - self, - master: tkinter.Misc | None = ..., - *, - background: tkinter._Color = ..., # undocumented - class_: str = ..., - command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., - cursor: tkinter._Cursor = ..., - exportselection: bool = ..., # undocumented - font: _FontDescription = ..., # undocumented - foreground: tkinter._Color = ..., # undocumented - format: str = ..., - from_: float = ..., - increment: float = ..., - invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented - justify: Literal["left", "center", "right"] = ..., # undocumented - name: str = ..., - show: Any = ..., # undocumented - state: str = ..., - style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., # undocumented - to: float = ..., - validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | tuple[str, ...] = ..., - width: int = ..., # undocumented - wrap: bool = ..., - xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> None: ... - @overload # type: ignore[override] - def configure( - self, - cnf: dict[str, Any] | None = ..., - *, - background: tkinter._Color = ..., - command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., - cursor: tkinter._Cursor = ..., - exportselection: bool = ..., - font: _FontDescription = ..., - foreground: tkinter._Color = ..., - format: str = ..., - from_: float = ..., - increment: float = ..., - invalidcommand: tkinter._EntryValidateCommand = ..., - justify: Literal["left", "center", "right"] = ..., - show: Any = ..., - state: str = ..., - style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., - to: float = ..., - validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tkinter._EntryValidateCommand = ..., - values: list[str] | tuple[str, ...] = ..., - width: int = ..., - wrap: bool = ..., - xscrollcommand: tkinter._XYScrollCommand = ..., - ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... - @overload - def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... - config = configure # type: ignore[assignment] - def set(self, value: Any) -> None: ... +class Spinbox(Entry): + def __init__( + self, + master: tkinter.Misc | None = ..., + *, + background: tkinter._Color = ..., # undocumented + class_: str = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., + cursor: tkinter._Cursor = ..., + exportselection: bool = ..., # undocumented + font: _FontDescription = ..., # undocumented + foreground: tkinter._Color = ..., # undocumented + format: str = ..., + from_: float = ..., + increment: float = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented + justify: Literal["left", "center", "right"] = ..., # undocumented + name: str = ..., + show: Any = ..., # undocumented + state: str = ..., + style: str = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., # undocumented + to: float = ..., + validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., + validatecommand: tkinter._EntryValidateCommand = ..., + values: list[str] | tuple[str, ...] = ..., + width: int = ..., # undocumented + wrap: bool = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., + ) -> None: ... + @overload # type: ignore[override] + def configure( + self, + cnf: dict[str, Any] | None = ..., + *, + background: tkinter._Color = ..., + command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., + cursor: tkinter._Cursor = ..., + exportselection: bool = ..., + font: _FontDescription = ..., + foreground: tkinter._Color = ..., + format: str = ..., + from_: float = ..., + increment: float = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., + justify: Literal["left", "center", "right"] = ..., + show: Any = ..., + state: str = ..., + style: str = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., + to: float = ..., + validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., + validatecommand: tkinter._EntryValidateCommand = ..., + values: list[str] | tuple[str, ...] = ..., + width: int = ..., + wrap: bool = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., + ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... + @overload + def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... + config = configure # type: ignore[assignment] + def set(self, value: Any) -> None: ... class _TreeviewItemDict(TypedDict): text: str diff --git a/mypy/typeshed/stdlib/token.pyi b/mypy/typeshed/stdlib/token.pyi index 5fe9db7e230d..fcd6ef87d217 100644 --- a/mypy/typeshed/stdlib/token.pyi +++ b/mypy/typeshed/stdlib/token.pyi @@ -62,16 +62,13 @@ __all__ = [ "VBAR", "VBAREQUAL", "tok_name", + "ENCODING", + "NL", + "COMMENT", ] -if sys.version_info < (3, 7) or sys.version_info >= (3, 8): - __all__ += ["ASYNC", "AWAIT"] - -if sys.version_info >= (3, 7): - __all__ += ["ENCODING", "NL", "COMMENT"] - if sys.version_info >= (3, 8): - __all__ += ["COLONEQUAL", "TYPE_COMMENT", "TYPE_IGNORE"] + __all__ += ["ASYNC", "AWAIT", "COLONEQUAL", "TYPE_COMMENT", "TYPE_IGNORE"] if sys.version_info >= (3, 10): __all__ += ["SOFT_KEYWORD"] @@ -129,8 +126,7 @@ AT: int RARROW: int ELLIPSIS: int ATEQUAL: int -if sys.version_info < (3, 7) or sys.version_info >= (3, 8): - # These were removed in Python 3.7 but added back in Python 3.8 +if sys.version_info >= (3, 8): AWAIT: int ASYNC: int OP: int @@ -138,10 +134,9 @@ ERRORTOKEN: int N_TOKENS: int NT_OFFSET: int tok_name: dict[int, str] -if sys.version_info >= (3, 7): - COMMENT: int - NL: int - ENCODING: int +COMMENT: int +NL: int +ENCODING: int if sys.version_info >= (3, 8): TYPE_COMMENT: int TYPE_IGNORE: int diff --git a/mypy/typeshed/stdlib/tokenize.pyi b/mypy/typeshed/stdlib/tokenize.pyi index 3ac136150ab5..1a67736e78de 100644 --- a/mypy/typeshed/stdlib/tokenize.pyi +++ b/mypy/typeshed/stdlib/tokenize.pyi @@ -1,9 +1,9 @@ import sys from _typeshed import StrOrBytesPath -from builtins import open as _builtin_open from collections.abc import Callable, Generator, Iterable, Sequence +from re import Pattern from token import * -from typing import Any, NamedTuple, Pattern, TextIO +from typing import Any, NamedTuple, TextIO from typing_extensions import TypeAlias __all__ = [ @@ -77,11 +77,8 @@ __all__ = [ "untokenize", ] -if sys.version_info < (3, 7) or sys.version_info >= (3, 8): - __all__ += ["ASYNC", "AWAIT"] - if sys.version_info >= (3, 8): - __all__ += ["COLONEQUAL", "generate_tokens", "TYPE_COMMENT", "TYPE_IGNORE"] + __all__ += ["ASYNC", "AWAIT", "COLONEQUAL", "generate_tokens", "TYPE_COMMENT", "TYPE_IGNORE"] if sys.version_info >= (3, 10): __all__ += ["SOFT_KEYWORD"] @@ -91,11 +88,6 @@ if sys.version_info >= (3, 8): else: EXACT_TOKEN_TYPES: dict[str, int] -if sys.version_info < (3, 7): - COMMENT: int - NL: int - ENCODING: int - cookie_re: Pattern[str] blank_re: Pattern[bytes] @@ -167,10 +159,6 @@ Double3: str # undocumented Triple: str # undocumented String: str # undocumented -if sys.version_info < (3, 7): - Operator: str # undocumented - Bracket: str # undocumented - Special: str # undocumented Funny: str # undocumented diff --git a/mypy/typeshed/stdlib/tracemalloc.pyi b/mypy/typeshed/stdlib/tracemalloc.pyi index 4b7063e5d800..ed952616600f 100644 --- a/mypy/typeshed/stdlib/tracemalloc.pyi +++ b/mypy/typeshed/stdlib/tracemalloc.pyi @@ -83,11 +83,8 @@ class Traceback(Sequence[Frame]): def __init__(self, frames: Sequence[_FrameTuple], total_nframe: int | None = ...) -> None: ... else: def __init__(self, frames: Sequence[_FrameTuple]) -> None: ... - if sys.version_info >= (3, 7): - def format(self, limit: int | None = ..., most_recent_first: bool = ...) -> list[str]: ... - else: - def format(self, limit: int | None = ...) -> list[str]: ... + def format(self, limit: int | None = ..., most_recent_first: bool = ...) -> list[str]: ... @overload def __getitem__(self, index: SupportsIndex) -> Frame: ... @overload diff --git a/mypy/typeshed/stdlib/types.pyi b/mypy/typeshed/stdlib/types.pyi index ecd42dbe3ba3..1af4420e684d 100644 --- a/mypy/typeshed/stdlib/types.pyi +++ b/mypy/typeshed/stdlib/types.pyi @@ -41,17 +41,13 @@ __all__ = [ "DynamicClassAttribute", "coroutine", "BuiltinMethodType", + "ClassMethodDescriptorType", + "MethodDescriptorType", + "MethodWrapperType", + "WrapperDescriptorType", + "resolve_bases", ] -if sys.version_info >= (3, 7): - __all__ += [ - "ClassMethodDescriptorType", - "MethodDescriptorType", - "MethodWrapperType", - "WrapperDescriptorType", - "resolve_bases", - ] - if sys.version_info >= (3, 8): __all__ += ["CellType"] @@ -407,9 +403,8 @@ class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]): def cr_frame(self) -> FrameType: ... @property def cr_running(self) -> bool: ... - if sys.version_info >= (3, 7): - @property - def cr_origin(self) -> tuple[tuple[str, int, str], ...] | None: ... + @property + def cr_origin(self) -> tuple[tuple[str, int, str], ...] | None: ... if sys.version_info >= (3, 11): @property def cr_suspended(self) -> bool: ... @@ -465,62 +460,57 @@ class BuiltinFunctionType: BuiltinMethodType = BuiltinFunctionType -if sys.version_info >= (3, 7): - @final - class WrapperDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, __obj: Any, __type: type = ...) -> Any: ... +@final +class WrapperDescriptorType: + @property + def __name__(self) -> str: ... + @property + def __qualname__(self) -> str: ... + @property + def __objclass__(self) -> type: ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... + def __get__(self, __obj: Any, __type: type = ...) -> Any: ... - @final - class MethodWrapperType: - @property - def __self__(self) -> object: ... - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __eq__(self, __other: object) -> bool: ... - def __ne__(self, __other: object) -> bool: ... +@final +class MethodWrapperType: + @property + def __self__(self) -> object: ... + @property + def __name__(self) -> str: ... + @property + def __qualname__(self) -> str: ... + @property + def __objclass__(self) -> type: ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... + def __eq__(self, __other: object) -> bool: ... + def __ne__(self, __other: object) -> bool: ... - @final - class MethodDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, obj: Any, type: type = ...) -> Any: ... +@final +class MethodDescriptorType: + @property + def __name__(self) -> str: ... + @property + def __qualname__(self) -> str: ... + @property + def __objclass__(self) -> type: ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... + def __get__(self, obj: Any, type: type = ...) -> Any: ... - @final - class ClassMethodDescriptorType: - @property - def __name__(self) -> str: ... - @property - def __qualname__(self) -> str: ... - @property - def __objclass__(self) -> type: ... - def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, obj: Any, type: type = ...) -> Any: ... +@final +class ClassMethodDescriptorType: + @property + def __name__(self) -> str: ... + @property + def __qualname__(self) -> str: ... + @property + def __objclass__(self) -> type: ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... + def __get__(self, obj: Any, type: type = ...) -> Any: ... @final class TracebackType: - if sys.version_info >= (3, 7): - def __init__(self, tb_next: TracebackType | None, tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ... - tb_next: TracebackType | None - else: - @property - def tb_next(self) -> TracebackType | None: ... + def __init__(self, tb_next: TracebackType | None, tb_frame: FrameType, tb_lasti: int, tb_lineno: int) -> None: ... + tb_next: TracebackType | None # the rest are read-only even in 3.7 @property def tb_frame(self) -> FrameType: ... @@ -549,9 +539,8 @@ class FrameType: @property def f_locals(self) -> dict[str, Any]: ... f_trace: Callable[[FrameType, str, Any], Any] | None - if sys.version_info >= (3, 7): - f_trace_lines: bool - f_trace_opcodes: bool + f_trace_lines: bool + f_trace_opcodes: bool def clear(self) -> None: ... @final @@ -578,23 +567,13 @@ class MemberDescriptorType: def __set__(self, __instance: Any, __value: Any) -> None: ... def __delete__(self, __obj: Any) -> None: ... -if sys.version_info >= (3, 7): - def new_class( - name: str, - bases: Iterable[object] = ..., - kwds: dict[str, Any] | None = ..., - exec_body: Callable[[dict[str, Any]], object] | None = ..., - ) -> type: ... - def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ... - -else: - def new_class( - name: str, - bases: tuple[type, ...] = ..., - kwds: dict[str, Any] | None = ..., - exec_body: Callable[[dict[str, Any]], object] | None = ..., - ) -> type: ... - +def new_class( + name: str, + bases: Iterable[object] = ..., + kwds: dict[str, Any] | None = ..., + exec_body: Callable[[dict[str, Any]], object] | None = ..., +) -> type: ... +def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ... def prepare_class( name: str, bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ... ) -> tuple[type, dict[str, Any], dict[str, Any]]: ... diff --git a/mypy/typeshed/stdlib/typing.pyi b/mypy/typeshed/stdlib/typing.pyi index acbce5cd3a5f..980505271e66 100644 --- a/mypy/typeshed/stdlib/typing.pyi +++ b/mypy/typeshed/stdlib/typing.pyi @@ -1,13 +1,21 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986 import sys -from _typeshed import IdentityFunction, ReadableBuffer, Self as TypeshedSelf, SupportsKeysAndGetItem +from _typeshed import IdentityFunction, Incomplete, ReadableBuffer, Self as TypeshedSelf, SupportsKeysAndGetItem from abc import ABCMeta, abstractmethod -from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType +from types import ( + BuiltinFunctionType, + CodeType, + FrameType, + FunctionType, + MethodDescriptorType, + MethodType, + MethodWrapperType, + ModuleType, + TracebackType, + WrapperDescriptorType, +) from typing_extensions import Literal as _Literal, ParamSpec as _ParamSpec, final as _final -if sys.version_info >= (3, 7): - from types import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType - if sys.version_info >= (3, 9): from types import GenericAlias @@ -71,14 +79,11 @@ __all__ = [ "no_type_check", "no_type_check_decorator", "overload", + "ForwardRef", + "NoReturn", + "OrderedDict", ] -if sys.version_info < (3, 7): - __all__ += ["GenericMeta"] - -if sys.version_info >= (3, 7): - __all__ += ["ForwardRef", "NoReturn", "OrderedDict"] - if sys.version_info >= (3, 8): __all__ += [ "Final", @@ -133,6 +138,8 @@ class TypeVar: if sys.version_info >= (3, 10): def __or__(self, right: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ... + if sys.version_info >= (3, 11): + def __typing_subst__(self, arg: Incomplete) -> Incomplete: ... # Used for an undocumented mypy feature. Does not exist at runtime. _promote = object() @@ -187,9 +194,8 @@ if sys.version_info >= (3, 11): __name__: str def __init__(self, name: str) -> None: ... def __iter__(self) -> Any: ... - -if sys.version_info < (3, 7): - class GenericMeta(type): ... + def __typing_subst__(self, arg: Never) -> Never: ... + def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ... if sys.version_info >= (3, 10): class ParamSpecArgs: @@ -210,6 +216,10 @@ if sys.version_info >= (3, 10): def args(self) -> ParamSpecArgs: ... @property def kwargs(self) -> ParamSpecKwargs: ... + if sys.version_info >= (3, 11): + def __typing_subst__(self, arg: Incomplete) -> Incomplete: ... + def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ... + def __or__(self, right: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ... Concatenate: _SpecialForm @@ -255,8 +265,7 @@ Counter = _Alias() Deque = _Alias() ChainMap = _Alias() -if sys.version_info >= (3, 7): - OrderedDict = _Alias() +OrderedDict = _Alias() if sys.version_info >= (3, 9): Annotated: _SpecialForm @@ -824,22 +833,17 @@ class Pattern(Generic[AnyStr]): # Functions -if sys.version_info >= (3, 7): - _get_type_hints_obj_allowed_types = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed - object - | Callable[..., Any] - | FunctionType - | BuiltinFunctionType - | MethodType - | ModuleType - | WrapperDescriptorType - | MethodWrapperType - | MethodDescriptorType - ) -else: - _get_type_hints_obj_allowed_types = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed - object | Callable[..., Any] | FunctionType | BuiltinFunctionType | MethodType | ModuleType - ) +_get_type_hints_obj_allowed_types = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed + object + | Callable[..., Any] + | FunctionType + | BuiltinFunctionType + | MethodType + | ModuleType + | WrapperDescriptorType + | MethodWrapperType + | MethodDescriptorType +) if sys.version_info >= (3, 9): def get_type_hints( @@ -910,7 +914,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta): # can go through. def setdefault(self, k: NoReturn, default: object) -> object: ... # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. - def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore + def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse] def update(self: _T, __m: _T) -> None: ... def __delitem__(self, k: NoReturn) -> None: ... def items(self) -> ItemsView[str, object]: ... @@ -919,28 +923,27 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta): def __or__(self: TypeshedSelf, __value: TypeshedSelf) -> TypeshedSelf: ... def __ior__(self: TypeshedSelf, __value: TypeshedSelf) -> TypeshedSelf: ... -if sys.version_info >= (3, 7): - @_final - class ForwardRef: - __forward_arg__: str - __forward_code__: CodeType - __forward_evaluated__: bool - __forward_value__: Any | None - __forward_is_argument__: bool - __forward_is_class__: bool - __forward_module__: Any | None - if sys.version_info >= (3, 9): - # The module and is_class arguments were added in later Python 3.9 versions. - def __init__(self, arg: str, is_argument: bool = ..., module: Any | None = ..., *, is_class: bool = ...) -> None: ... - else: - def __init__(self, arg: str, is_argument: bool = ...) -> None: ... - - def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ... - def __eq__(self, other: object) -> bool: ... - def __hash__(self) -> int: ... - if sys.version_info >= (3, 11): - def __or__(self, other: Any) -> _SpecialForm: ... - def __ror__(self, other: Any) -> _SpecialForm: ... +@_final +class ForwardRef: + __forward_arg__: str + __forward_code__: CodeType + __forward_evaluated__: bool + __forward_value__: Any | None + __forward_is_argument__: bool + __forward_is_class__: bool + __forward_module__: Any | None + if sys.version_info >= (3, 9): + # The module and is_class arguments were added in later Python 3.9 versions. + def __init__(self, arg: str, is_argument: bool = ..., module: Any | None = ..., *, is_class: bool = ...) -> None: ... + else: + def __init__(self, arg: str, is_argument: bool = ...) -> None: ... + + def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + if sys.version_info >= (3, 11): + def __or__(self, other: Any) -> _SpecialForm: ... + def __ror__(self, other: Any) -> _SpecialForm: ... if sys.version_info >= (3, 10): def is_typeddict(tp: object) -> bool: ... diff --git a/mypy/typeshed/stdlib/typing_extensions.pyi b/mypy/typeshed/stdlib/typing_extensions.pyi index fab5900128a5..0d82ec720c25 100644 --- a/mypy/typeshed/stdlib/typing_extensions.pyi +++ b/mypy/typeshed/stdlib/typing_extensions.pyi @@ -1,6 +1,8 @@ import abc +import collections import sys from _typeshed import IdentityFunction, Self as TypeshedSelf # see #6932 for why the Self alias cannot have a leading underscore +from collections.abc import Iterable from typing import ( # noqa: Y022,Y027,Y039 TYPE_CHECKING as TYPE_CHECKING, Any, @@ -54,6 +56,7 @@ __all__ = [ "Counter", "Deque", "DefaultDict", + "NamedTuple", "OrderedDict", "TypedDict", "SupportsIndex", @@ -126,7 +129,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): # can go through. def setdefault(self, k: NoReturn, default: object) -> object: ... # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. - def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore + def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse] def update(self: _T, __m: _T) -> None: ... def items(self) -> ItemsView[str, object]: ... def keys(self) -> KeysView[str]: ... @@ -193,9 +196,11 @@ else: def is_typeddict(tp: object) -> bool: ... # New things in 3.11 +# NamedTuples are not new, but the ability to create generic NamedTuples is new in 3.11 if sys.version_info >= (3, 11): from typing import ( LiteralString as LiteralString, + NamedTuple as NamedTuple, Never as Never, NotRequired as NotRequired, Required as Required, @@ -237,3 +242,24 @@ else: field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = ..., **kwargs: object, ) -> IdentityFunction: ... + + class NamedTuple(tuple[Any, ...]): + if sys.version_info < (3, 8): + _field_types: collections.OrderedDict[str, type] + elif sys.version_info < (3, 9): + _field_types: dict[str, type] + _field_defaults: dict[str, Any] + _fields: tuple[str, ...] + _source: str + @overload + def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ... + @overload + def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ... + @classmethod + def _make(cls: type[TypeshedSelf], iterable: Iterable[Any]) -> TypeshedSelf: ... + if sys.version_info >= (3, 8): + def _asdict(self) -> dict[str, Any]: ... + else: + def _asdict(self) -> collections.OrderedDict[str, Any]: ... + + def _replace(self: TypeshedSelf, **kwargs: Any) -> TypeshedSelf: ... diff --git a/mypy/typeshed/stdlib/unittest/case.pyi b/mypy/typeshed/stdlib/unittest/case.pyi index 8892d4a5efcb..7db217077f1b 100644 --- a/mypy/typeshed/stdlib/unittest/case.pyi +++ b/mypy/typeshed/stdlib/unittest/case.pyi @@ -4,6 +4,7 @@ import unittest.result from _typeshed import Self, SupportsDunderGE, SupportsDunderGT, SupportsDunderLE, SupportsDunderLT, SupportsRSub, SupportsSub from collections.abc import Callable, Container, Iterable, Mapping, Sequence, Set as AbstractSet from contextlib import AbstractContextManager +from re import Pattern from types import TracebackType from typing import ( Any, @@ -12,7 +13,6 @@ from typing import ( Generic, NamedTuple, NoReturn, - Pattern, Protocol, SupportsAbs, SupportsRound, @@ -145,7 +145,7 @@ class TestCase: def assertRaises( # type: ignore[misc] self, expected_exception: type[BaseException] | tuple[type[BaseException], ...], - callable: Callable[..., object], + callable: Callable[..., Any], *args: Any, **kwargs: Any, ) -> None: ... diff --git a/mypy/typeshed/stdlib/unittest/loader.pyi b/mypy/typeshed/stdlib/unittest/loader.pyi index 76c60f4803f5..9ba04b084c7f 100644 --- a/mypy/typeshed/stdlib/unittest/loader.pyi +++ b/mypy/typeshed/stdlib/unittest/loader.pyi @@ -1,10 +1,9 @@ -import sys import unittest.case -import unittest.result import unittest.suite from collections.abc import Callable, Sequence +from re import Pattern from types import ModuleType -from typing import Any, Pattern +from typing import Any from typing_extensions import TypeAlias _SortComparisonMethod: TypeAlias = Callable[[str, str], int] @@ -16,10 +15,7 @@ class TestLoader: errors: list[type[BaseException]] testMethodPrefix: str sortTestMethodsUsing: _SortComparisonMethod - - if sys.version_info >= (3, 7): - testNamePatterns: list[str] | None - + testNamePatterns: list[str] | None suiteClass: _SuiteClass def loadTestsFromTestCase(self, testCaseClass: type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ... def loadTestsFromModule(self, module: ModuleType, *args: Any, pattern: Any = ...) -> unittest.suite.TestSuite: ... @@ -30,19 +26,12 @@ class TestLoader: defaultTestLoader: TestLoader -if sys.version_info >= (3, 7): - def getTestCaseNames( - testCaseClass: type[unittest.case.TestCase], - prefix: str, - sortUsing: _SortComparisonMethod = ..., - testNamePatterns: list[str] | None = ..., - ) -> Sequence[str]: ... - -else: - def getTestCaseNames( - testCaseClass: type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ... - ) -> Sequence[str]: ... - +def getTestCaseNames( + testCaseClass: type[unittest.case.TestCase], + prefix: str, + sortUsing: _SortComparisonMethod = ..., + testNamePatterns: list[str] | None = ..., +) -> Sequence[str]: ... def makeSuite( testCaseClass: type[unittest.case.TestCase], prefix: str = ..., diff --git a/mypy/typeshed/stdlib/unittest/main.pyi b/mypy/typeshed/stdlib/unittest/main.pyi index 31853676b011..915d559cce5b 100644 --- a/mypy/typeshed/stdlib/unittest/main.pyi +++ b/mypy/typeshed/stdlib/unittest/main.pyi @@ -1,4 +1,3 @@ -import sys import unittest.case import unittest.loader import unittest.result @@ -23,9 +22,7 @@ class TestProgram: buffer: bool | None progName: str | None warnings: str | None - - if sys.version_info >= (3, 7): - testNamePatterns: list[str] | None + testNamePatterns: list[str] | None def __init__( self, module: None | str | ModuleType = ..., @@ -44,11 +41,7 @@ class TestProgram: ) -> None: ... def usageExit(self, msg: Any = ...) -> None: ... def parseArgs(self, argv: list[str]) -> None: ... - if sys.version_info >= (3, 7): - def createTests(self, from_discovery: bool = ..., Loader: unittest.loader.TestLoader | None = ...) -> None: ... - else: - def createTests(self) -> None: ... - + def createTests(self, from_discovery: bool = ..., Loader: unittest.loader.TestLoader | None = ...) -> None: ... def runTests(self) -> None: ... # undocumented main = TestProgram diff --git a/mypy/typeshed/stdlib/unittest/mock.pyi b/mypy/typeshed/stdlib/unittest/mock.pyi index d4e9e832c929..4aa67f4995cd 100644 --- a/mypy/typeshed/stdlib/unittest/mock.pyi +++ b/mypy/typeshed/stdlib/unittest/mock.pyi @@ -28,23 +28,6 @@ if sys.version_info >= (3, 8): "PropertyMock", "seal", ) -elif sys.version_info >= (3, 7): - __all__ = ( - "Mock", - "MagicMock", - "patch", - "sentinel", - "DEFAULT", - "ANY", - "call", - "create_autospec", - "FILTER_DIR", - "NonCallableMock", - "NonCallableMagicMock", - "mock_open", - "PropertyMock", - "seal", - ) else: __all__ = ( "Mock", @@ -60,7 +43,9 @@ else: "NonCallableMagicMock", "mock_open", "PropertyMock", + "seal", ) + __version__: str FILTER_DIR: Any @@ -155,10 +140,8 @@ class NonCallableMock(Base, Any): def assert_called_once(_mock_self) -> None: ... def reset_mock(self, visited: Any = ..., *, return_value: bool = ..., side_effect: bool = ...) -> None: ... - if sys.version_info >= (3, 7): - def _extract_mock_name(self) -> str: ... - def _get_call_signature_from_name(self, name: str) -> Any: ... - + def _extract_mock_name(self) -> str: ... + def _get_call_signature_from_name(self, name: str) -> Any: ... def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ... def assert_has_calls(self, calls: Sequence[_Call], any_order: bool = ...) -> None: ... def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ... @@ -446,5 +429,4 @@ class PropertyMock(Mock): def __set__(self, obj: Any, value: Any) -> None: ... -if sys.version_info >= (3, 7): - def seal(mock: Any) -> None: ... +def seal(mock: Any) -> None: ... diff --git a/mypy/typeshed/stdlib/urllib/parse.pyi b/mypy/typeshed/stdlib/urllib/parse.pyi index 49f3825e0821..7e1ec903a15e 100644 --- a/mypy/typeshed/stdlib/urllib/parse.pyi +++ b/mypy/typeshed/stdlib/urllib/parse.pyi @@ -66,7 +66,9 @@ class _NetlocResultMixinBase(Generic[AnyStr]): class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ... class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ... -class _DefragResultBase(tuple[Any, ...], Generic[AnyStr]): +# Ideally this would be a generic fixed-length tuple, +# but mypy doesn't support that yet: https://github.com/python/mypy/issues/685#issuecomment-992014179 +class _DefragResultBase(tuple[AnyStr, ...], Generic[AnyStr]): if sys.version_info >= (3, 10): __match_args__ = ("url", "fragment") @property diff --git a/mypy/typeshed/stdlib/urllib/request.pyi b/mypy/typeshed/stdlib/urllib/request.pyi index c44e5cf7043c..0ad10a218680 100644 --- a/mypy/typeshed/stdlib/urllib/request.pyi +++ b/mypy/typeshed/stdlib/urllib/request.pyi @@ -5,7 +5,8 @@ from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequenc from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar -from typing import IO, Any, ClassVar, NoReturn, Pattern, TypeVar, overload +from re import Pattern +from typing import IO, Any, ClassVar, NoReturn, TypeVar, overload from typing_extensions import TypeAlias from urllib.error import HTTPError as HTTPError from urllib.response import addclosehook, addinfourl diff --git a/mypy/typeshed/stdlib/uu.pyi b/mypy/typeshed/stdlib/uu.pyi index 4ebb12be8858..95a7f3dfa9e2 100644 --- a/mypy/typeshed/stdlib/uu.pyi +++ b/mypy/typeshed/stdlib/uu.pyi @@ -1,4 +1,3 @@ -import sys from typing import BinaryIO from typing_extensions import TypeAlias @@ -8,12 +7,5 @@ _File: TypeAlias = str | BinaryIO class Error(Exception): ... -if sys.version_info >= (3, 7): - def encode( - in_file: _File, out_file: _File, name: str | None = ..., mode: int | None = ..., *, backtick: bool = ... - ) -> None: ... - -else: - def encode(in_file: _File, out_file: _File, name: str | None = ..., mode: int | None = ...) -> None: ... - +def encode(in_file: _File, out_file: _File, name: str | None = ..., mode: int | None = ..., *, backtick: bool = ...) -> None: ... def decode(in_file: _File, out_file: _File | None = ..., mode: int | None = ..., quiet: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/uuid.pyi b/mypy/typeshed/stdlib/uuid.pyi index fd7f1334e52a..3d9b89a0b9f7 100644 --- a/mypy/typeshed/stdlib/uuid.pyi +++ b/mypy/typeshed/stdlib/uuid.pyi @@ -1,4 +1,4 @@ -import sys +from enum import Enum from typing_extensions import TypeAlias # Because UUID has properties called int and bytes we need to rename these temporarily. @@ -6,40 +6,25 @@ _Int: TypeAlias = int _Bytes: TypeAlias = bytes _FieldsType: TypeAlias = tuple[int, int, int, int, int, int] -if sys.version_info >= (3, 7): - from enum import Enum - - class SafeUUID(Enum): - safe: int - unsafe: int - unknown: None +class SafeUUID(Enum): + safe: int + unsafe: int + unknown: None class UUID: - if sys.version_info >= (3, 7): - def __init__( - self, - hex: str | None = ..., - bytes: _Bytes | None = ..., - bytes_le: _Bytes | None = ..., - fields: _FieldsType | None = ..., - int: _Int | None = ..., - version: _Int | None = ..., - *, - is_safe: SafeUUID = ..., - ) -> None: ... - @property - def is_safe(self) -> SafeUUID: ... - else: - def __init__( - self, - hex: str | None = ..., - bytes: _Bytes | None = ..., - bytes_le: _Bytes | None = ..., - fields: _FieldsType | None = ..., - int: _Int | None = ..., - version: _Int | None = ..., - ) -> None: ... - + def __init__( + self, + hex: str | None = ..., + bytes: _Bytes | None = ..., + bytes_le: _Bytes | None = ..., + fields: _FieldsType | None = ..., + int: _Int | None = ..., + version: _Int | None = ..., + *, + is_safe: SafeUUID = ..., + ) -> None: ... + @property + def is_safe(self) -> SafeUUID: ... @property def bytes(self) -> _Bytes: ... @property diff --git a/mypy/typeshed/stdlib/wave.pyi b/mypy/typeshed/stdlib/wave.pyi index 689282f69ee7..853a26a9469e 100644 --- a/mypy/typeshed/stdlib/wave.pyi +++ b/mypy/typeshed/stdlib/wave.pyi @@ -57,7 +57,7 @@ class Wave_write: def setcomptype(self, comptype: str, compname: str) -> None: ... def getcomptype(self) -> str: ... def getcompname(self) -> str: ... - def setparams(self, params: _wave_params) -> None: ... + def setparams(self, params: _wave_params | tuple[int, int, int, int, str, str]) -> None: ... def getparams(self) -> _wave_params: ... def setmark(self, id: Any, pos: Any, name: Any) -> NoReturn: ... def getmark(self, id: Any) -> NoReturn: ... diff --git a/mypy/typeshed/stdlib/weakref.pyi b/mypy/typeshed/stdlib/weakref.pyi index 03dd89c8e210..af960391e85d 100644 --- a/mypy/typeshed/stdlib/weakref.pyi +++ b/mypy/typeshed/stdlib/weakref.pyi @@ -88,7 +88,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): class KeyedRef(ref[_T], Generic[_KT, _T]): key: _KT # This __new__ method uses a non-standard name for the "cls" parameter - def __new__(type: type[Self], ob: _T, callback: Callable[[_T], Any], key: _KT) -> Self: ... # type: ignore + def __new__(type: type[Self], ob: _T, callback: Callable[[_T], Any], key: _KT) -> Self: ... def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ... class WeakKeyDictionary(MutableMapping[_KT, _VT]): diff --git a/mypy/typeshed/stdlib/webbrowser.pyi b/mypy/typeshed/stdlib/webbrowser.pyi index a5b04a262596..8cf8935ffaad 100644 --- a/mypy/typeshed/stdlib/webbrowser.pyi +++ b/mypy/typeshed/stdlib/webbrowser.pyi @@ -7,16 +7,9 @@ __all__ = ["Error", "open", "open_new", "open_new_tab", "get", "register"] class Error(Exception): ... -if sys.version_info >= (3, 7): - def register( - name: str, klass: Callable[[], BaseBrowser] | None, instance: BaseBrowser | None = ..., *, preferred: bool = ... - ) -> None: ... - -else: - def register( - name: str, klass: Callable[[], BaseBrowser] | None, instance: BaseBrowser | None = ..., update_tryorder: int = ... - ) -> None: ... - +def register( + name: str, klass: Callable[[], BaseBrowser] | None, instance: BaseBrowser | None = ..., *, preferred: bool = ... +) -> None: ... def get(using: str | None = ...) -> BaseBrowser: ... def open(url: str, new: int = ..., autoraise: bool = ...) -> bool: ... def open_new(url: str) -> bool: ... diff --git a/mypy/typeshed/stdlib/wsgiref/headers.pyi b/mypy/typeshed/stdlib/wsgiref/headers.pyi index cde0227a7830..dd963d9b4727 100644 --- a/mypy/typeshed/stdlib/wsgiref/headers.pyi +++ b/mypy/typeshed/stdlib/wsgiref/headers.pyi @@ -1,4 +1,5 @@ -from typing import Pattern, overload +from re import Pattern +from typing import overload from typing_extensions import TypeAlias _HeaderList: TypeAlias = list[tuple[str, str]] diff --git a/mypy/typeshed/stdlib/wsgiref/types.pyi b/mypy/typeshed/stdlib/wsgiref/types.pyi index b8ece8d57a9d..4e8f47264f3a 100644 --- a/mypy/typeshed/stdlib/wsgiref/types.pyi +++ b/mypy/typeshed/stdlib/wsgiref/types.pyi @@ -1,4 +1,4 @@ -from collections.abc import Callable, Iterable +from collections.abc import Callable, Iterable, Iterator from sys import _OptExcInfo from typing import Any, Protocol from typing_extensions import TypeAlias @@ -17,7 +17,7 @@ class InputStream(Protocol): def read(self, __size: int = ...) -> bytes: ... def readline(self, __size: int = ...) -> bytes: ... def readlines(self, __hint: int = ...) -> list[bytes]: ... - def __iter__(self) -> Iterable[bytes]: ... + def __iter__(self) -> Iterator[bytes]: ... class ErrorStream(Protocol): def flush(self) -> object: ... diff --git a/mypy/typeshed/stdlib/wsgiref/validate.pyi b/mypy/typeshed/stdlib/wsgiref/validate.pyi index ada2283a6af0..fa8a6bbb8d03 100644 --- a/mypy/typeshed/stdlib/wsgiref/validate.pyi +++ b/mypy/typeshed/stdlib/wsgiref/validate.pyi @@ -1,6 +1,7 @@ from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication from collections.abc import Callable, Iterable, Iterator from typing import Any, NoReturn +from typing_extensions import TypeAlias __all__ = ["validator"] @@ -14,7 +15,7 @@ class InputWrapper: def read(self, size: int) -> bytes: ... def readline(self, size: int = ...) -> bytes: ... def readlines(self, hint: int = ...) -> bytes: ... - def __iter__(self) -> Iterable[bytes]: ... + def __iter__(self) -> Iterator[bytes]: ... def close(self) -> NoReturn: ... class ErrorWrapper: @@ -25,9 +26,11 @@ class ErrorWrapper: def writelines(self, seq: Iterable[str]) -> None: ... def close(self) -> NoReturn: ... +_WriterCallback: TypeAlias = Callable[[bytes], Any] + class WriteWrapper: - writer: Callable[[bytes], Any] - def __init__(self, wsgi_writer: Callable[[bytes], Any]) -> None: ... + writer: _WriterCallback + def __init__(self, wsgi_writer: _WriterCallback) -> None: ... def __call__(self, s: bytes) -> None: ... class PartialIteratorWrapper: diff --git a/mypy/typeshed/stdlib/xml/dom/minidom.pyi b/mypy/typeshed/stdlib/xml/dom/minidom.pyi index d8bcc299b991..92da20832fd6 100644 --- a/mypy/typeshed/stdlib/xml/dom/minidom.pyi +++ b/mypy/typeshed/stdlib/xml/dom/minidom.pyi @@ -127,21 +127,21 @@ class Element(Node): self, tagName, namespaceURI: str | None = ..., prefix: Any | None = ..., localName: Any | None = ... ) -> None: ... def unlink(self) -> None: ... - def getAttribute(self, attname): ... + def getAttribute(self, attname: str) -> str: ... def getAttributeNS(self, namespaceURI: str, localName): ... - def setAttribute(self, attname, value) -> None: ... + def setAttribute(self, attname: str, value: str) -> None: ... def setAttributeNS(self, namespaceURI: str, qualifiedName: str, value) -> None: ... - def getAttributeNode(self, attrname): ... + def getAttributeNode(self, attrname: str): ... def getAttributeNodeNS(self, namespaceURI: str, localName): ... def setAttributeNode(self, attr): ... setAttributeNodeNS: Any - def removeAttribute(self, name) -> None: ... + def removeAttribute(self, name: str) -> None: ... def removeAttributeNS(self, namespaceURI: str, localName) -> None: ... def removeAttributeNode(self, node): ... removeAttributeNodeNS: Any def hasAttribute(self, name: str) -> bool: ... def hasAttributeNS(self, namespaceURI: str, localName) -> bool: ... - def getElementsByTagName(self, name): ... + def getElementsByTagName(self, name: str): ... def getElementsByTagNameNS(self, namespaceURI: str, localName): ... def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... def hasAttributes(self) -> bool: ... diff --git a/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi b/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi index 1f652050e4fd..94ce933582dd 100644 --- a/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi +++ b/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi @@ -1,24 +1,25 @@ from collections.abc import Callable, Generator -from typing import Pattern, TypeVar +from re import Pattern +from typing import TypeVar from typing_extensions import TypeAlias from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] -_token: TypeAlias = tuple[str, str] -_Next: TypeAlias = Callable[[], _token] +_Token: TypeAlias = tuple[str, str] +_Next: TypeAlias = Callable[[], _Token] _Callback: TypeAlias = Callable[[_SelectorContext, list[Element]], Generator[Element, None, None]] -def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = ...) -> Generator[_token, None, None]: ... +def xpath_tokenizer(pattern: str, namespaces: dict[str, str] | None = ...) -> Generator[_Token, None, None]: ... def get_parent_map(context: _SelectorContext) -> dict[Element, Element]: ... -def prepare_child(next: _Next, token: _token) -> _Callback: ... -def prepare_star(next: _Next, token: _token) -> _Callback: ... -def prepare_self(next: _Next, token: _token) -> _Callback: ... -def prepare_descendant(next: _Next, token: _token) -> _Callback: ... -def prepare_parent(next: _Next, token: _token) -> _Callback: ... -def prepare_predicate(next: _Next, token: _token) -> _Callback: ... +def prepare_child(next: _Next, token: _Token) -> _Callback: ... +def prepare_star(next: _Next, token: _Token) -> _Callback: ... +def prepare_self(next: _Next, token: _Token) -> _Callback: ... +def prepare_descendant(next: _Next, token: _Token) -> _Callback: ... +def prepare_parent(next: _Next, token: _Token) -> _Callback: ... +def prepare_predicate(next: _Next, token: _Token) -> _Callback: ... -ops: dict[str, Callable[[_Next, _token], _Callback]] +ops: dict[str, Callable[[_Next, _Token], _Callback]] class _SelectorContext: parent_map: dict[Element, Element] | None diff --git a/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi b/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi index 82cd735bd829..84059bc21a87 100644 --- a/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +++ b/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi @@ -325,7 +325,7 @@ if sys.version_info >= (3, 8): class C14NWriterTarget: def __init__( self, - write: Callable[[str], Any], + write: Callable[[str], object], *, with_comments: bool = ..., strip_text: bool = ..., diff --git a/mypy/typeshed/stdlib/xmlrpc/server.pyi b/mypy/typeshed/stdlib/xmlrpc/server.pyi index 237620f70250..e4fc300343bf 100644 --- a/mypy/typeshed/stdlib/xmlrpc/server.pyi +++ b/mypy/typeshed/stdlib/xmlrpc/server.pyi @@ -1,10 +1,10 @@ import http.server import pydoc import socketserver -import sys from collections.abc import Callable, Iterable, Mapping from datetime import datetime -from typing import Any, ClassVar, Pattern, Protocol +from re import Pattern +from typing import Any, ClassVar, Protocol from typing_extensions import TypeAlias from xmlrpc.client import Fault @@ -48,11 +48,7 @@ class SimpleXMLRPCDispatcher: # undocumented use_builtin_types: bool def __init__(self, allow_none: bool = ..., encoding: str | None = ..., use_builtin_types: bool = ...) -> None: ... def register_instance(self, instance: Any, allow_dotted_names: bool = ...) -> None: ... - if sys.version_info >= (3, 7): - def register_function(self, function: _DispatchProtocol | None = ..., name: str | None = ...) -> Callable[..., Any]: ... - else: - def register_function(self, function: _DispatchProtocol, name: str | None = ...) -> Callable[..., Any]: ... - + def register_function(self, function: _DispatchProtocol | None = ..., name: str | None = ...) -> Callable[..., Any]: ... def register_introspection_functions(self) -> None: ... def register_multicall_functions(self) -> None: ... def _marshaled_dispatch( diff --git a/mypy/typeshed/stdlib/zipapp.pyi b/mypy/typeshed/stdlib/zipapp.pyi index d42640141620..3363161c3c6f 100644 --- a/mypy/typeshed/stdlib/zipapp.pyi +++ b/mypy/typeshed/stdlib/zipapp.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Callable from pathlib import Path from typing import BinaryIO @@ -10,19 +9,12 @@ _Path: TypeAlias = str | Path | BinaryIO class ZipAppError(ValueError): ... -if sys.version_info >= (3, 7): - def create_archive( - source: _Path, - target: _Path | None = ..., - interpreter: str | None = ..., - main: str | None = ..., - filter: Callable[[Path], bool] | None = ..., - compressed: bool = ..., - ) -> None: ... - -else: - def create_archive( - source: _Path, target: _Path | None = ..., interpreter: str | None = ..., main: str | None = ... - ) -> None: ... - +def create_archive( + source: _Path, + target: _Path | None = ..., + interpreter: str | None = ..., + main: str | None = ..., + filter: Callable[[Path], bool] | None = ..., + compressed: bool = ..., +) -> None: ... def get_interpreter(archive: _Path) -> str: ... diff --git a/mypy/typeshed/stdlib/zipfile.pyi b/mypy/typeshed/stdlib/zipfile.pyi index c799cf9b4e12..da1710787252 100644 --- a/mypy/typeshed/stdlib/zipfile.pyi +++ b/mypy/typeshed/stdlib/zipfile.pyi @@ -1,7 +1,7 @@ import io import sys from _typeshed import Self, StrOrBytesPath, StrPath -from collections.abc import Callable, Iterable, Iterator, Sequence +from collections.abc import Callable, Iterable, Iterator from os import PathLike from types import TracebackType from typing import IO, Any, Protocol, overload @@ -56,78 +56,38 @@ class _ClosableZipStream(_ZipStream, Protocol): class ZipExtFile(io.BufferedIOBase): MAX_N: int MIN_READ_SIZE: int - - if sys.version_info >= (3, 7): - MAX_SEEK_READ: int - + MAX_SEEK_READ: int newlines: list[bytes] | None mode: _ReadWriteMode name: str - if sys.version_info >= (3, 7): - @overload - def __init__( - self, - fileobj: _ClosableZipStream, - mode: _ReadWriteMode, - zipinfo: ZipInfo, - pwd: bytes | None, - close_fileobj: Literal[True], - ) -> None: ... - @overload - def __init__( - self, - fileobj: _ClosableZipStream, - mode: _ReadWriteMode, - zipinfo: ZipInfo, - pwd: bytes | None = ..., - *, - close_fileobj: Literal[True], - ) -> None: ... - @overload - def __init__( - self, - fileobj: _ZipStream, - mode: _ReadWriteMode, - zipinfo: ZipInfo, - pwd: bytes | None = ..., - close_fileobj: Literal[False] = ..., - ) -> None: ... - else: - @overload - def __init__( - self, - fileobj: _ClosableZipStream, - mode: _ReadWriteMode, - zipinfo: ZipInfo, - decrypter: Callable[[Sequence[int]], bytes] | None, - close_fileobj: Literal[True], - ) -> None: ... - @overload - def __init__( - self, - fileobj: _ClosableZipStream, - mode: _ReadWriteMode, - zipinfo: ZipInfo, - decrypter: Callable[[Sequence[int]], bytes] | None = ..., - *, - close_fileobj: Literal[True], - ) -> None: ... - @overload - def __init__( - self, - fileobj: _ZipStream, - mode: _ReadWriteMode, - zipinfo: ZipInfo, - decrypter: Callable[[Sequence[int]], bytes] | None = ..., - close_fileobj: Literal[False] = ..., - ) -> None: ... - + @overload + def __init__( + self, fileobj: _ClosableZipStream, mode: _ReadWriteMode, zipinfo: ZipInfo, pwd: bytes | None, close_fileobj: Literal[True] + ) -> None: ... + @overload + def __init__( + self, + fileobj: _ClosableZipStream, + mode: _ReadWriteMode, + zipinfo: ZipInfo, + pwd: bytes | None = ..., + *, + close_fileobj: Literal[True], + ) -> None: ... + @overload + def __init__( + self, + fileobj: _ZipStream, + mode: _ReadWriteMode, + zipinfo: ZipInfo, + pwd: bytes | None = ..., + close_fileobj: Literal[False] = ..., + ) -> None: ... def read(self, n: int | None = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... # type: ignore[override] def peek(self, n: int = ...) -> bytes: ... def read1(self, n: int | None) -> bytes: ... # type: ignore[override] - if sys.version_info >= (3, 7): - def seek(self, offset: int, whence: int = ...) -> int: ... + def seek(self, offset: int, whence: int = ...) -> int: ... class _Writer(Protocol): def write(self, __s: str) -> object: ... @@ -180,7 +140,7 @@ class ZipFile: *, strict_timestamps: bool = ..., ) -> None: ... - elif sys.version_info >= (3, 7): + else: def __init__( self, file: StrPath | IO[bytes], @@ -189,10 +149,6 @@ class ZipFile: allowZip64: bool = ..., compresslevel: int | None = ..., ) -> None: ... - else: - def __init__( - self, file: StrPath | IO[bytes], mode: _ZipFileMode = ..., compression: int = ..., allowZip64: bool = ... - ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( @@ -213,26 +169,12 @@ class ZipFile: def setpassword(self, pwd: bytes) -> None: ... def read(self, name: str | ZipInfo, pwd: bytes | None = ...) -> bytes: ... def testzip(self) -> str | None: ... - if sys.version_info >= (3, 7): - def write( - self, - filename: StrPath, - arcname: StrPath | None = ..., - compress_type: int | None = ..., - compresslevel: int | None = ..., - ) -> None: ... - else: - def write(self, filename: StrPath, arcname: StrPath | None = ..., compress_type: int | None = ...) -> None: ... - if sys.version_info >= (3, 7): - def writestr( - self, - zinfo_or_arcname: str | ZipInfo, - data: bytes | str, - compress_type: int | None = ..., - compresslevel: int | None = ..., - ) -> None: ... - else: - def writestr(self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: int | None = ...) -> None: ... + def write( + self, filename: StrPath, arcname: StrPath | None = ..., compress_type: int | None = ..., compresslevel: int | None = ... + ) -> None: ... + def writestr( + self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: int | None = ..., compresslevel: int | None = ... + ) -> None: ... if sys.version_info >= (3, 11): def mkdir(self, zinfo_or_directory_name: str | ZipInfo, mode: int = ...) -> None: ... diff --git a/mypy/typeshed/stdlib/zipimport.pyi b/mypy/typeshed/stdlib/zipimport.pyi index a0e6d9e258dc..db06544138ca 100644 --- a/mypy/typeshed/stdlib/zipimport.pyi +++ b/mypy/typeshed/stdlib/zipimport.pyi @@ -1,12 +1,10 @@ import os import sys +from importlib.abc import ResourceReader from importlib.machinery import ModuleSpec from types import CodeType, ModuleType from typing import Any -if sys.version_info >= (3, 7): - from importlib.abc import ResourceReader - if sys.version_info >= (3, 8): __all__ = ["ZipImportError", "zipimporter"] @@ -21,9 +19,7 @@ class zipimporter: def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> str: ... def get_filename(self, fullname: str) -> str: ... - if sys.version_info >= (3, 7): - def get_resource_reader(self, fullname: str) -> ResourceReader | None: ... # undocumented - + def get_resource_reader(self, fullname: str) -> ResourceReader | None: ... # undocumented def get_source(self, fullname: str) -> str | None: ... def is_package(self, fullname: str) -> bool: ... def load_module(self, fullname: str) -> ModuleType: ... diff --git a/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi b/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi index bf8d72ba8393..85c828e8a8a8 100644 --- a/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi +++ b/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi @@ -13,7 +13,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): # can go through. def setdefault(self, k: NoReturn, default: object) -> object: ... # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. - def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore + def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse] def update(self: Self, __m: Self) -> None: ... def items(self) -> ItemsView[str, object]: ... def keys(self) -> KeysView[str]: ... diff --git a/test-data/unit/pythoneval-asyncio.test b/test-data/unit/pythoneval-asyncio.test index 97dd9d4f0a55..556414cf3252 100644 --- a/test-data/unit/pythoneval-asyncio.test +++ b/test-data/unit/pythoneval-asyncio.test @@ -364,7 +364,7 @@ try: finally: loop.close() [out] -_program.py:17: error: Argument 1 to "add_done_callback" of "Future" has incompatible type "Callable[[Future[int]], None]"; expected "Callable[[Future[str]], Any]" +_program.py:17: error: Argument 1 to "add_done_callback" of "Future" has incompatible type "Callable[[Future[int]], None]"; expected "Callable[[Future[str]], object]" [case testErrorOneMoreFutureInReturnType] import typing diff --git a/test-data/unit/pythoneval.test b/test-data/unit/pythoneval.test index d3c6cfb31d6d..a79e8743fb97 100644 --- a/test-data/unit/pythoneval.test +++ b/test-data/unit/pythoneval.test @@ -652,7 +652,10 @@ x = range(3) a = list(map(str, x)) a + 1 [out] -_program.py:4: error: Unsupported operand types for + ("List[str]" and "int") +_testMapStr.py:4: error: No overload variant of "__add__" of "list" matches argument type "int" +_testMapStr.py:4: note: Possible overload variants: +_testMapStr.py:4: note: def __add__(self, List[str]) -> List[str] +_testMapStr.py:4: note: def [_S] __add__(self, List[_S]) -> List[Union[_S, str]] [case testRelativeImport] import typing