From baa5dbe29c33658ba21d0de8aac9afbe133c3231 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 15 May 2021 00:00:38 +0300 Subject: [PATCH 1/6] run script --- stdlib/@python2/__future__.pyi | 9 - stdlib/@python2/_bisect.pyi | 33 +- stdlib/@python2/_codecs.pyi | 22 +- stdlib/@python2/_csv.pyi | 13 +- stdlib/@python2/_curses.pyi | 28 +- stdlib/@python2/_dummy_threading.pyi | 113 ++----- stdlib/@python2/_heapq.pyi | 5 +- stdlib/@python2/_random.pyi | 3 +- stdlib/@python2/_thread.pyi | 12 - stdlib/@python2/_typeshed/__init__.pyi | 41 +-- stdlib/@python2/_typeshed/tkinter.pyi | 4 - stdlib/@python2/_warnings.pyi | 87 ++--- stdlib/@python2/_weakref.pyi | 8 - stdlib/@python2/_weakrefset.pyi | 5 - stdlib/@python2/aifc.pyi | 23 +- stdlib/@python2/antigravity.pyi | 2 - stdlib/@python2/argparse.pyi | 138 ++------ stdlib/@python2/array.pyi | 30 +- stdlib/@python2/asynchat.pyi | 15 +- stdlib/@python2/asyncore.pyi | 59 ++-- stdlib/@python2/base64.pyi | 27 +- stdlib/@python2/binascii.pyi | 30 +- stdlib/@python2/bz2.pyi | 51 +-- stdlib/@python2/cProfile.pyi | 4 - stdlib/@python2/calendar.pyi | 28 +- stdlib/@python2/cmath.pyi | 12 - stdlib/@python2/code.pyi | 20 +- stdlib/@python2/codecs.pyi | 10 +- stdlib/@python2/contextlib.pyi | 96 +----- stdlib/@python2/crypt.pyi | 20 +- stdlib/@python2/csv.pyi | 25 +- stdlib/@python2/ctypes/__init__.pyi | 38 +-- stdlib/@python2/datetime.pyi | 276 ++++------------ stdlib/@python2/decimal.pyi | 195 +++-------- stdlib/@python2/difflib.pyi | 63 +--- stdlib/@python2/dis.pyi | 54 +-- stdlib/@python2/doctest.pyi | 9 +- stdlib/@python2/ensurepip/__init__.pyi | 28 +- stdlib/@python2/filecmp.pyi | 46 +-- stdlib/@python2/fileinput.pyi | 65 +--- stdlib/@python2/fractions.pyi | 56 ++-- stdlib/@python2/ftplib.pyi | 54 +-- stdlib/@python2/genericpath.pyi | 4 - stdlib/@python2/hmac.pyi | 15 - stdlib/@python2/imaplib.pyi | 36 +- stdlib/@python2/imghdr.pyi | 5 +- stdlib/@python2/ipaddress.pyi | 3 - stdlib/@python2/keyword.pyi | 3 - stdlib/@python2/lib2to3/pgen2/token.pyi | 7 - stdlib/@python2/lib2to3/pytree.pyi | 5 +- stdlib/@python2/linecache.pyi | 2 - stdlib/@python2/locale.pyi | 14 +- stdlib/@python2/macpath.pyi | 53 +-- stdlib/@python2/mailbox.pyi | 9 - stdlib/@python2/math.pyi | 65 +--- stdlib/@python2/mimetypes.pyi | 7 +- stdlib/@python2/mmap.pyi | 83 +---- stdlib/@python2/modulefinder.pyi | 25 +- stdlib/@python2/msilib/__init__.pyi | 3 +- stdlib/@python2/nntplib.pyi | 5 +- stdlib/@python2/numbers.pyi | 36 +- stdlib/@python2/opcode.pyi | 5 - stdlib/@python2/operator.pyi | 58 ++-- stdlib/@python2/optparse.pyi | 8 +- stdlib/@python2/os/__init__.pyi | 63 +--- stdlib/@python2/pdb.pyi | 163 +++------ stdlib/@python2/pickle.pyi | 78 ----- stdlib/@python2/pickletools.pyi | 63 +--- stdlib/@python2/pkgutil.pyi | 20 +- stdlib/@python2/plistlib.pyi | 60 +--- stdlib/@python2/poplib.pyi | 34 +- stdlib/@python2/pprint.pyi | 50 --- stdlib/@python2/pstats.pyi | 13 - stdlib/@python2/pty.pyi | 6 +- stdlib/@python2/py_compile.pyi | 19 -- stdlib/@python2/pyclbr.pyi | 18 +- stdlib/@python2/pydoc.pyi | 14 +- stdlib/@python2/pyexpat/errors.pyi | 4 - stdlib/@python2/queue.pyi | 17 - stdlib/@python2/readline.pyi | 6 - stdlib/@python2/rlcompleter.pyi | 5 +- stdlib/@python2/sched.pyi | 28 +- stdlib/@python2/select.pyi | 29 +- stdlib/@python2/shutil.pyi | 95 +----- stdlib/@python2/smtpd.pyi | 53 +-- stdlib/@python2/sndhdr.pyi | 11 +- stdlib/@python2/socket.pyi | 218 +----------- stdlib/@python2/socketserver.pyi | 4 - stdlib/@python2/sqlite3/dbapi2.pyi | 182 ++++------ stdlib/@python2/sre_compile.pyi | 13 +- stdlib/@python2/ssl.pyi | 329 ++++--------------- stdlib/@python2/struct.pyi | 18 +- stdlib/@python2/sunau.pyi | 21 +- stdlib/@python2/symtable.pyi | 12 +- stdlib/@python2/tarfile.pyi | 66 +--- stdlib/@python2/telnetlib.pyi | 3 - stdlib/@python2/threading.pyi | 113 ++----- stdlib/@python2/time.pyi | 84 +---- stdlib/@python2/timeit.pyi | 32 +- stdlib/@python2/token.pyi | 25 +- stdlib/@python2/traceback.pyi | 150 +-------- stdlib/@python2/turtle.pyi | 62 +--- stdlib/@python2/typing_extensions.pyi | 77 ++--- stdlib/@python2/unicodedata.pyi | 3 - stdlib/@python2/uu.pyi | 8 +- stdlib/@python2/uuid.pyi | 79 ++--- stdlib/@python2/warnings.pyi | 31 +- stdlib/@python2/wave.pyi | 21 +- stdlib/@python2/weakref.pyi | 60 +--- stdlib/@python2/webbrowser.pyi | 12 +- stdlib/@python2/wsgiref/handlers.pyi | 3 - stdlib/@python2/wsgiref/headers.pyi | 10 +- stdlib/@python2/wsgiref/simple_server.pyi | 5 +- stdlib/@python2/wsgiref/util.pyi | 5 +- stdlib/@python2/wsgiref/validate.pyi | 13 +- stdlib/@python2/xml/dom/minidom.pyi | 27 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 11 +- stdlib/@python2/xml/etree/ElementTree.pyi | 177 +--------- stdlib/@python2/xml/sax/__init__.pyi | 6 +- stdlib/@python2/xml/sax/saxutils.pyi | 18 +- stdlib/@python2/zipfile.pyi | 117 +------ stdlib/@python2/zipimport.pyi | 14 +- stdlib/@python2/zlib.pyi | 29 +- 123 files changed, 925 insertions(+), 4290 deletions(-) diff --git a/stdlib/@python2/__future__.pyi b/stdlib/@python2/__future__.pyi index 8a5035271eec..8f5ff06ac080 100644 --- a/stdlib/@python2/__future__.pyi +++ b/stdlib/@python2/__future__.pyi @@ -14,13 +14,4 @@ nested_scopes: _Feature print_function: _Feature unicode_literals: _Feature with_statement: _Feature -if sys.version_info >= (3, 0): - barry_as_FLUFL: _Feature - -if sys.version_info >= (3, 5): - generator_stop: _Feature - -if sys.version_info >= (3, 7): - annotations: _Feature - all_feature_names: List[str] # undocumented diff --git a/stdlib/@python2/_bisect.pyi b/stdlib/@python2/_bisect.pyi index 3ca863a2e939..80a0bea735a3 100644 --- a/stdlib/@python2/_bisect.pyi +++ b/stdlib/@python2/_bisect.pyi @@ -4,32 +4,7 @@ from typing import Callable, MutableSequence, Optional, Sequence, TypeVar _T = TypeVar("_T") -if sys.version_info >= (3, 10): - def bisect_left( - a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... - ) -> int: ... - def bisect_right( - a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... - ) -> int: ... - def insort_left( - a: MutableSequence[_T], - x: _T, - lo: int = ..., - hi: Optional[int] = ..., - *, - key: Optional[Callable[[_T], SupportsLessThan]] = ..., - ) -> None: ... - def insort_right( - a: MutableSequence[_T], - x: _T, - lo: int = ..., - hi: Optional[int] = ..., - *, - key: Optional[Callable[[_T], SupportsLessThan]] = ..., - ) -> None: ... - -else: - def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... - def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... - def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... - def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... +def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... +def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... +def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... +def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index fbb014aadbfb..27fad0fdcef7 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -6,12 +6,8 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union _Handler = Callable[[Exception], Tuple[Text, int]] _String = Union[bytes, str] _Errors = Union[str, Text, None] -if sys.version_info >= (3, 0): - _Decodable = bytes - _Encodable = str -else: - _Decodable = Union[bytes, Text] - _Encodable = Union[bytes, Text] +_Decodable = Union[bytes, Text] +_Encodable = Union[bytes, Text] # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap(object): @@ -29,8 +25,7 @@ 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]: ... -if sys.version_info < (3, 2): - def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... +def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ... def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... @@ -44,9 +39,8 @@ def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> Tuple[bytes, def unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ... def unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... -if sys.version_info < (3, 8): - def unicode_internal_decode(__obj: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ... - def unicode_internal_encode(__obj: _String, __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]: ... @@ -74,9 +68,3 @@ 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]: ... - if sys.version_info >= (3, 0): - def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... - def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... - if sys.version_info >= (3, 6): - def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... - def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index 2b4b1a743865..9544ba91958c 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_csv.pyi @@ -24,20 +24,13 @@ _DialectLike = Union[str, Dialect, Type[Dialect]] class _reader(Iterator[List[str]]): dialect: Dialect line_num: int - if sys.version_info >= (3, 0): - def __next__(self) -> List[str]: ... - else: - def next(self) -> List[str]: ... + def next(self) -> List[str]: ... class _writer: dialect: Dialect - if sys.version_info >= (3, 5): - def writerow(self, row: Iterable[Any]) -> Any: ... - def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... - else: - def writerow(self, row: Sequence[Any]) -> Any: ... - def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... + def writerow(self, row: Sequence[Any]) -> Any: ... + def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... class _Writer(Protocol): def write(self, s: str) -> Any: ... diff --git a/stdlib/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index 1ccd54e35edd..e5591d596104 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -57,8 +57,6 @@ A_COLOR: int A_DIM: int A_HORIZONTAL: int A_INVIS: int -if sys.version_info >= (3, 7): - A_ITALIC: int A_LEFT: int A_LOW: int A_NORMAL: int @@ -269,11 +267,7 @@ 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 -if sys.version_info >= (3, 8): - def color_pair(pair_number: int) -> int: ... - -else: - def color_pair(__color_number: int) -> int: ... +def color_pair(__color_number: int) -> int: ... def curs_set(__visibility: int) -> int: ... def def_prog_mode() -> None: ... @@ -349,23 +343,15 @@ def tparm( def typeahead(__fd: int) -> None: ... def unctrl(__ch: _chtype) -> bytes: ... -if sys.version_info >= (3, 3): - def unget_wch(__ch: Union[int, str]) -> None: ... - def ungetch(__ch: _chtype) -> None: ... def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ... -if sys.version_info >= (3, 5): - def update_lines_cols() -> int: ... - def use_default_colors() -> None: ... def use_env(__flag: bool) -> None: ... class error(Exception): ... class _CursesWindow: - if sys.version_info >= (3, 3): - encoding: str @overload def addch(self, ch: _chtype, attr: int = ...) -> None: ... @overload @@ -429,11 +415,6 @@ class _CursesWindow: def getch(self) -> int: ... @overload def getch(self, y: int, x: int) -> int: ... - if sys.version_info >= (3, 3): - @overload - def get_wch(self) -> Union[int, str]: ... - @overload - def get_wch(self, y: int, x: int) -> Union[int, str]: ... @overload def getkey(self) -> str: ... @overload @@ -533,10 +514,3 @@ class _CursesWindow: @overload def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... -if sys.version_info >= (3, 8): - class _ncurses_version(NamedTuple): - major: int - minor: int - patch: int - ncurses_version: _ncurses_version - window = _CursesWindow # undocumented diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index af0b0af89d9b..f8e1fc46b10a 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -12,30 +12,17 @@ __all__: List[str] def active_count() -> int: ... -if sys.version_info < (3,): - def activeCount() -> int: ... +def activeCount() -> int: ... def current_thread() -> Thread: ... def currentThread() -> Thread: ... -if sys.version_info >= (3,): - def get_ident() -> int: ... - def enumerate() -> List[Thread]: ... -if sys.version_info >= (3, 4): - def main_thread() -> Thread: ... - -if sys.version_info >= (3, 8): - from _thread import get_native_id as get_native_id - def settrace(func: _TF) -> None: ... def setprofile(func: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... -if sys.version_info >= (3,): - TIMEOUT_MAX: float - class ThreadError(Exception): ... class local(object): @@ -47,37 +34,21 @@ class Thread: name: str ident: Optional[int] daemon: bool - if sys.version_info >= (3,): - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - *, - daemon: Optional[bool] = ..., - ) -> None: ... - else: - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[Text] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., - ) -> None: ... + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[Text] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[Text, Any]] = ..., + ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: Text) -> None: ... - if sys.version_info >= (3, 8): - @property - def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - if sys.version_info < (3, 9): - def isAlive(self) -> bool: ... + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -89,10 +60,7 @@ class Lock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -102,10 +70,7 @@ class _RLock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock @@ -116,14 +81,9 @@ class Condition: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... - if sys.version_info >= (3,): - def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -133,56 +93,23 @@ class Semaphore: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - if sys.version_info >= (3, 9): - def release(self, n: int = ...) -> None: ... - else: - def release(self) -> 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: ... - if sys.version_info < (3,): - def isSet(self) -> bool: ... + def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... -if sys.version_info >= (3, 8): - from _thread import _excepthook, _ExceptHookArgs - - excepthook = _excepthook - ExceptHookArgs = _ExceptHookArgs - class Timer(Thread): - if sys.version_info >= (3,): - def __init__( - self, - interval: float, - function: Callable[..., Any], - args: Optional[Iterable[Any]] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - ) -> None: ... - else: - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... + def __init__( + self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... + ) -> None: ... def cancel(self) -> None: ... -if sys.version_info >= (3,): - class Barrier: - parties: int - n_waiting: int - broken: bool - def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> int: ... - def reset(self) -> None: ... - def abort(self) -> None: ... - class BrokenBarrierError(RuntimeError): ... diff --git a/stdlib/@python2/_heapq.pyi b/stdlib/@python2/_heapq.pyi index 5b14a9de773d..2928f39c2c17 100644 --- a/stdlib/@python2/_heapq.pyi +++ b/stdlib/@python2/_heapq.pyi @@ -9,6 +9,5 @@ def heappush(__heap: List[_T], __item: _T) -> None: ... def heappushpop(__heap: List[_T], __item: _T) -> _T: ... def heapreplace(__heap: List[_T], __item: _T) -> _T: ... -if sys.version_info < (3,): - def nlargest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... - def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... +def nlargest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... +def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... diff --git a/stdlib/@python2/_random.pyi b/stdlib/@python2/_random.pyi index aa09693420ca..3d1d6476953f 100644 --- a/stdlib/@python2/_random.pyi +++ b/stdlib/@python2/_random.pyi @@ -11,5 +11,4 @@ class Random(object): def setstate(self, __state: _State) -> None: ... def random(self) -> float: ... def getrandbits(self, __k: int) -> int: ... - if sys.version_info < (3,): - def jumpahead(self, i: int) -> None: ... + def jumpahead(self, i: int) -> None: ... diff --git a/stdlib/@python2/_thread.pyi b/stdlib/@python2/_thread.pyi index 513678499223..6cf7f5f59206 100644 --- a/stdlib/@python2/_thread.pyi +++ b/stdlib/@python2/_thread.pyi @@ -27,15 +27,3 @@ def stack_size(size: int = ...) -> int: ... TIMEOUT_MAX: float -if sys.version_info >= (3, 8): - def get_native_id() -> int: ... # only available on some platforms - class _ExceptHookArgs(Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]): - @property - def exc_type(self) -> Type[BaseException]: ... - @property - def exc_value(self) -> Optional[BaseException]: ... - @property - def exc_traceback(self) -> Optional[TracebackType]: ... - @property - def thread(self) -> Optional[Thread]: ... - _excepthook: Callable[[_ExceptHookArgs], Any] diff --git a/stdlib/@python2/_typeshed/__init__.pyi b/stdlib/@python2/_typeshed/__init__.pyi index 948d4269f575..e041aa02c2af 100644 --- a/stdlib/@python2/_typeshed/__init__.pyi +++ b/stdlib/@python2/_typeshed/__init__.pyi @@ -40,11 +40,8 @@ class SupportsRDivMod(Protocol[_T_contra, _T_co]): # Mapping-like protocols class SupportsItems(Protocol[_KT_co, _VT_co]): - if sys.version_info >= (3,): - def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ... - else: - # We want dictionaries to support this on Python 2. - def items(self) -> Iterable[Tuple[_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]: ... @@ -59,16 +56,9 @@ class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, # StrPath and AnyPath can be used in places where a # path can be used instead of a string, starting with Python 3.6. -if sys.version_info >= (3, 6): - from os import PathLike - - StrPath = Union[str, PathLike[str]] - BytesPath = Union[bytes, PathLike[bytes]] - AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]] -else: - StrPath = Text - BytesPath = bytes - AnyPath = Union[Text, bytes] +StrPath = Text +BytesPath = bytes +AnyPath = Union[Text, bytes] OpenTextModeUpdating = Literal[ "r+", @@ -155,17 +145,10 @@ class SupportsNoArgReadline(Protocol[_T_co]): class SupportsWrite(Protocol[_T_contra]): def write(self, __s: _T_contra) -> Any: ... -if sys.version_info >= (3,): - ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap] - WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap] -else: - ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer] - WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, buffer] - -if sys.version_info >= (3, 10): - from types import NoneType as NoneType -else: - # Used by type checkers for checks involving None (does not exist at runtime) - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... +ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer] +WriteableBuffer = Union[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/stdlib/@python2/_typeshed/tkinter.pyi b/stdlib/@python2/_typeshed/tkinter.pyi index 565635adbb74..a4b00506a0e3 100644 --- a/stdlib/@python2/_typeshed/tkinter.pyi +++ b/stdlib/@python2/_typeshed/tkinter.pyi @@ -1,7 +1,3 @@ import sys from typing import Optional, Protocol -if sys.version_info >= (3,): - from tkinter import Event, Misc, Widget - class DndSource(Protocol): - def dnd_end(self, target: Optional[Widget], event: Optional[Event[Misc]]) -> None: ... diff --git a/stdlib/@python2/_warnings.pyi b/stdlib/@python2/_warnings.pyi index b4ec4e6ee794..2844b0b690fa 100644 --- a/stdlib/@python2/_warnings.pyi +++ b/stdlib/@python2/_warnings.pyi @@ -1,67 +1,32 @@ import sys from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload -if sys.version_info >= (3, 0): - _defaultaction: str - _onceregistry: Dict[Any, Any] -else: - default_action: str - once_registry: Dict[Any, Any] +default_action: str +once_registry: Dict[Any, Any] filters: List[Tuple[Any, ...]] -if sys.version_info >= (3, 6): - @overload - def warn( - message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ... - ) -> None: ... - @overload - def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Optional[Any] = ...) -> None: ... - @overload - def warn_explicit( - message: str, - category: Type[Warning], - filename: str, - lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., - ) -> None: ... - @overload - def warn_explicit( - message: Warning, - category: Any, - filename: str, - lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., - ) -> None: ... - -else: - @overload - def warn(message: str, category: Optional[Type[Warning]] = ..., 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: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - ) -> None: ... - @overload - def warn_explicit( - message: Warning, - category: Any, - filename: str, - lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - ) -> None: ... +@overload +def warn(message: str, category: Optional[Type[Warning]] = ..., 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: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., +) -> None: ... +@overload +def warn_explicit( + message: Warning, + category: Any, + filename: str, + lineno: int, + module: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., +) -> None: ... diff --git a/stdlib/@python2/_weakref.pyi b/stdlib/@python2/_weakref.pyi index 115a591ce4c8..3c395dc7206e 100644 --- a/stdlib/@python2/_weakref.pyi +++ b/stdlib/@python2/_weakref.pyi @@ -1,9 +1,6 @@ import sys from typing import Any, Callable, Generic, List, Optional, TypeVar, overload -if sys.version_info >= (3, 9): - from types import GenericAlias - _C = TypeVar("_C", bound=Callable[..., Any]) _T = TypeVar("_T") @@ -14,14 +11,9 @@ class ProxyType(Generic[_T]): # "weakproxy" def __getattr__(self, attr: str) -> Any: ... class ReferenceType(Generic[_T]): - if sys.version_info >= (3, 4): - __callback__: Callable[[ReferenceType[_T]], Any] def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ... def __call__(self) -> Optional[_T]: ... def __hash__(self) -> int: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - ref = ReferenceType def getweakrefcount(__object: Any) -> int: ... diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index c369584aa243..f5f4fc5241c9 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -1,9 +1,6 @@ import sys from typing import Any, Generic, Iterable, Iterator, MutableSet, Optional, TypeVar, Union -if sys.version_info >= (3, 9): - from types import GenericAlias - _S = TypeVar("_S") _T = TypeVar("_T") _SelfT = TypeVar("_SelfT", bound=WeakSet[Any]) @@ -43,5 +40,3 @@ class WeakSet(MutableSet[_T], Generic[_T]): def union(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... def __or__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... def isdisjoint(self, other: Iterable[_T]) -> bool: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index f812ac593e97..68c4286cc150 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -18,11 +18,6 @@ _Marker = Tuple[int, int, bytes] class Aifc_read: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 4): - def __enter__(self) -> Aifc_read: ... - def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def getfp(self) -> IO[bytes]: ... def rewind(self) -> None: ... @@ -43,11 +38,6 @@ class Aifc_read: class Aifc_write: def __init__(self, f: _File) -> None: ... def __del__(self) -> None: ... - if sys.version_info >= (3, 4): - def __enter__(self) -> Aifc_write: ... - def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def aiff(self) -> None: ... def aifc(self) -> None: ... @@ -79,10 +69,9 @@ def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... @overload def open(f: _File, mode: Optional[str] = ...) -> Any: ... -if sys.version_info < (3, 9): - @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: Optional[str] = ...) -> 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: Optional[str] = ...) -> Any: ... diff --git a/stdlib/@python2/antigravity.pyi b/stdlib/@python2/antigravity.pyi index 52e2c5d96bef..44bd5c72b94b 100644 --- a/stdlib/@python2/antigravity.pyi +++ b/stdlib/@python2/antigravity.pyi @@ -1,4 +1,2 @@ import sys -if sys.version_info >= (3, 0): - def geohash(latitude: float, longitude: float, datedow: bytes) -> None: ... diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 9dceaabd4631..149d2c1f5f19 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -24,10 +24,7 @@ _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) _N = TypeVar("_N") -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] ONE_OR_MORE: str OPTIONAL: str @@ -109,31 +106,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): fromfile_prefix_chars: Optional[_Text] add_help: bool - if sys.version_info >= (3, 5): - allow_abbrev: bool - # undocumented _positionals: _ArgumentGroup _optionals: _ArgumentGroup _subparsers: Optional[_ArgumentGroup] - if sys.version_info >= (3, 9): - def __init__( - self, - prog: Optional[str] = ..., - usage: Optional[str] = ..., - description: Optional[str] = ..., - epilog: Optional[str] = ..., - parents: Sequence[ArgumentParser] = ..., - formatter_class: _FormatterClass = ..., - prefix_chars: str = ..., - fromfile_prefix_chars: Optional[str] = ..., - argument_default: Any = ..., - conflict_handler: str = ..., - add_help: bool = ..., - allow_abbrev: bool = ..., - exit_on_error: bool = ..., - ) -> None: ... elif sys.version_info >= (3, 5): def __init__( self, @@ -177,35 +154,19 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore @overload def parse_args(self, *, namespace: _N) -> _N: ... - if sys.version_info >= (3, 7): - def add_subparsers( - self, - *, - title: str = ..., - description: Optional[str] = ..., - prog: str = ..., - parser_class: Type[ArgumentParser] = ..., - action: Type[Action] = ..., - option_string: str = ..., - dest: Optional[str] = ..., - required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[str] = ..., - ) -> _SubParsersAction: ... - else: - def add_subparsers( - self, - *, - title: Text = ..., - description: Optional[Text] = ..., - prog: Text = ..., - parser_class: Type[ArgumentParser] = ..., - action: Type[Action] = ..., - option_string: Text = ..., - dest: Optional[Text] = ..., - help: Optional[Text] = ..., - metavar: Optional[Text] = ..., - ) -> _SubParsersAction: ... + def add_subparsers( + self, + *, + title: Text = ..., + description: Optional[Text] = ..., + prog: Text = ..., + parser_class: Type[ArgumentParser] = ..., + action: Type[Action] = ..., + option_string: Text = ..., + dest: Optional[Text] = ..., + help: Optional[Text] = ..., + metavar: Optional[Text] = ..., + ) -> _SubParsersAction: ... def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... def print_help(self, file: Optional[IO[str]] = ...) -> None: ... def format_usage(self) -> str: ... @@ -216,13 +177,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def convert_arg_line_to_args(self, arg_line: Text) -> List[str]: ... def exit(self, status: int = ..., message: Optional[Text] = ...) -> NoReturn: ... def error(self, message: Text) -> NoReturn: ... - if sys.version_info >= (3, 7): - def parse_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... - ) -> Namespace: ... - def parse_known_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... - ) -> Tuple[Namespace, List[str]]: ... # undocumented def _get_optional_actions(self) -> List[Action]: ... def _get_positional_actions(self) -> List[Action]: ... @@ -290,9 +244,6 @@ class RawDescriptionHelpFormatter(HelpFormatter): ... class RawTextHelpFormatter(RawDescriptionHelpFormatter): ... class ArgumentDefaultsHelpFormatter(HelpFormatter): ... -if sys.version_info >= (3,): - class MetavarTypeHelpFormatter(HelpFormatter): ... - class Action(_AttributeHolder): option_strings: Sequence[_Text] dest: _Text @@ -324,23 +275,6 @@ class Action(_AttributeHolder): values: Union[Text, Sequence[Any], None], option_string: Optional[Text] = ..., ) -> None: ... - if sys.version_info >= (3, 9): - def format_usage(self) -> str: ... - -if sys.version_info >= (3, 9): - class BooleanOptionalAction(Action): - def __init__( - self, - option_strings: Sequence[str], - dest: str, - default: Union[_T, str, None] = ..., - type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., - required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - ) -> None: ... - class Namespace(_AttributeHolder): def __init__(self, **kwargs: Any) -> None: ... def __getattr__(self, name: Text) -> Any: ... @@ -351,14 +285,7 @@ class FileType: # undocumented _mode: _Text _bufsize: int - if sys.version_info >= (3,): - _encoding: Optional[str] - _errors: Optional[str] - def __init__( - self, mode: str = ..., bufsize: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ... - ) -> None: ... - else: - def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ... + def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ... def __call__(self, string: Text) -> IO[Any]: ... # undocumented @@ -451,27 +378,15 @@ class _SubParsersAction(Action): _name_parser_map: Dict[_Text, ArgumentParser] choices: Dict[_Text, ArgumentParser] _choices_actions: List[Action] - if sys.version_info >= (3, 7): - def __init__( - self, - option_strings: Sequence[Text], - prog: Text, - parser_class: Type[ArgumentParser], - dest: Text = ..., - required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - ) -> None: ... - else: - def __init__( - self, - option_strings: Sequence[Text], - prog: Text, - parser_class: Type[ArgumentParser], - dest: Text = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - ) -> None: ... + def __init__( + self, + option_strings: Sequence[Text], + prog: Text, + parser_class: Type[ArgumentParser], + dest: Text = ..., + help: Optional[Text] = ..., + metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... def _get_subactions(self) -> List[Action]: ... @@ -479,9 +394,8 @@ class _SubParsersAction(Action): # undocumented class ArgumentTypeError(Exception): ... -if sys.version_info < (3, 7): - # undocumented - def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ... +# undocumented +def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ... # undocumented def _get_action_name(argument: Optional[Action]) -> Optional[str]: ... diff --git a/stdlib/@python2/array.pyi b/stdlib/@python2/array.pyi index 498bf92919f1..af694ad2d23f 100644 --- a/stdlib/@python2/array.pyi +++ b/stdlib/@python2/array.pyi @@ -9,9 +9,6 @@ _TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] _T = TypeVar("_T", int, float, Text) -if sys.version_info >= (3,): - typecodes: str - class array(MutableSequence[_T], Generic[_T]): typecode: _TypeCode itemsize: int @@ -28,31 +25,21 @@ class array(MutableSequence[_T], Generic[_T]): def byteswap(self) -> None: ... def count(self, __v: Any) -> int: ... def extend(self, __bb: Iterable[_T]) -> None: ... - if sys.version_info >= (3, 2): - def frombytes(self, __buffer: bytes) -> None: ... def fromfile(self, __f: BinaryIO, __n: int) -> None: ... def fromlist(self, __list: List[_T]) -> None: ... def fromunicode(self, __ustr: str) -> None: ... - if sys.version_info >= (3, 10): - def index(self, __v: _T, __start: int = ..., __stop: int = ...) -> int: ... - else: - def index(self, __v: _T) -> int: ... # type: ignore # Overrides Sequence + def index(self, __v: _T) -> int: ... # type: ignore # Overrides Sequence def insert(self, __i: int, __v: _T) -> None: ... def pop(self, __i: int = ...) -> _T: ... - if sys.version_info < (3,): - def read(self, f: BinaryIO, n: int) -> None: ... + def read(self, f: BinaryIO, n: int) -> None: ... def remove(self, __v: Any) -> None: ... def reverse(self) -> None: ... - if sys.version_info >= (3, 2): - def tobytes(self) -> bytes: ... def tofile(self, __f: BinaryIO) -> None: ... def tolist(self) -> List[_T]: ... def tounicode(self) -> str: ... - if sys.version_info < (3,): - def write(self, f: BinaryIO) -> None: ... - if sys.version_info < (3, 9): - def fromstring(self, __buffer: bytes) -> None: ... - def tostring(self) -> bytes: ... + 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: ... @@ -72,9 +59,8 @@ class array(MutableSequence[_T], Generic[_T]): def __lt__(self, other: array[_T]) -> bool: ... def __mul__(self, n: int) -> array[_T]: ... def __rmul__(self, n: int) -> array[_T]: ... - if sys.version_info < (3,): - 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: ... + 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/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index 34039b993400..2fc5bbf07d0f 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -29,11 +29,10 @@ class async_chat(asyncore.dispatcher): def initiate_send(self) -> None: ... def discard_buffers(self) -> None: ... -if sys.version_info < (3, 0): - class fifo: - def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... - def __len__(self) -> int: ... - def is_empty(self) -> bool: ... - def first(self) -> bytes: ... - def push(self, data: Union[bytes, simple_producer]) -> None: ... - def pop(self) -> Tuple[int, bytes]: ... +class fifo: + def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... + def __len__(self) -> int: ... + def is_empty(self) -> bool: ... + def first(self) -> bytes: ... + def push(self, data: Union[bytes, simple_producer]) -> None: ... + def pop(self) -> Tuple[int, bytes]: ... diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index a05a205115f3..be551a040cc1 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -59,36 +59,35 @@ class dispatcher: def handle_connect(self) -> None: ... def handle_accept(self) -> None: ... def handle_close(self) -> None: ... - if sys.version_info < (3, 5): - # 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: Union[Tuple[str, int], str], flags: int = ...) -> int: ... - def setblocking(self, flag: bool) -> None: ... - def settimeout(self, value: Union[float, None]) -> None: ... - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... - def shutdown(self, how: int) -> 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: Union[Tuple[str, int], str], flags: int = ...) -> int: ... + def setblocking(self, flag: bool) -> None: ... + def settimeout(self, value: Union[float, None]) -> None: ... + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + def shutdown(self, how: int) -> None: ... class dispatcher_with_send(dispatcher): def __init__(self, sock: SocketType = ..., map: Optional[_maptype] = ...) -> None: ... diff --git a/stdlib/@python2/base64.pyi b/stdlib/@python2/base64.pyi index e217d6d3dbf2..999b2713a456 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -1,12 +1,8 @@ import sys from typing import IO, Optional, Union -if sys.version_info >= (3, 0): - _encodable = bytes - _decodable = Union[bytes, str] -else: - _encodable = Union[bytes, unicode] - _decodable = Union[bytes, unicode] +_encodable = Union[bytes, unicode] +_decodable = Union[bytes, unicode] def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ... def b64decode(s: _decodable, altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ... @@ -19,23 +15,8 @@ def b32decode(s: _decodable, casefold: bool = ..., map01: Optional[bytes] = ...) def b16encode(s: _encodable) -> bytes: ... def b16decode(s: _decodable, casefold: bool = ...) -> bytes: ... -if sys.version_info >= (3, 10): - def b32hexencode(s: _encodable) -> bytes: ... - def b32hexdecode(s: _decodable, casefold: bool = ...) -> bytes: ... - -if sys.version_info >= (3, 4): - def a85encode(b: _encodable, *, foldspaces: bool = ..., wrapcol: int = ..., pad: bool = ..., adobe: bool = ...) -> bytes: ... - def a85decode(b: _decodable, *, foldspaces: bool = ..., adobe: bool = ..., ignorechars: Union[str, bytes] = ...) -> bytes: ... - def b85encode(b: _encodable, pad: bool = ...) -> bytes: ... - def b85decode(b: _decodable) -> bytes: ... - def decode(input: IO[bytes], output: IO[bytes]) -> None: ... def encode(input: IO[bytes], output: IO[bytes]) -> None: ... -if sys.version_info >= (3,): - def encodebytes(s: bytes) -> bytes: ... - def decodebytes(s: bytes) -> bytes: ... - -if sys.version_info < (3, 9): - def encodestring(s: bytes) -> bytes: ... - def decodestring(s: bytes) -> bytes: ... +def encodestring(s: bytes) -> bytes: ... +def decodestring(s: bytes) -> bytes: ... diff --git a/stdlib/@python2/binascii.pyi b/stdlib/@python2/binascii.pyi index db843ad6ca31..69233a05a8fc 100644 --- a/stdlib/@python2/binascii.pyi +++ b/stdlib/@python2/binascii.pyi @@ -1,31 +1,17 @@ import sys from typing import Text, Union -if sys.version_info >= (3, 0): - # But since Python 3.3 ASCII-only unicode strings are accepted by the - # a2b_* functions. - _Bytes = bytes - _Ascii = Union[bytes, str] -else: - # Python 2 accepts unicode ascii pretty much everywhere. - _Bytes = Text - _Ascii = Text +# Python 2 accepts unicode ascii pretty much everywhere. +_Bytes = Text +_Ascii = Text def a2b_uu(__data: _Ascii) -> bytes: ... -if sys.version_info >= (3, 7): - def b2a_uu(__data: _Bytes, *, backtick: bool = ...) -> bytes: ... - -else: - def b2a_uu(__data: _Bytes) -> bytes: ... +def b2a_uu(__data: _Bytes) -> bytes: ... def a2b_base64(__data: _Ascii) -> bytes: ... -if sys.version_info >= (3, 6): - def b2a_base64(__data: _Bytes, *, newline: bool = ...) -> bytes: ... - -else: - def b2a_base64(__data: _Bytes) -> 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: ... @@ -37,11 +23,7 @@ def crc_hqx(__data: _Bytes, __crc: int) -> int: ... def crc32(__data: _Bytes, __crc: int = ...) -> int: ... def b2a_hex(__data: _Bytes) -> bytes: ... -if sys.version_info >= (3, 8): - def hexlify(data: bytes, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> bytes: ... - -else: - def hexlify(__data: _Bytes) -> bytes: ... +def hexlify(__data: _Bytes) -> bytes: ... def a2b_hex(__hexstr: _Ascii) -> bytes: ... def unhexlify(__hexstr: _Ascii) -> bytes: ... diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index dfc1876bf43e..77d0f8e21c20 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -10,45 +10,11 @@ _T = TypeVar("_T") def compress(data: bytes, compresslevel: int = ...) -> bytes: ... def decompress(data: bytes) -> bytes: ... -if sys.version_info >= (3, 3): - _OpenBinaryMode = Literal["r", "rb", "w", "wb", "x", "xb", "a", "ab"] - _OpenTextMode = Literal["rt", "wt", "xt", "at"] - @overload - def open( - filename: _PathOrFile, - mode: _OpenBinaryMode = ..., - compresslevel: int = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - ) -> BZ2File: ... - @overload - def open( - filename: AnyPath, - mode: _OpenTextMode, - compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> TextIO: ... - @overload - def open( - filename: _PathOrFile, - mode: str, - compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> Union[BZ2File, TextIO]: ... - class BZ2File(io.BufferedIOBase, IO[bytes]): def __enter__(self: _T) -> _T: ... - if sys.version_info >= (3, 9): - def __init__(self, filename: _PathOrFile, mode: str = ..., *, compresslevel: int = ...) -> None: ... - else: - def __init__( - self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... - ) -> None: ... + def __init__( + self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... + ) -> None: ... def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore @@ -64,15 +30,6 @@ class BZ2Compressor(object): def flush(self) -> bytes: ... class BZ2Decompressor(object): - if sys.version_info >= (3, 5): - def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... - else: - def decompress(self, data: bytes) -> bytes: ... - if sys.version_info >= (3, 3): - @property - def eof(self) -> bool: ... - if sys.version_info >= (3, 5): - @property - def needs_input(self) -> bool: ... + def decompress(self, data: bytes) -> bytes: ... @property def unused_data(self) -> bytes: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 638a2a79f2e5..cc26f9836cc1 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -26,8 +26,4 @@ class Profile: def run(self: _SelfT, cmd: str) -> _SelfT: ... def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... - if sys.version_info >= (3, 8): - def __enter__(self: _SelfT) -> _SelfT: ... - def __exit__(self, *exc_info: Any) -> None: ... - def label(code: Union[str, CodeType]) -> _Label: ... # undocumented diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index ad73132b4595..752bd9a591cd 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -33,10 +33,6 @@ 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]]: ... - class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... def formatday(self, day: int, weekday: int, width: int) -> str: ... @@ -68,26 +64,10 @@ 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: Optional[str] = ..., encoding: Optional[str] = ...) -> 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 - -if sys.version_info >= (3, 0): - class different_locale: - def __init__(self, locale: _LocaleType) -> None: ... - def __enter__(self) -> _LocaleType: ... - def __exit__(self, *args: Any) -> None: ... - -else: - class TimeEncoding: - def __init__(self, locale: _LocaleType) -> None: ... - def __enter__(self) -> _LocaleType: ... - def __exit__(self, *args: Any) -> None: ... +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: Optional[_LocaleType] = ...) -> None: ... diff --git a/stdlib/@python2/cmath.pyi b/stdlib/@python2/cmath.pyi index eaa62eafcb33..3c38ab9d04db 100644 --- a/stdlib/@python2/cmath.pyi +++ b/stdlib/@python2/cmath.pyi @@ -3,13 +3,6 @@ from typing import SupportsComplex, SupportsFloat, Tuple, Union e: float pi: float -if sys.version_info >= (3, 6): - inf: float - infj: complex - nan: float - nanj: complex - tau: float - _C = Union[SupportsFloat, SupportsComplex, complex] def acos(__z: _C) -> complex: ... @@ -22,9 +15,6 @@ def cos(__z: _C) -> complex: ... def cosh(__z: _C) -> complex: ... def exp(__z: _C) -> complex: ... -if sys.version_info >= (3, 5): - def isclose(a: _C, b: _C, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... - def isinf(__z: _C) -> bool: ... def isnan(__z: _C) -> bool: ... def log(__x: _C, __y_obj: _C = ...) -> complex: ... @@ -38,5 +28,3 @@ def sqrt(__z: _C) -> complex: ... def tan(__z: _C) -> complex: ... def tanh(__z: _C) -> complex: ... -if sys.version_info >= (3,): - def isfinite(__z: _C) -> bool: ... diff --git a/stdlib/@python2/code.pyi b/stdlib/@python2/code.pyi index 16c2b129dd1e..aee7f518d655 100644 --- a/stdlib/@python2/code.pyi +++ b/stdlib/@python2/code.pyi @@ -12,25 +12,13 @@ class InteractiveInterpreter: class InteractiveConsole(InteractiveInterpreter): def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... - if sys.version_info >= (3, 6): - def interact(self, banner: Optional[str] = ..., exitmsg: Optional[str] = ...) -> None: ... - else: - def interact(self, banner: Optional[str] = ...) -> None: ... + def interact(self, banner: Optional[str] = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... def raw_input(self, prompt: str = ...) -> str: ... -if sys.version_info >= (3, 6): - def interact( - banner: Optional[str] = ..., - readfunc: Optional[Callable[[str], str]] = ..., - local: Optional[Mapping[str, Any]] = ..., - exitmsg: Optional[str] = ..., - ) -> None: ... - -else: - def interact( - banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... - ) -> None: ... +def interact( + banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... +) -> None: ... def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index 79be8e254c4c..1132cdd18fb5 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -234,10 +234,7 @@ class StreamReaderWriter(TextIO): def read(self, size: int = ...) -> _Decoded: ... def readline(self, size: Optional[int] = ...) -> _Decoded: ... def readlines(self, sizehint: Optional[int] = ...) -> List[_Decoded]: ... - if sys.version_info >= (3,): - def __next__(self) -> Text: ... - else: - def next(self) -> Text: ... + def next(self) -> Text: ... def __iter__(self: _T) -> _T: ... # This actually returns None, but that's incompatible with the supertype def write(self, data: _Decoded) -> int: ... @@ -277,10 +274,7 @@ class StreamRecoder(BinaryIO): def read(self, size: int = ...) -> bytes: ... def readline(self, size: Optional[int] = ...) -> bytes: ... def readlines(self, sizehint: Optional[int] = ...) -> List[bytes]: ... - if sys.version_info >= (3,): - def __next__(self) -> bytes: ... - else: - def next(self) -> bytes: ... + def next(self) -> bytes: ... def __iter__(self: _SRT) -> _SRT: ... def write(self, data: bytes) -> int: ... def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index 19ef45bed241..c38d3eadb4d7 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -3,14 +3,6 @@ from types import TracebackType from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Type, TypeVar, overload from typing_extensions import Protocol -if sys.version_info >= (3, 5): - from typing import AsyncContextManager, AsyncIterator - -if sys.version_info >= (3, 6): - AbstractContextManager = ContextManager -if sys.version_info >= (3, 7): - AbstractAsyncContextManager = AsyncContextManager - _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=Optional[IO[str]]) @@ -19,21 +11,11 @@ _F = TypeVar("_F", bound=Callable[..., Any]) _ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) -if sys.version_info >= (3, 2): - class _GeneratorContextManager(ContextManager[_T_co]): - def __call__(self, func: _F) -> _F: ... - def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]: ... - -else: - class GeneratorContextManager(ContextManager[_T_co]): - def __call__(self, func: _F) -> _F: ... - def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +class GeneratorContextManager(ContextManager[_T_co]): + def __call__(self, func: _F) -> _F: ... +def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... -if sys.version_info >= (3, 7): - def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ... - -if sys.version_info < (3,): - def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... +def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... class _SupportsClose(Protocol): def close(self) -> None: ... @@ -43,73 +25,3 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) class closing(ContextManager[_SupportsCloseT]): def __init__(self, thing: _SupportsCloseT) -> None: ... -if sys.version_info >= (3, 10): - class _SupportsAclose(Protocol): - async def aclose(self) -> None: ... - _SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) - class aclosing(AsyncContextManager[_SupportsAcloseT]): - def __init__(self, thing: _SupportsAcloseT) -> None: ... - -if sys.version_info >= (3, 4): - class suppress(ContextManager[None]): - def __init__(self, *exceptions: Type[BaseException]) -> None: ... - def __exit__( - self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType] - ) -> bool: ... - class redirect_stdout(ContextManager[_T_io]): - def __init__(self, new_target: _T_io) -> None: ... - -if sys.version_info >= (3, 5): - class redirect_stderr(ContextManager[_T_io]): - def __init__(self, new_target: _T_io) -> None: ... - -if sys.version_info >= (3,): - class ContextDecorator: - def __call__(self, func: _F) -> _F: ... - _U = TypeVar("_U", bound=ExitStack) - class ExitStack(ContextManager[ExitStack]): - def __init__(self) -> None: ... - def enter_context(self, cm: ContextManager[_T]) -> _T: ... - def push(self, exit: _CM_EF) -> _CM_EF: ... - def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ... - def pop_all(self: _U) -> _U: ... - def close(self) -> None: ... - def __enter__(self: _U) -> _U: ... - def __exit__( - self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> bool: ... - -if sys.version_info >= (3, 7): - from typing import Awaitable - - _S = TypeVar("_S", bound=AsyncExitStack) - - _ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] - _CallbackCoroFunc = Callable[..., Awaitable[Any]] - _ACM_EF = TypeVar("_ACM_EF", AsyncContextManager[Any], _ExitCoroFunc) - class AsyncExitStack(AsyncContextManager[AsyncExitStack]): - def __init__(self) -> None: ... - def enter_context(self, cm: ContextManager[_T]) -> _T: ... - def enter_async_context(self, cm: AsyncContextManager[_T]) -> Awaitable[_T]: ... - def push(self, exit: _CM_EF) -> _CM_EF: ... - def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ... - def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ... - def push_async_callback(self, callback: _CallbackCoroFunc, *args: Any, **kwds: Any) -> _CallbackCoroFunc: ... - def pop_all(self: _S) -> _S: ... - def aclose(self) -> Awaitable[None]: ... - def __aenter__(self: _S) -> Awaitable[_S]: ... - def __aexit__( - self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> Awaitable[bool]: ... - -if sys.version_info >= (3, 7): - @overload - def nullcontext(enter_result: _T) -> ContextManager[_T]: ... - @overload - def nullcontext() -> ContextManager[None]: ... diff --git a/stdlib/@python2/crypt.pyi b/stdlib/@python2/crypt.pyi index 18893721a11f..bab839794f02 100644 --- a/stdlib/@python2/crypt.pyi +++ b/stdlib/@python2/crypt.pyi @@ -1,22 +1,4 @@ import sys from typing import List, Optional, Union -if sys.version_info >= (3, 3): - class _Method: ... - METHOD_CRYPT: _Method - METHOD_MD5: _Method - METHOD_SHA256: _Method - METHOD_SHA512: _Method - if sys.version_info >= (3, 7): - METHOD_BLOWFISH: _Method - - methods: List[_Method] - - if sys.version_info >= (3, 7): - def mksalt(method: Optional[_Method] = ..., *, rounds: Optional[int] = ...) -> str: ... - else: - def mksalt(method: Optional[_Method] = ...) -> str: ... - def crypt(word: str, salt: Optional[Union[str, _Method]] = ...) -> str: ... - -else: - def crypt(word: str, salt: str) -> str: ... +def crypt(word: str, salt: str) -> str: ... diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index db48e9e6c78a..11d78de1fc9c 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -19,11 +19,7 @@ from _csv import ( ) from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, TypeVar, overload -if sys.version_info >= (3, 8) or sys.version_info < (3, 6): - from typing import Dict as _DictReadMapping -else: - from collections import OrderedDict as _DictReadMapping - +from typing import Dict as _DictReadMapping _T = TypeVar("_T") class excel(Dialect): @@ -37,15 +33,6 @@ class excel(Dialect): class excel_tab(excel): delimiter: str -if sys.version_info >= (3,): - class unix_dialect(Dialect): - delimiter: str - quotechar: str - doublequote: bool - skipinitialspace: bool - lineterminator: str - quoting: int - class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): fieldnames: Optional[Sequence[_T]] restkey: Optional[str] @@ -76,10 +63,7 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): **kwds: Any, ) -> None: ... def __iter__(self) -> DictReader[_T]: ... - if sys.version_info >= (3,): - def __next__(self) -> _DictReadMapping[_T, str]: ... - else: - def next(self) -> _DictReadMapping[_T, str]: ... + def next(self) -> _DictReadMapping[_T, str]: ... class DictWriter(Generic[_T]): fieldnames: Sequence[_T] @@ -96,10 +80,7 @@ class DictWriter(Generic[_T]): *args: Any, **kwds: Any, ) -> None: ... - if sys.version_info >= (3, 8): - def writeheader(self) -> Any: ... - else: - def writeheader(self) -> None: ... + def writeheader(self) -> None: ... def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ... def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ... diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 299672ad0629..64c447d893f6 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -19,9 +19,6 @@ from typing import ( overload, ) -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") _DLLT = TypeVar("_DLLT", bound=CDLL) _CT = TypeVar("_CT", bound=_CData) @@ -36,25 +33,14 @@ class CDLL(object): _name: str = ... _handle: int = ... _FuncPtr: Type[_FuncPointer] = ... - if sys.version_info >= (3, 8): - def __init__( - self, - name: Optional[str], - mode: int = ..., - handle: Optional[int] = ..., - use_errno: bool = ..., - use_last_error: bool = ..., - winmode: Optional[int] = ..., - ) -> None: ... - else: - def __init__( - self, - name: Optional[str], - mode: int = ..., - handle: Optional[int] = ..., - use_errno: bool = ..., - use_last_error: bool = ..., - ) -> None: ... + def __init__( + self, + name: Optional[str], + mode: int = ..., + handle: Optional[int] = ..., + use_errno: bool = ..., + use_last_error: bool = ..., + ) -> None: ... def __getattr__(self, name: str) -> _NamedFuncPointer: ... def __getitem__(self, name: str) -> _NamedFuncPointer: ... @@ -69,9 +55,6 @@ class LibraryLoader(Generic[_DLLT]): def __getattr__(self, name: str) -> _DLLT: ... def __getitem__(self, name: str) -> _DLLT: ... def LoadLibrary(self, name: str) -> _DLLT: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - cdll: LibraryLoader[CDLL] = ... if sys.platform == "win32": windll: LibraryLoader[WinDLL] = ... @@ -201,8 +184,7 @@ class pointer(Generic[_CT], _PointerLike, _CData): def resize(obj: _CData, size: int) -> None: ... -if sys.version_info < (3,): - def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ... +def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ... def set_errno(value: int) -> int: ... @@ -315,5 +297,3 @@ class Array(Generic[_CT], _CData): # Can't inherit from Sized because the metaclass conflict between # Sized and _CData prevents using _CDataMeta. def __len__(self) -> int: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index 4692f590b5b3..a8428613f775 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -4,10 +4,7 @@ from typing import AnyStr, ClassVar, NamedTuple, Optional, SupportsAbs, Tuple, T _S = TypeVar("_S") -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] MINYEAR: int MAXYEAR: int @@ -18,20 +15,6 @@ class tzinfo: def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def fromutc(self, dt: datetime) -> datetime: ... -if sys.version_info >= (3, 2): - class timezone(tzinfo): - utc: ClassVar[timezone] - min: ClassVar[timezone] - max: ClassVar[timezone] - def __init__(self, offset: timedelta, name: str = ...) -> None: ... - def __hash__(self) -> int: ... - -if sys.version_info >= (3, 9): - class _IsoCalendarDate(NamedTuple): - year: int - week: int - weekday: int - _tzinfo = tzinfo class date: @@ -45,12 +28,6 @@ class date: def today(cls: Type[_S]) -> _S: ... @classmethod def fromordinal(cls: Type[_S], n: int) -> _S: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... - if sys.version_info >= (3, 8): - @classmethod - def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ... @property def year(self) -> int: ... @property @@ -59,10 +36,7 @@ class date: def day(self) -> int: ... def ctime(self) -> str: ... def strftime(self, fmt: _Text) -> str: ... - if sys.version_info >= (3,): - def __format__(self, fmt: str) -> str: ... - else: - def __format__(self, fmt: AnyStr) -> AnyStr: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... def toordinal(self) -> int: ... @@ -71,12 +45,8 @@ class date: def __lt__(self, other: date) -> bool: ... def __ge__(self, other: date) -> bool: ... def __gt__(self, other: date) -> bool: ... - if sys.version_info >= (3, 8): - def __add__(self: _S, other: timedelta) -> _S: ... - def __radd__(self: _S, other: timedelta) -> _S: ... - else: - def __add__(self, other: timedelta) -> date: ... - def __radd__(self, other: timedelta) -> date: ... + def __add__(self, other: timedelta) -> date: ... + def __radd__(self, other: timedelta) -> date: ... @overload def __sub__(self, other: timedelta) -> date: ... @overload @@ -84,31 +54,16 @@ class date: def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... - if sys.version_info >= (3, 9): - def isocalendar(self) -> _IsoCalendarDate: ... - else: - def isocalendar(self) -> Tuple[int, int, int]: ... + def isocalendar(self) -> Tuple[int, int, int]: ... class time: min: ClassVar[time] max: ClassVar[time] resolution: ClassVar[timedelta] - if sys.version_info >= (3, 6): - def __init__( - self, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> None: ... - else: - def __init__( - self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... - ) -> None: ... + def __init__( + self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... + ) -> None: ... @property def hour(self) -> int: ... @property @@ -119,44 +74,20 @@ class time: def microsecond(self) -> int: ... @property def tzinfo(self) -> Optional[_tzinfo]: ... - if sys.version_info >= (3, 6): - @property - def fold(self) -> int: ... 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: ... - if sys.version_info >= (3, 6): - def isoformat(self, timespec: str = ...) -> str: ... - else: - def isoformat(self) -> str: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: Type[_S], time_string: str) -> _S: ... + def isoformat(self) -> str: ... def strftime(self, fmt: _Text) -> str: ... - if sys.version_info >= (3,): - def __format__(self, fmt: str) -> str: ... - else: - def __format__(self, fmt: AnyStr) -> AnyStr: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def utcoffset(self) -> Optional[timedelta]: ... def tzname(self) -> Optional[str]: ... def dst(self) -> Optional[timedelta]: ... - if sys.version_info >= (3, 6): - def replace( - self, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> time: ... - else: - def replace( - self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... - ) -> time: ... + def replace( + self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... + ) -> time: ... _date = date _time = time @@ -166,30 +97,16 @@ class timedelta(SupportsAbs[timedelta]): max: ClassVar[timedelta] resolution: ClassVar[timedelta] - if sys.version_info >= (3, 6): - def __init__( - self, - days: float = ..., - seconds: float = ..., - microseconds: float = ..., - milliseconds: float = ..., - minutes: float = ..., - hours: float = ..., - weeks: float = ..., - *, - fold: int = ..., - ) -> None: ... - else: - def __init__( - self, - days: float = ..., - seconds: float = ..., - microseconds: float = ..., - milliseconds: float = ..., - minutes: float = ..., - hours: float = ..., - weeks: float = ..., - ) -> None: ... + def __init__( + self, + days: float = ..., + seconds: float = ..., + microseconds: float = ..., + milliseconds: float = ..., + minutes: float = ..., + hours: float = ..., + weeks: float = ..., + ) -> None: ... @property def days(self) -> int: ... @property @@ -210,18 +127,10 @@ class timedelta(SupportsAbs[timedelta]): def __floordiv__(self, other: timedelta) -> int: ... @overload def __floordiv__(self, other: int) -> timedelta: ... - if sys.version_info >= (3,): - @overload - def __truediv__(self, other: timedelta) -> float: ... - @overload - def __truediv__(self, other: float) -> timedelta: ... - def __mod__(self, other: timedelta) -> timedelta: ... - def __divmod__(self, other: timedelta) -> Tuple[int, timedelta]: ... - else: - @overload - def __div__(self, other: timedelta) -> float: ... - @overload - def __div__(self, other: float) -> 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: ... @@ -233,32 +142,17 @@ class datetime(date): max: ClassVar[datetime] resolution: ClassVar[timedelta] - if sys.version_info >= (3, 6): - def __new__( - cls: Type[_S], - year: int, - month: int, - day: int, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> _S: ... - else: - def __new__( - cls: Type[_S], - year: int, - month: int, - day: int, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - ) -> _S: ... + def __new__( + cls: Type[_S], + year: int, + month: int, + day: int, + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + ) -> _S: ... @property def year(self) -> int: ... @property @@ -275,9 +169,6 @@ class datetime(date): def microsecond(self) -> int: ... @property def tzinfo(self) -> Optional[_tzinfo]: ... - if sys.version_info >= (3, 6): - @property - def fold(self) -> int: ... @classmethod def fromtimestamp(cls: Type[_S], t: float, tz: Optional[_tzinfo] = ...) -> _S: ... @classmethod @@ -286,77 +177,41 @@ class datetime(date): def today(cls: Type[_S]) -> _S: ... @classmethod def fromordinal(cls: Type[_S], n: int) -> _S: ... - if sys.version_info >= (3, 8): - @classmethod - def now(cls: Type[_S], tz: Optional[_tzinfo] = ...) -> _S: ... - else: - @overload - @classmethod - def now(cls: Type[_S], tz: None = ...) -> _S: ... - @overload - @classmethod - def now(cls, tz: _tzinfo) -> datetime: ... + @overload + @classmethod + def now(cls: Type[_S], tz: None = ...) -> _S: ... + @overload + @classmethod + def now(cls, tz: _tzinfo) -> datetime: ... @classmethod def utcnow(cls: Type[_S]) -> _S: ... - if sys.version_info >= (3, 6): - @classmethod - def combine(cls, date: _date, time: _time, tzinfo: Optional[_tzinfo] = ...) -> datetime: ... - else: - @classmethod - def combine(cls, date: _date, time: _time) -> datetime: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... + @classmethod + def combine(cls, date: _date, time: _time) -> datetime: ... def strftime(self, fmt: _Text) -> str: ... - if sys.version_info >= (3,): - def __format__(self, fmt: str) -> str: ... - else: - def __format__(self, fmt: AnyStr) -> AnyStr: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def toordinal(self) -> int: ... def timetuple(self) -> struct_time: ... - if sys.version_info >= (3, 3): - def timestamp(self) -> float: ... def utctimetuple(self) -> struct_time: ... def date(self) -> _date: ... def time(self) -> _time: ... def timetz(self) -> _time: ... - if sys.version_info >= (3, 6): - def replace( - self, - year: int = ..., - month: int = ..., - day: int = ..., - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> datetime: ... - else: - def replace( - self, - year: int = ..., - month: int = ..., - day: int = ..., - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - ) -> datetime: ... - if sys.version_info >= (3, 8): - def astimezone(self: _S, tz: Optional[_tzinfo] = ...) -> _S: ... + def replace( + self, + year: int = ..., + month: int = ..., + day: int = ..., + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + ) -> datetime: ... elif sys.version_info >= (3, 3): def astimezone(self, tz: Optional[_tzinfo] = ...) -> datetime: ... else: def astimezone(self, tz: _tzinfo) -> datetime: ... def ctime(self) -> str: ... - if sys.version_info >= (3, 6): - def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... - else: - def isoformat(self, sep: str = ...) -> str: ... + def isoformat(self, sep: str = ...) -> str: ... @classmethod def strptime(cls, date_string: _Text, format: _Text) -> datetime: ... def utcoffset(self) -> Optional[timedelta]: ... @@ -366,12 +221,8 @@ class datetime(date): def __lt__(self, other: datetime) -> bool: ... # type: ignore def __ge__(self, other: datetime) -> bool: ... # type: ignore def __gt__(self, other: datetime) -> bool: ... # type: ignore - if sys.version_info >= (3, 8): - def __add__(self: _S, other: timedelta) -> _S: ... - def __radd__(self: _S, other: timedelta) -> _S: ... - else: - def __add__(self, other: timedelta) -> datetime: ... - def __radd__(self, other: timedelta) -> datetime: ... + def __add__(self, other: timedelta) -> datetime: ... + def __radd__(self, other: timedelta) -> datetime: ... @overload # type: ignore def __sub__(self, other: datetime) -> timedelta: ... @overload @@ -379,7 +230,4 @@ class datetime(date): def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... - if sys.version_info >= (3, 9): - def isocalendar(self) -> _IsoCalendarDate: ... - else: - def isocalendar(self) -> Tuple[int, int, int]: ... + def isocalendar(self) -> Tuple[int, int, int]: ... diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index c3a671d4ba5f..ef5744a49cba 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -5,10 +5,7 @@ from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, T _Decimal = Union[Decimal, int] _DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] -if sys.version_info >= (3,): - _ComparableNum = Union[Decimal, float, numbers.Rational] -else: - _ComparableNum = Union[Decimal, float] +_ComparableNum = Union[Decimal, float] _DecimalT = TypeVar("_DecimalT", bound=Decimal) class DecimalTuple(NamedTuple): @@ -25,16 +22,8 @@ ROUND_UP: str ROUND_HALF_DOWN: str ROUND_05UP: str -if sys.version_info >= (3,): - HAVE_THREADS: bool - MAX_EMAX: int - MAX_PREC: int - MIN_EMIN: int - MIN_ETINY: int - class DecimalException(ArithmeticError): - if sys.version_info < (3,): - def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... + def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... class Clamped(DecimalException): ... class InvalidOperation(DecimalException): ... @@ -49,9 +38,6 @@ class Subnormal(DecimalException): ... class Overflow(Inexact, Rounded): ... class Underflow(Inexact, Rounded, Subnormal): ... -if sys.version_info >= (3,): - class FloatOperation(DecimalException, TypeError): ... - def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... @@ -60,69 +46,38 @@ class Decimal(object): def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... @classmethod def from_float(cls, __f: float) -> Decimal: ... - if sys.version_info >= (3,): - def __bool__(self) -> bool: ... - else: - def __nonzero__(self) -> bool: ... - def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... + def __nonzero__(self) -> bool: ... + def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... - if sys.version_info >= (3, 6): - def as_integer_ratio(self) -> Tuple[int, int]: ... def to_eng_string(self, context: Optional[Context] = ...) -> str: ... - if sys.version_info >= (3,): - def __abs__(self) -> Decimal: ... - def __add__(self, other: _Decimal) -> Decimal: ... - def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... - def __eq__(self, other: object) -> bool: ... - def __floordiv__(self, other: _Decimal) -> Decimal: ... - def __ge__(self, other: _ComparableNum) -> bool: ... - def __gt__(self, other: _ComparableNum) -> bool: ... - def __le__(self, other: _ComparableNum) -> bool: ... - def __lt__(self, other: _ComparableNum) -> bool: ... - def __mod__(self, other: _Decimal) -> Decimal: ... - def __mul__(self, other: _Decimal) -> Decimal: ... - def __neg__(self) -> Decimal: ... - def __pos__(self) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ... - def __radd__(self, other: _Decimal) -> Decimal: ... - def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... - def __rfloordiv__(self, other: _Decimal) -> Decimal: ... - def __rmod__(self, other: _Decimal) -> Decimal: ... - def __rmul__(self, other: _Decimal) -> Decimal: ... - def __rsub__(self, other: _Decimal) -> Decimal: ... - def __rtruediv__(self, other: _Decimal) -> Decimal: ... - def __str__(self) -> str: ... - def __sub__(self, other: _Decimal) -> Decimal: ... - def __truediv__(self, other: _Decimal) -> Decimal: ... - else: - def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... - def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... - def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... - def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... - def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... + def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... + def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... + def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... + def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... + def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... + def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... + def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... + def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __float__(self) -> float: ... def __int__(self) -> int: ... @@ -133,26 +88,14 @@ class Decimal(object): def imag(self) -> Decimal: ... def conjugate(self) -> Decimal: ... def __complex__(self) -> complex: ... - if sys.version_info >= (3,): - @overload - def __round__(self) -> int: ... - @overload - def __round__(self, ndigits: int) -> Decimal: ... - def __floor__(self) -> int: ... - def __ceil__(self) -> int: ... - else: - def __long__(self) -> long: ... + def __long__(self) -> long: ... def fma(self, other: _Decimal, third: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __rpow__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def normalize(self, context: Optional[Context] = ...) -> Decimal: ... - if sys.version_info >= (3,): - def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... - def same_quantum(self, other: _Decimal, context: Optional[Context] = ...) -> bool: ... - else: - def quantize( - self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ... - ) -> Decimal: ... - def same_quantum(self, other: _Decimal) -> bool: ... + def quantize( + self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ... + ) -> Decimal: ... + def same_quantum(self, other: _Decimal) -> bool: ... def to_integral_exact(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... def to_integral_value(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... def to_integral(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... @@ -160,23 +103,13 @@ class Decimal(object): def max(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def min(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def adjusted(self) -> int: ... - if sys.version_info >= (3,): - def canonical(self) -> Decimal: ... - else: - def canonical(self, context: Optional[Context] = ...) -> Decimal: ... + def canonical(self, context: Optional[Context] = ...) -> Decimal: ... def compare_signal(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - if sys.version_info >= (3,): - def compare_total(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def compare_total_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - else: - def compare_total(self, other: _Decimal) -> Decimal: ... - def compare_total_mag(self, other: _Decimal) -> 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: ... - if sys.version_info >= (3,): - def copy_sign(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - else: - def copy_sign(self, other: _Decimal) -> Decimal: ... + def copy_sign(self, other: _Decimal) -> Decimal: ... def exp(self, context: Optional[Context] = ...) -> Decimal: ... def is_canonical(self) -> bool: ... def is_finite(self) -> bool: ... @@ -225,46 +158,22 @@ class Context(object): Emin: int Emax: int capitals: int - if sys.version_info >= (3,): - clamp: int - else: - _clamp: int + _clamp: int traps: Dict[_TrapType, bool] flags: Dict[_TrapType, bool] - if sys.version_info >= (3,): - def __init__( - self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - clamp: Optional[int] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., - ) -> None: ... - else: - def __init__( - self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - _clamp: Optional[int] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., - ) -> None: ... - if sys.version_info >= (3,): - # __setattr__() only allows to set a specific set of attributes, - # already defined above. - def __delattr__(self, name: str) -> None: ... - def __reduce__(self) -> Tuple[Type[Context], Tuple[Any, ...]]: ... + def __init__( + self, + prec: Optional[int] = ..., + rounding: Optional[str] = ..., + traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + Emin: Optional[int] = ..., + Emax: Optional[int] = ..., + capitals: Optional[int] = ..., + _clamp: Optional[int] = ..., + _ignored_flags: Optional[List[_TrapType]] = ..., + ) -> None: ... def clear_flags(self) -> None: ... - if sys.version_info >= (3,): - def clear_traps(self) -> None: ... def copy(self) -> Context: ... def __copy__(self) -> Context: ... __hash__: Any = ... diff --git a/stdlib/@python2/difflib.pyi b/stdlib/@python2/difflib.pyi index 572972ccda9e..d615f3c873da 100644 --- a/stdlib/@python2/difflib.pyi +++ b/stdlib/@python2/difflib.pyi @@ -17,16 +17,10 @@ from typing import ( overload, ) -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") -if sys.version_info >= (3,): - _StrType = Text -else: - # Aliases can't point to type vars, so we need to redeclare AnyStr - _StrType = TypeVar("_StrType", Text, bytes) +# Aliases can't point to type vars, so we need to redeclare AnyStr +_StrType = TypeVar("_StrType", Text, bytes) _JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]] @@ -42,21 +36,13 @@ class SequenceMatcher(Generic[_T]): 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: ... - if sys.version_info >= (3, 9): - def find_longest_match( - self, alo: int = ..., ahi: Optional[int] = ..., blo: int = ..., bhi: Optional[int] = ... - ) -> Match: ... - else: - def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ... + 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: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - # mypy thinks the signatures of the overloads overlap, but the types still work fine @overload def get_close_matches( # type: ignore @@ -105,28 +91,15 @@ class HtmlDiff(object): linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ..., ) -> None: ... - if sys.version_info >= (3, 5): - def make_file( - self, - fromlines: Sequence[_StrType], - tolines: Sequence[_StrType], - fromdesc: _StrType = ..., - todesc: _StrType = ..., - context: bool = ..., - numlines: int = ..., - *, - charset: str = ..., - ) -> _StrType: ... - else: - def make_file( - self, - fromlines: Sequence[_StrType], - tolines: Sequence[_StrType], - fromdesc: _StrType = ..., - todesc: _StrType = ..., - context: bool = ..., - numlines: int = ..., - ) -> _StrType: ... + 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], @@ -139,15 +112,3 @@ class HtmlDiff(object): def restore(delta: Iterable[_StrType], which: int) -> Iterator[_StrType]: ... -if sys.version_info >= (3, 5): - def diff_bytes( - dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]], - a: Sequence[bytes], - b: Sequence[bytes], - fromfile: bytes = ..., - tofile: bytes = ..., - fromfiledate: bytes = ..., - tofiledate: bytes = ..., - n: int = ..., - lineterm: bytes = ..., - ) -> Iterator[bytes]: ... diff --git a/stdlib/@python2/dis.pyi b/stdlib/@python2/dis.pyi index b52d0ed624f6..b5c0b4d7c1e1 100644 --- a/stdlib/@python2/dis.pyi +++ b/stdlib/@python2/dis.pyi @@ -16,68 +16,24 @@ from opcode import ( ) from typing import IO, Any, Callable, Dict, Iterator, List, NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3, 4): - from opcode import stack_effect as stack_effect - -if sys.version_info >= (3, 6): - from opcode import hasnargs as hasnargs - # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) _have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type, Callable[..., Any]] _have_code_or_string = Union[_have_code, str, bytes] -if sys.version_info >= (3, 4): - class Instruction(NamedTuple): - opname: str - opcode: int - arg: Optional[int] - argval: Any - argrepr: str - offset: int - starts_line: Optional[int] - is_jump_target: bool - class Bytecode: - codeobj: types.CodeType - first_line: int - def __init__( - self, x: _have_code_or_string, *, first_line: Optional[int] = ..., current_offset: Optional[int] = ... - ) -> None: ... - def __iter__(self) -> Iterator[Instruction]: ... - def __repr__(self) -> str: ... - def info(self) -> str: ... - def dis(self) -> str: ... - @classmethod - def from_traceback(cls, tb: types.TracebackType) -> Bytecode: ... - COMPILER_FLAG_NAMES: Dict[int, str] def findlabels(code: _have_code) -> List[int]: ... def findlinestarts(code: _have_code) -> Iterator[Tuple[int, int]]: ... -if sys.version_info >= (3, 0): - def pretty_flags(flags: int) -> str: ... - def code_info(x: _have_code_or_string) -> str: ... - -if sys.version_info >= (3, 7): - def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ..., depth: Optional[int] = ...) -> None: ... - elif sys.version_info >= (3, 4): def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ...) -> None: ... else: def dis(x: _have_code_or_string = ...) -> None: ... -if sys.version_info >= (3, 4): - def distb(tb: Optional[types.TracebackType] = ..., *, file: Optional[IO[str]] = ...) -> None: ... - def disassemble(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... - def disco(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... - def show_code(co: _have_code, *, file: Optional[IO[str]] = ...) -> None: ... - def get_instructions(x: _have_code, *, first_line: Optional[int] = ...) -> Iterator[Instruction]: ... - -else: - def distb(tb: types.TracebackType = ...) -> None: ... - def disassemble(co: _have_code, lasti: int = ...) -> None: ... - def disco(co: _have_code, lasti: int = ...) -> None: ... - if sys.version_info >= (3, 0): - def show_code(co: _have_code) -> None: ... +def distb(tb: types.TracebackType = ...) -> None: ... +def disassemble(co: _have_code, lasti: int = ...) -> None: ... +def disco(co: _have_code, lasti: int = ...) -> None: ... +if sys.version_info >= (3, 0): + def show_code(co: _have_code) -> None: ... diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index ae84c2c25efc..5e10f2c5ecea 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -24,9 +24,6 @@ REPORT_UDIFF: int REPORT_CDIFF: int REPORT_NDIFF: int REPORT_ONLY_FIRST_FAILURE: int -if sys.version_info >= (3, 4): - FAIL_FAST: int - REPORTING_FLAGS: int BLANKLINE_MARKER: str @@ -189,11 +186,7 @@ class SkipDocTestCase(DocTestCase): def test_skip(self) -> None: ... def shortDescription(self) -> str: ... -if sys.version_info >= (3, 4): - class _DocTestSuite(unittest.TestSuite): ... - -else: - _DocTestSuite = unittest.TestSuite +_DocTestSuite = unittest.TestSuite def DocTestSuite( module: Union[None, str, types.ModuleType] = ..., diff --git a/stdlib/@python2/ensurepip/__init__.pyi b/stdlib/@python2/ensurepip/__init__.pyi index a411dbb456d2..83fd43ff002e 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -3,23 +3,11 @@ from typing import Optional def version() -> str: ... -if sys.version_info >= (3, 0): - def bootstrap( - *, - root: Optional[str] = ..., - upgrade: bool = ..., - user: bool = ..., - altinstall: bool = ..., - default_pip: bool = ..., - verbosity: int = ..., - ) -> None: ... - -else: - def bootstrap( - root: Optional[str] = ..., - upgrade: bool = ..., - user: bool = ..., - altinstall: bool = ..., - default_pip: bool = ..., - verbosity: int = ..., - ) -> None: ... +def bootstrap( + root: Optional[str] = ..., + upgrade: bool = ..., + user: bool = ..., + altinstall: bool = ..., + default_pip: bool = ..., + verbosity: int = ..., +) -> None: ... diff --git a/stdlib/@python2/filecmp.pyi b/stdlib/@python2/filecmp.pyi index b05eebac07c9..5767ada0bd08 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -1,44 +1,17 @@ import sys from typing import Any, AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Text, Tuple, Union -if sys.version_info >= (3, 6): - from os import PathLike - -if sys.version_info >= (3, 9): - from types import GenericAlias - DEFAULT_IGNORES: List[str] -if sys.version_info >= (3, 6): - def cmp( - f1: Union[bytes, Text, PathLike[AnyStr]], f2: Union[bytes, Text, PathLike[AnyStr]], shallow: Union[int, bool] = ... - ) -> bool: ... - def cmpfiles( - a: Union[AnyStr, PathLike[AnyStr]], - b: Union[AnyStr, PathLike[AnyStr]], - common: Iterable[AnyStr], - shallow: Union[int, bool] = ..., - ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... - -else: - def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ... - def cmpfiles( - a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: Union[int, bool] = ... - ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... +def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ... +def cmpfiles( + a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: Union[int, bool] = ... +) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... class dircmp(Generic[AnyStr]): - if sys.version_info >= (3, 6): - def __init__( - self, - a: Union[AnyStr, PathLike[AnyStr]], - b: Union[AnyStr, PathLike[AnyStr]], - ignore: Optional[Sequence[AnyStr]] = ..., - hide: Optional[Sequence[AnyStr]] = ..., - ) -> None: ... - else: - def __init__( - self, a: AnyStr, b: AnyStr, ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ... - ) -> None: ... + def __init__( + self, a: AnyStr, b: AnyStr, ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ... + ) -> None: ... left: AnyStr right: AnyStr hide: Sequence[AnyStr] @@ -66,8 +39,3 @@ class dircmp(Generic[AnyStr]): def phase3(self) -> None: ... def phase4(self) -> None: ... def phase4_closure(self) -> None: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - -if sys.version_info >= (3,): - def clear_cache() -> None: ... diff --git a/stdlib/@python2/fileinput.pyi b/stdlib/@python2/fileinput.pyi index fbb602b3bf45..bd6050523553 100644 --- a/stdlib/@python2/fileinput.pyi +++ b/stdlib/@python2/fileinput.pyi @@ -2,25 +2,14 @@ import sys from _typeshed import AnyPath from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Optional, Union -if sys.version_info >= (3, 8): - def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., - inplace: bool = ..., - backup: str = ..., - *, - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> FileInput[AnyStr]: ... - -else: - def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> FileInput[AnyStr]: ... +def input( + files: Union[AnyPath, Iterable[AnyPath], None] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., +) -> FileInput[AnyStr]: ... def close() -> None: ... def nextfile() -> None: ... @@ -32,31 +21,17 @@ def isfirstline() -> bool: ... def isstdin() -> bool: ... class FileInput(Iterable[AnyStr], Generic[AnyStr]): - if sys.version_info >= (3, 8): - def __init__( - self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., - inplace: bool = ..., - backup: str = ..., - *, - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> None: ... - else: - def __init__( - self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> None: ... + def __init__( + self, + files: Union[None, AnyPath, Iterable[AnyPath]] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... - if sys.version_info >= (3, 2): - def __enter__(self) -> FileInput[AnyStr]: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... def __iter__(self) -> Iterator[AnyStr]: ... def __next__(self) -> AnyStr: ... def __getitem__(self, i: int) -> AnyStr: ... @@ -71,8 +46,4 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): def hook_compressed(filename: AnyPath, mode: str) -> IO[Any]: ... -if sys.version_info >= (3, 6): - def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[AnyPath, str], IO[Any]]: ... - -else: - def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... +def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index 75cfa48a1cf6..a51fcda41e3e 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -7,15 +7,14 @@ from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] _T = TypeVar("_T") -if sys.version_info < (3, 9): - @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: ... +@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 @@ -33,8 +32,6 @@ class Fraction(Rational): @classmethod def from_decimal(cls, dec: Decimal) -> Fraction: ... def limit_denominator(self, max_denominator: int = ...) -> Fraction: ... - if sys.version_info >= (3, 8): - def as_integer_ratio(self) -> Tuple[int, int]: ... @property def numerator(self) -> int: ... @property @@ -87,19 +84,18 @@ class Fraction(Rational): def __rtruediv__(self, other: float) -> float: ... @overload def __rtruediv__(self, other: complex) -> complex: ... - if sys.version_info < (3, 0): - @overload - def __div__(self, other: Union[int, Fraction]) -> Fraction: ... - @overload - def __div__(self, other: float) -> float: ... - @overload - def __div__(self, other: complex) -> complex: ... - @overload - def __rdiv__(self, other: Union[int, Fraction]) -> Fraction: ... - @overload - def __rdiv__(self, other: float) -> float: ... - @overload - def __rdiv__(self, other: complex) -> complex: ... + @overload + def __div__(self, other: Union[int, Fraction]) -> Fraction: ... + @overload + def __div__(self, other: float) -> float: ... + @overload + def __div__(self, other: complex) -> complex: ... + @overload + def __rdiv__(self, other: Union[int, Fraction]) -> Fraction: ... + @overload + def __rdiv__(self, other: float) -> float: ... + @overload + def __rdiv__(self, other: complex) -> complex: ... @overload def __floordiv__(self, other: Union[int, Fraction]) -> int: ... @overload @@ -138,23 +134,13 @@ class Fraction(Rational): def __neg__(self) -> Fraction: ... def __abs__(self) -> Fraction: ... def __trunc__(self) -> int: ... - if sys.version_info >= (3, 0): - def __floor__(self) -> int: ... - def __ceil__(self) -> int: ... - @overload - def __round__(self, ndigits: None = ...) -> int: ... - @overload - def __round__(self, ndigits: int) -> Fraction: ... 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: ... - if sys.version_info >= (3, 0): - def __bool__(self) -> bool: ... - else: - def __nonzero__(self) -> bool: ... + def __nonzero__(self) -> bool: ... # Not actually defined within fractions.py, but provides more useful # overrides @property diff --git a/stdlib/@python2/ftplib.pyi b/stdlib/@python2/ftplib.pyi index bdb1716549c0..7658630f2b58 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -13,9 +13,6 @@ MSG_OOB: int FTP_PORT: int MAXLINE: int CRLF: str -if sys.version_info >= (3,): - B_CRLF: bytes - class Error(Exception): ... class error_reply(Error): ... class error_temp(Error): ... @@ -40,35 +37,12 @@ class FTP: af: int lastresp: str - if sys.version_info >= (3,): - file: Optional[TextIO] - encoding: str - def __enter__(self: _T) -> _T: ... - def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> None: ... - else: - file: Optional[BinaryIO] + file: Optional[BinaryIO] - if sys.version_info >= (3, 3): - source_address: Optional[Tuple[str, int]] - def __init__( - self, - host: Text = ..., - user: Text = ..., - passwd: Text = ..., - acct: Text = ..., - timeout: float = ..., - source_address: Optional[Tuple[str, int]] = ..., - ) -> None: ... - def connect( - self, host: Text = ..., port: int = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ... - ) -> str: ... - else: - 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 __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: ... @@ -108,8 +82,6 @@ class FTP: def nlst(self, *args: Text) -> List[str]: ... # Technically only the last arg can be a Callable but ... def dir(self, *args: Union[str, Callable[[str], None]]) -> None: ... - if sys.version_info >= (3, 3): - def mlsd(self, path: Text = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, Dict[str, str]]]: ... def rename(self, fromname: Text, toname: Text) -> str: ... def delete(self, filename: Text) -> str: ... def cwd(self, dirname: Text) -> str: ... @@ -141,16 +113,12 @@ class FTP_TLS(FTP): def auth(self) -> str: ... def prot_p(self) -> str: ... def prot_c(self) -> str: ... - if sys.version_info >= (3, 3): - def ccc(self) -> str: ... - -if sys.version_info < (3,): - class Netrc: - def __init__(self, filename: Optional[Text] = ...) -> None: ... - def get_hosts(self) -> List[str]: ... - def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ... - def get_macros(self) -> List[str]: ... - def get_macro(self, macro: Text) -> Tuple[str, ...]: ... +class Netrc: + def __init__(self, filename: Optional[Text] = ...) -> None: ... + def get_hosts(self) -> List[str]: ... + def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ... + def get_macros(self) -> List[str]: ... + def get_macro(self, macro: Text) -> Tuple[str, ...]: ... def parse150(resp: str) -> Optional[int]: ... # undocumented def parse227(resp: str) -> Tuple[str, int]: ... # undocumented diff --git a/stdlib/@python2/genericpath.pyi b/stdlib/@python2/genericpath.pyi index 17a0df575c56..04b9884998e4 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -26,7 +26,3 @@ def getatime(filename: AnyPath) -> float: ... def getmtime(filename: AnyPath) -> float: ... def getctime(filename: AnyPath) -> float: ... -if sys.version_info >= (3, 4): - def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... - def sameopenfile(fp1: int, fp2: int) -> bool: ... - def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/@python2/hmac.pyi b/stdlib/@python2/hmac.pyi index ca4013da7879..e300307c664d 100644 --- a/stdlib/@python2/hmac.pyi +++ b/stdlib/@python2/hmac.pyi @@ -9,14 +9,6 @@ _DigestMod = Union[str, Callable[[], _Hash], ModuleType] digest_size: None -if sys.version_info >= (3, 8): - # In reality digestmod has a default value, but the function always throws an error - # if the argument is not given, so we pretend it is a required argument. - @overload - def new(key: bytes, msg: Optional[ReadableBuffer], digestmod: _DigestMod) -> HMAC: ... - @overload - def new(key: bytes, *, digestmod: _DigestMod) -> HMAC: ... - elif sys.version_info >= (3, 4): def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... @@ -24,11 +16,6 @@ else: def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... class HMAC: - if sys.version_info >= (3,): - digest_size: int - if sys.version_info >= (3, 4): - block_size: int - name: str def __init__(self, key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: _DigestMod = ...) -> None: ... def update(self, msg: ReadableBuffer) -> None: ... def digest(self) -> bytes: ... @@ -40,5 +27,3 @@ 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: str) -> bytes: ... diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index bb9e9c6db132..2b60cba7b2a6 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -31,12 +31,8 @@ class IMAP4: welcome: bytes = ... capabilities: Tuple[str] = ... PROTOCOL_VERSION: str = ... - if sys.version_info >= (3, 9): - def __init__(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... - def open(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... - else: - def __init__(self, host: str = ..., port: int = ...) -> None: ... - def open(self, host: str = ..., port: int = ...) -> None: ... + 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 = ... @@ -58,10 +54,6 @@ class IMAP4: def create(self, mailbox: str) -> _CommandResults: ... def delete(self, mailbox: str) -> _CommandResults: ... def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... - if sys.version_info >= (3, 5): - def enable(self, capability: str) -> _CommandResults: ... - def __enter__(self) -> IMAP4: ... - def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... @@ -85,32 +77,18 @@ class IMAP4: 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: ... - if sys.version_info >= (3,): - def starttls(self, ssl_context: Optional[Any] = ...) -> Tuple[Literal["OK"], List[None]]: ... 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: ... - if sys.version_info >= (3, 9): - def unselect(self) -> _CommandResults: ... def xatom(self, name: str, *args: str) -> _CommandResults: ... def print_log(self) -> None: ... class IMAP4_SSL(IMAP4): keyfile: str = ... certfile: str = ... - if sys.version_info >= (3, 9): - def __init__( - self, - host: str = ..., - port: int = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - ssl_context: Optional[SSLContext] = ..., - timeout: Optional[float] = ..., - ) -> None: ... elif sys.version_info >= (3, 3): def __init__( self, @@ -129,10 +107,7 @@ class IMAP4_SSL(IMAP4): sock: _socket = ... sslobj: SSLSocket = ... file: IO[Any] = ... - if sys.version_info >= (3, 9): - def open(self, host: str = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... - else: - def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... + def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... @@ -150,10 +125,7 @@ class IMAP4_stream(IMAP4): process: subprocess.Popen[bytes] = ... writefile: IO[Any] = ... readfile: IO[Any] = ... - if sys.version_info >= (3, 9): - def open(self, host: Optional[str] = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... - else: - def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ... + def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... diff --git a/stdlib/@python2/imghdr.pyi b/stdlib/@python2/imghdr.pyi index ffdbbf20e97b..77b1fc75e583 100644 --- a/stdlib/@python2/imghdr.pyi +++ b/stdlib/@python2/imghdr.pyi @@ -7,10 +7,7 @@ class _ReadableBinary(Protocol): def read(self, size: int) -> bytes: ... def seek(self, offset: int) -> Any: ... -if sys.version_info >= (3, 6): - _File = Union[Text, os.PathLike[Text], _ReadableBinary] -else: - _File = Union[Text, _ReadableBinary] +_File = Union[Text, _ReadableBinary] @overload def what(file: _File, h: None = ...) -> Optional[str]: ... diff --git a/stdlib/@python2/ipaddress.pyi b/stdlib/@python2/ipaddress.pyi index b4e2b2c4b3f9..a742ac76be7d 100644 --- a/stdlib/@python2/ipaddress.pyi +++ b/stdlib/@python2/ipaddress.pyi @@ -87,9 +87,6 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): def overlaps(self, other: _BaseNetwork[_A]) -> bool: ... @property def prefixlen(self) -> int: ... - if sys.version_info >= (3, 7): - def subnet_of(self: _T, other: _T) -> bool: ... - def supernet_of(self: _T, other: _T) -> bool: ... def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ... def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ... @property diff --git a/stdlib/@python2/keyword.pyi b/stdlib/@python2/keyword.pyi index 3e095ed5f94c..fb113141222e 100644 --- a/stdlib/@python2/keyword.pyi +++ b/stdlib/@python2/keyword.pyi @@ -5,6 +5,3 @@ def iskeyword(s: Text) -> bool: ... kwlist: Sequence[str] -if sys.version_info >= (3, 9): - def issoftkeyword(s: str) -> bool: ... - softkwlist: Sequence[str] diff --git a/stdlib/@python2/lib2to3/pgen2/token.pyi b/stdlib/@python2/lib2to3/pgen2/token.pyi index 19660cb0ce26..a933c291b32d 100644 --- a/stdlib/@python2/lib2to3/pgen2/token.pyi +++ b/stdlib/@python2/lib2to3/pgen2/token.pyi @@ -54,13 +54,6 @@ DOUBLESLASHEQUAL: int OP: int COMMENT: int NL: int -if sys.version_info >= (3,): - RARROW: int -if sys.version_info >= (3, 5): - AT: int - ATEQUAL: int - AWAIT: int - ASYNC: int ERRORTOKEN: int N_TOKENS: int NT_OFFSET: int diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 955763588cd1..2f52b66d45c9 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -36,9 +36,8 @@ class Base: def leaves(self) -> Iterator[Leaf]: ... def depth(self) -> int: ... def get_suffix(self) -> Text: ... - if sys.version_info < (3,): - def get_prefix(self) -> Text: ... - def set_prefix(self, prefix: Text) -> None: ... + def get_prefix(self) -> Text: ... + def set_prefix(self, prefix: Text) -> None: ... class Node(Base): fixers_applied: List[Any] diff --git a/stdlib/@python2/linecache.pyi b/stdlib/@python2/linecache.pyi index f52267bdba98..62c94d4b9770 100644 --- a/stdlib/@python2/linecache.pyi +++ b/stdlib/@python2/linecache.pyi @@ -9,5 +9,3 @@ def getlines(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> def checkcache(filename: Optional[Text] = ...) -> None: ... def updatecache(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... -if sys.version_info >= (3, 5): - def lazycache(filename: Text, module_globals: _ModuleGlobals) -> bool: ... diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 9be4aa2735e1..1d1ec020e707 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -3,10 +3,7 @@ from decimal import Decimal from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union # workaround for mypy#2010 -if sys.version_info >= (3, 0): - from builtins import str as _str -else: - from __builtin__ import str as _str +from __builtin__ import str as _str CODESET: int D_T_FMT: int @@ -91,17 +88,10 @@ def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... def format(percent: _str, value: Union[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 = ...) -> _str: ... def currency(val: Union[int, float, Decimal], symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ... -if sys.version_info >= (3, 5): - def delocalize(string: _str) -> _str: ... - def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... def str(val: float) -> _str: ... diff --git a/stdlib/@python2/macpath.pyi b/stdlib/@python2/macpath.pyi index 296f3a9ba151..84c7b42539c9 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -11,9 +11,6 @@ from genericpath import ( isfile as isfile, ) -if sys.version_info >= (3, 4): - from genericpath import samefile as samefile, sameopenfile as sameopenfile, samestat as samestat - # Re-export common definitions from posixpath to reduce duplication from posixpath import ( abspath as abspath, @@ -36,45 +33,14 @@ from typing import AnyStr, Optional, Text, Tuple, overload altsep: Optional[str] -if sys.version_info >= (3, 6): - from os import PathLike - @overload - def basename(s: PathLike[AnyStr]) -> AnyStr: ... - @overload - def basename(s: AnyStr) -> AnyStr: ... - @overload - def dirname(s: PathLike[AnyStr]) -> AnyStr: ... - @overload - def dirname(s: AnyStr) -> AnyStr: ... - @overload - def normcase(path: PathLike[AnyStr]) -> AnyStr: ... - @overload - def normcase(path: AnyStr) -> AnyStr: ... - @overload - def normpath(s: PathLike[AnyStr]) -> AnyStr: ... - @overload - def normpath(s: AnyStr) -> AnyStr: ... - @overload - def realpath(path: PathLike[AnyStr]) -> AnyStr: ... - @overload - def realpath(path: AnyStr) -> AnyStr: ... - -else: - 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 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: AnyPath) -> bool: ... -if sys.version_info >= (3, 6): - # Mypy complains that the signatures overlap, but things seem to behave correctly anyway. - @overload - def join(s: StrPath, *paths: StrPath) -> Text: ... - @overload - def join(s: BytesPath, *paths: BytesPath) -> bytes: ... - elif sys.version_info >= (3, 0): def join(s: AnyStr, *paths: AnyStr) -> AnyStr: ... @@ -94,11 +60,4 @@ else: @overload def join(__p1: Text, *p: AnyPath) -> Text: ... -if sys.version_info >= (3, 6): - @overload - def split(s: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... - @overload - def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... - -else: - def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index d968e7d77244..3bef884d0d5e 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -25,9 +25,6 @@ from typing import ( ) from typing_extensions import Literal -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") _MessageT = TypeVar("_MessageT", bound=Message) _MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]] @@ -80,9 +77,6 @@ class Mailbox(Generic[_MessageT]): def lock(self) -> None: ... def unlock(self) -> None: ... def close(self) -> None: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - class Maildir(Mailbox[MaildirMessage]): colon: str @@ -190,9 +184,6 @@ class _ProxyFile(Generic[AnyStr]): def flush(self) -> None: ... @property def closed(self) -> bool: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - class _PartialFile(_ProxyFile[AnyStr]): def __init__(self, f: IO[AnyStr], start: Optional[int] = ..., stop: Optional[int] = ...) -> None: ... diff --git a/stdlib/@python2/math.pyi b/stdlib/@python2/math.pyi index 6f9a89996dc0..59819554ba7a 100644 --- a/stdlib/@python2/math.pyi +++ b/stdlib/@python2/math.pyi @@ -3,12 +3,6 @@ from typing import Iterable, Optional, SupportsFloat, SupportsInt, Tuple, overlo e: float pi: float -if sys.version_info >= (3, 5): - inf: float - nan: float -if sys.version_info >= (3, 6): - tau: float - def acos(__x: SupportsFloat) -> float: ... def acosh(__x: SupportsFloat) -> float: ... def asin(__x: SupportsFloat) -> float: ... @@ -17,23 +11,13 @@ def atan(__x: SupportsFloat) -> float: ... def atan2(__y: SupportsFloat, __x: SupportsFloat) -> float: ... def atanh(__x: SupportsFloat) -> float: ... -if sys.version_info >= (3,): - def ceil(__x: SupportsFloat) -> int: ... - -else: - def ceil(__x: SupportsFloat) -> float: ... - -if sys.version_info >= (3, 8): - def comb(__n: int, __k: int) -> int: ... +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: ... -if sys.version_info >= (3, 8): - def dist(__p: Iterable[SupportsFloat], __q: Iterable[SupportsFloat]) -> float: ... - def erf(__x: SupportsFloat) -> float: ... def erfc(__x: SupportsFloat) -> float: ... def exp(__x: SupportsFloat) -> float: ... @@ -41,75 +25,34 @@ def expm1(__x: SupportsFloat) -> float: ... def fabs(__x: SupportsFloat) -> float: ... def factorial(__x: SupportsInt) -> int: ... -if sys.version_info >= (3,): - def floor(__x: SupportsFloat) -> int: ... - -else: - def floor(__x: SupportsFloat) -> float: ... +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: ... -if sys.version_info >= (3, 9): - def gcd(*integers: int) -> int: ... - elif sys.version_info >= (3, 5): def gcd(__x: int, __y: int) -> int: ... -if sys.version_info >= (3, 8): - def hypot(*coordinates: SupportsFloat) -> float: ... - -else: - def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... - -if sys.version_info >= (3, 5): - def isclose(a: SupportsFloat, b: SupportsFloat, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... +def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... def isinf(__x: SupportsFloat) -> bool: ... -if sys.version_info >= (3,): - def isfinite(__x: SupportsFloat) -> bool: ... - def isnan(__x: SupportsFloat) -> bool: ... -if sys.version_info >= (3, 8): - def isqrt(__n: int) -> int: ... - -if sys.version_info >= (3, 9): - def lcm(*integers: int) -> int: ... - 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: ... -if sys.version_info >= (3, 3): - def log2(__x: SupportsFloat) -> float: ... - def modf(__x: SupportsFloat) -> Tuple[float, float]: ... -if sys.version_info >= (3, 9): - def nextafter(__x: SupportsFloat, __y: SupportsFloat) -> float: ... - -if sys.version_info >= (3, 8): - def perm(__n: int, __k: Optional[int] = ...) -> int: ... - def pow(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -if sys.version_info >= (3, 8): - @overload - def prod(__iterable: Iterable[int], *, start: int = ...) -> int: ... # type: ignore - @overload - def prod(__iterable: Iterable[SupportsFloat], *, start: SupportsFloat = ...) -> float: ... - def radians(__x: SupportsFloat) -> float: ... -if sys.version_info >= (3, 7): - def remainder(__x: SupportsFloat, __y: SupportsFloat) -> float: ... - def sin(__x: SupportsFloat) -> float: ... def sinh(__x: SupportsFloat) -> float: ... def sqrt(__x: SupportsFloat) -> float: ... @@ -117,5 +60,3 @@ def tan(__x: SupportsFloat) -> float: ... def tanh(__x: SupportsFloat) -> float: ... def trunc(__x: SupportsFloat) -> int: ... -if sys.version_info >= (3, 9): - def ulp(__x: SupportsFloat) -> float: ... diff --git a/stdlib/@python2/mimetypes.pyi b/stdlib/@python2/mimetypes.pyi index f0cfac32cafd..f4c7b6132d2f 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -1,12 +1,7 @@ import sys from typing import IO, Dict, List, Optional, Sequence, Text, Tuple, Union -if sys.version_info >= (3, 8): - from os import PathLike - def guess_type(url: Union[Text, PathLike[str]], strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... - -else: - def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... +def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> Optional[str]: ... diff --git a/stdlib/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index 0ba69e5896d7..485ddcdc2545 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -34,10 +34,7 @@ class _mmap(Generic[AnyStr]): self, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = ..., offset: int = ... ) -> None: ... def close(self) -> None: ... - if sys.version_info >= (3, 8): - def flush(self, offset: int = ..., size: int = ...) -> None: ... - else: - def flush(self, offset: int = ..., size: int = ...) -> int: ... + def flush(self, offset: int = ..., size: int = ...) -> int: ... def move(self, dest: int, src: int, count: int) -> None: ... def read_byte(self) -> AnyStr: ... def readline(self) -> AnyStr: ... @@ -48,73 +45,13 @@ class _mmap(Generic[AnyStr]): def write_byte(self, byte: AnyStr) -> None: ... def __len__(self) -> int: ... -if sys.version_info >= (3,): - class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], Sized): - closed: bool - if sys.version_info >= (3, 8) and sys.platform != "win32": - def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ... - def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def read(self, n: Optional[int] = ...) -> bytes: ... - if sys.version_info >= (3, 6): - def write(self, bytes: ReadableBuffer) -> int: ... - else: - def write(self, bytes: ReadableBuffer) -> None: ... - @overload - def __getitem__(self, index: int) -> int: ... - @overload - def __getitem__(self, index: slice) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... - @overload - def __setitem__(self, index: int, object: int) -> None: ... - @overload - def __setitem__(self, index: slice, object: bytes) -> None: ... - # Doesn't actually exist, but the object is actually iterable because it has __getitem__ and - # __len__, so we claim that there is also an __iter__ to help type checkers. - def __iter__(self) -> Iterator[bytes]: ... - -else: - class mmap(_mmap[bytes], Sequence[bytes]): - 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: Union[int, slice]) -> bytes: ... - def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... - def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... - -if sys.version_info >= (3, 8) and sys.platform != "win32": - MADV_NORMAL: int - MADV_RANDOM: int - MADV_SEQUENTIAL: int - MADV_WILLNEED: int - MADV_DONTNEED: int - - if sys.platform == "linux": - MADV_REMOVE: int - MADV_DONTFORK: int - MADV_DOFORK: int - MADV_HWPOISON: int - MADV_MERGEABLE: int - MADV_UNMERGEABLE: int - # Seems like this constant is not defined in glibc. - # See https://github.com/python/typeshed/pull/5360 for details - # MADV_SOFT_OFFLINE: int - MADV_HUGEPAGE: int - MADV_NOHUGEPAGE: int - MADV_DONTDUMP: int - MADV_DODUMP: int - MADV_FREE: int - - # This Values are defined for FreeBSD but type checkers do not support conditions for these - if sys.platform != "linux" and sys.platform != "darwin": - MADV_NOSYNC: int - MADV_AUTOSYNC: int - MADV_NOCORE: int - MADV_CORE: int - MADV_PROTECT: int +class mmap(_mmap[bytes], Sequence[bytes]): + 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: Union[int, slice]) -> bytes: ... + def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... + def __delitem__(self, index: Union[int, slice]) -> None: ... + def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... -if sys.version_info >= (3, 10) and sys.platform == "darwin": - MADV_FREE_REUSABLE: int - MADV_FREE_REUSE: int diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index 89119b6029df..b8884b8b62bf 100644 --- a/stdlib/@python2/modulefinder.pyi +++ b/stdlib/@python2/modulefinder.pyi @@ -31,22 +31,13 @@ class ModuleFinder: excludes: Container[str] # undocumented replace_paths: Sequence[Tuple[str, str]] # undocumented - if sys.version_info >= (3, 8): - def __init__( - self, - path: Optional[List[str]] = ..., - debug: int = ..., - excludes: Optional[Container[str]] = ..., - replace_paths: Optional[Sequence[Tuple[str, str]]] = ..., - ) -> None: ... - else: - def __init__( - self, - path: Optional[List[str]] = ..., - debug: int = ..., - excludes: Container[str] = ..., - replace_paths: Sequence[Tuple[str, str]] = ..., - ) -> None: ... + def __init__( + self, + path: Optional[List[str]] = ..., + 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 @@ -62,8 +53,6 @@ class ModuleFinder: def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented def import_module(self, partname: str, fqname: str, parent: Module) -> Optional[Module]: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: Tuple[str, str, str]) -> Module: ... # undocumented - if sys.version_info >= (3, 6): - def scan_opcodes(self, co: CodeType) -> Iterator[Tuple[str, Tuple[Any, ...]]]: ... # 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 diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index 0442ffaaec83..c783493f315e 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -7,8 +7,7 @@ if sys.platform == "win32": from _msi import _Database AMD64: bool - if sys.version_info < (3, 7): - Itanium: bool + Itanium: bool Win64: bool datasizemask: Literal[0x00FF] diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index 36fe063c8486..cb52934f9f17 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -74,9 +74,8 @@ class _NNTPBase: def over( self, message_spec: Union[None, str, List[Any], Tuple[Any, ...]], *, file: _File = ... ) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... - if sys.version_info < (3, 9): - def xgtitle(self, group: str, *, file: _File = ...) -> Tuple[str, List[Tuple[str, str]]]: ... - def xpath(self, id: Any) -> Tuple[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: Union[bytes, Iterable[bytes]]) -> str: ... def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ... diff --git a/stdlib/@python2/numbers.pyi b/stdlib/@python2/numbers.pyi index 4f8a5a5d67fc..796b44366aa3 100644 --- a/stdlib/@python2/numbers.pyi +++ b/stdlib/@python2/numbers.pyi @@ -12,10 +12,7 @@ class Number(metaclass=ABCMeta): class Complex(Number): @abstractmethod def __complex__(self) -> complex: ... - if sys.version_info >= (3, 0): - def __bool__(self) -> bool: ... - else: - def __nonzero__(self) -> bool: ... + def __nonzero__(self) -> bool: ... @property @abstractmethod def real(self) -> Any: ... @@ -36,11 +33,10 @@ class Complex(Number): def __mul__(self, other: Any) -> Any: ... @abstractmethod def __rmul__(self, other: Any) -> Any: ... - if sys.version_info < (3, 0): - @abstractmethod - def __div__(self, other): ... - @abstractmethod - def __rdiv__(self, other): ... + @abstractmethod + def __div__(self, other): ... + @abstractmethod + def __rdiv__(self, other): ... @abstractmethod def __truediv__(self, other: Any) -> Any: ... @abstractmethod @@ -52,25 +48,13 @@ class Complex(Number): def __abs__(self) -> Real: ... def conjugate(self) -> Any: ... def __eq__(self, other: Any) -> bool: ... - if sys.version_info < (3, 0): - def __ne__(self, other: Any) -> bool: ... + def __ne__(self, other: Any) -> bool: ... class Real(Complex, SupportsFloat): @abstractmethod def __float__(self) -> float: ... @abstractmethod def __trunc__(self) -> int: ... - if sys.version_info >= (3, 0): - @abstractmethod - def __floor__(self) -> int: ... - @abstractmethod - def __ceil__(self) -> int: ... - @abstractmethod - @overload - def __round__(self, ndigits: None = ...) -> int: ... - @abstractmethod - @overload - def __round__(self, ndigits: int) -> Any: ... def __divmod__(self, other: Any) -> Any: ... def __rdivmod__(self, other: Any) -> Any: ... @abstractmethod @@ -102,12 +86,8 @@ class Rational(Real): def __float__(self) -> float: ... class Integral(Rational): - if sys.version_info >= (3, 0): - @abstractmethod - def __int__(self) -> int: ... - else: - @abstractmethod - def __long__(self) -> long: ... + @abstractmethod + def __long__(self) -> long: ... def __index__(self) -> int: ... @abstractmethod def __pow__(self, exponent: Any, modulus: Optional[Any] = ...) -> Any: ... diff --git a/stdlib/@python2/opcode.pyi b/stdlib/@python2/opcode.pyi index 6307c280aebe..fc10d0148dce 100644 --- a/stdlib/@python2/opcode.pyi +++ b/stdlib/@python2/opcode.pyi @@ -15,11 +15,6 @@ opmap: Dict[str, int] HAVE_ARGUMENT: int EXTENDED_ARG: int -if sys.version_info >= (3, 8): - def stack_effect(__opcode: int, __oparg: Optional[int] = ..., *, jump: Optional[bool] = ...) -> int: ... - elif sys.version_info >= (3, 4): def stack_effect(__opcode: int, __oparg: Optional[int] = ...) -> int: ... -if sys.version_info >= (3, 6): - hasnargs: List[int] diff --git a/stdlib/@python2/operator.pyi b/stdlib/@python2/operator.pyi index 03510fed90fc..0bbf22c9a2c8 100644 --- a/stdlib/@python2/operator.pyi +++ b/stdlib/@python2/operator.pyi @@ -42,9 +42,8 @@ def __add__(a: Any, b: Any) -> Any: ... def and_(__a: Any, __b: Any) -> Any: ... def __and__(a: Any, b: Any) -> Any: ... -if sys.version_info < (3,): - def div(a: Any, b: Any) -> Any: ... - def __div__(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: ... @@ -61,10 +60,6 @@ def __mod__(a: Any, b: Any) -> Any: ... def mul(__a: Any, __b: Any) -> Any: ... def __mul__(a: Any, b: Any) -> Any: ... -if sys.version_info >= (3, 5): - def matmul(__a: Any, __b: Any) -> Any: ... - def __matmul__(a: Any, b: Any) -> Any: ... - def neg(__a: Any) -> Any: ... def __neg__(a: Any) -> Any: ... def or_(__a: Any, __b: Any) -> Any: ... @@ -99,9 +94,8 @@ def __delitem__(a: MutableSequence[Any], b: slice) -> None: ... @overload def __delitem__(a: MutableMapping[_K, Any], b: _K) -> None: ... -if sys.version_info < (3,): - def delslice(a: MutableSequence[Any], b: int, c: int) -> None: ... - def __delslice__(a: MutableSequence[Any], b: int, c: int) -> 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: ... @@ -116,18 +110,15 @@ def __getitem__(a: Sequence[_T], b: slice) -> Sequence[_T]: ... @overload def __getitem__(a: Mapping[_K, _V], b: _K) -> _V: ... -if sys.version_info < (3,): - def getslice(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ... - def __getslice__(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ... +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: ... -if sys.version_info < (3,): - def repeat(a: Any, b: int) -> Any: ... - def __repeat__(a: Any, b: int) -> Any: ... +def repeat(a: Any, b: int) -> Any: ... +def __repeat__(a: Any, b: int) -> Any: ... -if sys.version_info < (3,): - def sequenceIncludes(a: Container[Any], b: Any) -> bool: ... +def sequenceIncludes(a: Container[Any], b: Any) -> bool: ... @overload def setitem(__a: MutableSequence[_T], __b: int, __c: _T) -> None: ... @@ -142,12 +133,8 @@ def __setitem__(a: MutableSequence[_T], b: slice, c: Sequence[_T]) -> None: ... @overload def __setitem__(a: MutableMapping[_K, _V], b: _K, c: _V) -> None: ... -if sys.version_info < (3,): - 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: ... - -if sys.version_info >= (3, 4): - def length_hint(__obj: Any, __default: int = ...) -> int: ... +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 @@ -186,9 +173,8 @@ def __iand__(a: Any, b: Any) -> Any: ... def iconcat(__a: Any, __b: Any) -> Any: ... def __iconcat__(a: Any, b: Any) -> Any: ... -if sys.version_info < (3,): - def idiv(a: Any, b: Any) -> Any: ... - def __idiv__(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: ... @@ -199,18 +185,13 @@ def __imod__(a: Any, b: Any) -> Any: ... def imul(__a: Any, __b: Any) -> Any: ... def __imul__(a: Any, b: Any) -> Any: ... -if sys.version_info >= (3, 5): - def imatmul(__a: Any, __b: Any) -> Any: ... - def __imatmul__(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: ... -if sys.version_info < (3,): - def irepeat(a: Any, b: int) -> Any: ... - def __irepeat__(a: Any, b: int) -> 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: ... @@ -221,8 +202,7 @@ def __itruediv__(a: Any, b: Any) -> Any: ... def ixor(__a: Any, __b: Any) -> Any: ... def __ixor__(a: Any, b: Any) -> Any: ... -if sys.version_info < (3,): - def isCallable(x: Any) -> bool: ... - def isMappingType(x: Any) -> bool: ... - def isNumberType(x: Any) -> bool: ... - def isSequenceType(x: Any) -> bool: ... +def isCallable(x: Any) -> bool: ... +def isMappingType(x: Any) -> bool: ... +def isNumberType(x: Any) -> bool: ... +def isSequenceType(x: Any) -> bool: ... diff --git a/stdlib/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index 2229807bc641..6726d827aa4d 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -2,10 +2,7 @@ import sys from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] NO_DEFAULT: Tuple[_Text, ...] SUPPRESS_HELP: _Text @@ -14,8 +11,7 @@ SUPPRESS_USAGE: _Text def check_builtin(option: Option, opt: Any, value: _Text) -> Any: ... def check_choice(option: Option, opt: Any, value: _Text) -> Any: ... -if sys.version_info < (3,): - def isbasestring(x: Any) -> bool: ... +def isbasestring(x: Any) -> bool: ... class OptParseError(Exception): msg: _Text diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 7b32f5087495..3be2b0a24da1 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -37,15 +37,6 @@ _T = TypeVar("_T") error = OSError -if sys.version_info >= (3, 2): - supports_bytes_environ: bool - -if sys.version_info >= (3, 3): - supports_dir_fd: Set[Callable[..., Any]] - supports_fd: Set[Callable[..., Any]] - supports_effective_ids: Set[Callable[..., Any]] - supports_follow_symlinks: Set[Callable[..., Any]] - SEEK_SET: int SEEK_CUR: int SEEK_END: int @@ -110,9 +101,6 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): def __len__(self) -> int: ... environ: _Environ[str] -if sys.version_info >= (3, 2): - environb: _Environ[bytes] - if sys.platform != "win32": # Unix only confstr_names: Dict[str, int] @@ -245,11 +233,7 @@ def symlink(source: AnyPath, link_name: AnyPath) -> None: ... def unlink(path: AnyPath) -> None: ... # TODO: add ns, dir_fd, follow_symlinks argument -if sys.version_info >= (3, 0): - def utime(path: AnyPath, times: Optional[Tuple[float, float]] = ...) -> None: ... - -else: - def utime(path: AnyPath, times: Optional[Tuple[float, float]]) -> None: ... +def utime(path: AnyPath, times: Optional[Tuple[float, float]]) -> None: ... if sys.platform != "win32": # Unix only @@ -275,18 +259,9 @@ if sys.platform != "win32": def pathconf(path: AnyPath, name: Union[str, int]) -> int: ... def statvfs(path: AnyPath) -> _StatVFS: ... -if sys.version_info >= (3, 6): - def walk( - top: Union[AnyStr, PathLike[AnyStr]], - topdown: bool = ..., - onerror: Optional[Callable[[OSError], Any]] = ..., - followlinks: bool = ..., - ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... - -else: - def walk( - top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... - ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... +def walk( + top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... +) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... def abort() -> NoReturn: ... @@ -317,17 +292,10 @@ if sys.platform != "win32": def nice(increment: int) -> int: ... def plock(op: int) -> None: ... # ???op is int? -if sys.version_info >= (3, 0): - class popen(_TextIOWrapper): - # TODO 'b' modes or bytes command not accepted? - def __init__(self, command: str, mode: str = ..., bufsize: int = ...) -> None: ... - def close(self) -> Any: ... # may return int - -else: - 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 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: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, path: AnyPath, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig @@ -362,18 +330,9 @@ else: def getloadavg() -> Tuple[float, float, float]: ... def sysconf(name: Union[str, int]) -> int: ... -if sys.version_info >= (3, 0): - def sched_getaffinity(id: int) -> Set[int]: ... - -if sys.version_info >= (3, 3): - class waitresult: - si_pid: int - def waitid(idtype: int, id: int, options: int) -> waitresult: ... - -if sys.version_info < (3, 0): - def tmpfile() -> IO[Any]: ... - def tmpnam() -> str: ... - def tempnam(dir: str = ..., prefix: str = ...) -> str: ... +def tmpfile() -> IO[Any]: ... +def tmpnam() -> str: ... +def tempnam(dir: str = ..., prefix: str = ...) -> str: ... P_ALL: int WEXITED: int diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index 2750e9ea0f4b..dff9e3467a4e 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -17,11 +17,7 @@ def runeval(expression: str, globals: Optional[Dict[str, Any]] = ..., locals: Op def runctx(statement: str, globals: Dict[str, Any], locals: Mapping[str, Any]) -> None: ... def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... -if sys.version_info >= (3, 7): - def set_trace(*, header: Optional[str] = ...) -> None: ... - -else: - def set_trace() -> None: ... +def set_trace() -> None: ... def post_mortem(t: Optional[TracebackType] = ...) -> None: ... def pm() -> None: ... @@ -46,16 +42,6 @@ class Pdb(Bdb, Cmd): curframe: Optional[FrameType] curframe_locals: Mapping[str, Any] - if sys.version_info >= (3, 6): - def __init__( - self, - completekey: str = ..., - stdin: Optional[IO[str]] = ..., - stdout: Optional[IO[str]] = ..., - skip: Optional[Iterable[str]] = ..., - nosigint: bool = ..., - readrc: bool = ..., - ) -> None: ... elif sys.version_info >= (3, 2): def __init__( self, @@ -140,101 +126,54 @@ class Pdb(Bdb, Cmd): do_h = do_help def help_exec(self) -> None: ... def help_pdb(self) -> None: ... - if sys.version_info < (3, 2): - 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 - - if sys.version_info >= (3, 2): - def sigint_handler(self, signum: signal.Signals, frame: FrameType) -> None: ... - def message(self, msg: str) -> None: ... - def error(self, msg: str) -> None: ... - def _select_frame(self, number: int) -> None: ... - def _getval_except(self, arg: str, frame: Optional[FrameType] = ...) -> object: ... - def _print_lines( - self, lines: Sequence[str], start: int, breaks: Sequence[int] = ..., frame: Optional[FrameType] = ... - ) -> None: ... - def _cmdloop(self) -> None: ... - def do_display(self, arg: str) -> Optional[bool]: ... - def do_interact(self, arg: str) -> Optional[bool]: ... - def do_longlist(self, arg: str) -> Optional[bool]: ... - def do_source(self, arg: str) -> Optional[bool]: ... - def do_undisplay(self, arg: str) -> Optional[bool]: ... - do_ll = do_longlist - - if sys.version_info >= (3, 3): - def _complete_location(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def _complete_bpnumber(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def _complete_expression(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def complete_undisplay(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def complete_unalias(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - complete_commands = _complete_bpnumber - complete_break = _complete_location - complete_b = _complete_location - complete_tbreak = _complete_location - complete_enable = _complete_bpnumber - complete_disable = _complete_bpnumber - complete_condition = _complete_bpnumber - complete_ignore = _complete_bpnumber - complete_clear = _complete_location - complete_cl = _complete_location - complete_debug = _complete_expression - complete_print = _complete_expression - complete_p = _complete_expression - complete_pp = _complete_expression - complete_source = _complete_expression - complete_whatis = _complete_expression - complete_display = _complete_expression - - if sys.version_info >= (3, 7): - def _runmodule(self, module_name: str) -> None: ... - if sys.version_info >= (3,) and sys.version_info < (3, 4): - do_print = do_p + 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 @@ -242,9 +181,5 @@ def find_function(funcname: str, filename: str) -> Optional[Tuple[str, str, int] def main() -> None: ... def help() -> None: ... -if sys.version_info >= (3, 2): - def getsourcelines(obj: _SourceObjectType) -> Tuple[List[str], int]: ... - def lasti2lineno(code: CodeType, lasti: int) -> int: ... - class _rstr(str): def __repr__(self) -> _rstr: ... diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index ddf8a4401399..d68198889730 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -2,42 +2,8 @@ import sys from typing import IO, Any, Callable, Iterable, Iterator, Mapping, Optional, Tuple, Type, Union HIGHEST_PROTOCOL: int -if sys.version_info >= (3, 0): - DEFAULT_PROTOCOL: int - bytes_types: Tuple[Type[Any], ...] # undocumented -if sys.version_info >= (3, 8): - # TODO: holistic design for buffer interface (typing.Buffer?) - class PickleBuffer: - # buffer must be a buffer-providing object - def __init__(self, buffer: Any) -> None: ... - def raw(self) -> memoryview: ... - def release(self) -> None: ... - _BufferCallback = Optional[Callable[[PickleBuffer], Any]] - def dump( - obj: Any, - file: IO[bytes], - protocol: Optional[int] = ..., - *, - fix_imports: bool = ..., - buffer_callback: _BufferCallback = ..., - ) -> None: ... - def dumps( - obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... - ) -> bytes: ... - def load( - file: IO[bytes], - *, - fix_imports: bool = ..., - encoding: str = ..., - errors: str = ..., - buffers: Optional[Iterable[Any]] = ..., - ) -> Any: ... - def loads( - __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Optional[Iterable[Any]] = ... - ) -> Any: ... - elif sys.version_info >= (3, 0): def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... def dumps(obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> bytes: ... @@ -64,19 +30,6 @@ _reducedtype = Union[ class Pickler: fast: bool - if sys.version_info >= (3, 3): - dispatch_table: Mapping[type, Callable[[Any], _reducedtype]] - - if sys.version_info >= (3, 8): - def __init__( - self, - file: IO[bytes], - protocol: Optional[int] = ..., - *, - fix_imports: bool = ..., - buffer_callback: _BufferCallback = ..., - ) -> None: ... - def reducer_override(self, obj: Any) -> Any: ... elif sys.version_info >= (3, 0): def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... else: @@ -86,25 +39,12 @@ class Pickler: def persistent_id(self, obj: Any) -> Any: ... class Unpickler: - if sys.version_info >= (3, 8): - def __init__( - self, - file: IO[bytes], - *, - fix_imports: bool = ..., - encoding: str = ..., - errors: str = ..., - buffers: Optional[Iterable[Any]] = ..., - ) -> None: ... elif sys.version_info >= (3, 0): def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> None: ... else: def __init__(self, file: IO[bytes]) -> None: ... def load(self) -> Any: ... def find_class(self, __module_name: str, __global_name: str) -> Any: ... - if sys.version_info >= (3, 0): - def persistent_load(self, pid: Any) -> Any: ... - MARK: bytes STOP: bytes POP: bytes @@ -164,23 +104,5 @@ NEWFALSE: bytes LONG1: bytes LONG4: bytes -if sys.version_info >= (3, 0): - # protocol 3 - BINBYTES: bytes - SHORT_BINBYTES: bytes - -if sys.version_info >= (3, 4): - # protocol 4 - SHORT_BINUNICODE: bytes - BINUNICODE8: bytes - BINBYTES8: bytes - EMPTY_SET: bytes - ADDITEMS: bytes - FROZENSET: bytes - NEWOBJ_EX: bytes - STACK_GLOBAL: bytes - MEMOIZE: bytes - FRAME: bytes - def encode_long(x: int) -> bytes: ... # undocumented def decode_long(data: bytes) -> int: ... # undocumented diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index ec279524bc50..4ad75fb8bbbf 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -3,17 +3,9 @@ from typing import IO, Any, Callable, Iterator, List, MutableMapping, Optional, _Reader = Callable[[IO[bytes]], Any] -if sys.version_info >= (3, 0): - bytes_types: Tuple[Type[Any], ...] - UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int TAKEN_FROM_ARGUMENT4: int -if sys.version_info >= (3, 3): - TAKEN_FROM_ARGUMENT4U: int -if sys.version_info >= (3, 4): - TAKEN_FROM_ARGUMENT8U: int - class ArgumentDescriptor(object): name: str n: int @@ -33,14 +25,6 @@ def read_int4(f: IO[bytes]) -> int: ... int4: ArgumentDescriptor -if sys.version_info >= (3, 3): - def read_uint4(f: IO[bytes]) -> int: ... - uint4: ArgumentDescriptor - -if sys.version_info >= (3, 5): - def read_uint8(f: IO[bytes]) -> int: ... - uint8: ArgumentDescriptor - def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, Text]: ... stringnl: ArgumentDescriptor @@ -61,32 +45,14 @@ def read_string4(f: IO[bytes]) -> str: ... string4: ArgumentDescriptor -if sys.version_info >= (3, 3): - def read_bytes1(f: IO[bytes]) -> bytes: ... - bytes1: ArgumentDescriptor - def read_bytes4(f: IO[bytes]) -> bytes: ... - bytes4: ArgumentDescriptor - -if sys.version_info >= (3, 4): - def read_bytes8(f: IO[bytes]) -> bytes: ... - bytes8: ArgumentDescriptor - def read_unicodestringnl(f: IO[bytes]) -> Text: ... unicodestringnl: ArgumentDescriptor -if sys.version_info >= (3, 4): - def read_unicodestring1(f: IO[bytes]) -> Text: ... - unicodestring1: ArgumentDescriptor - def read_unicodestring4(f: IO[bytes]) -> Text: ... unicodestring4: ArgumentDescriptor -if sys.version_info >= (3, 4): - def read_unicodestring8(f: IO[bytes]) -> Text: ... - unicodestring8: ArgumentDescriptor - def read_decimalnl_short(f: IO[bytes]) -> int: ... def read_decimalnl_long(f: IO[bytes]) -> int: ... @@ -120,19 +86,12 @@ pylong: StackObject pyinteger_or_bool: StackObject pybool: StackObject pyfloat: StackObject -if sys.version_info >= (3, 4): - pybytes_or_str: StackObject pystring: StackObject -if sys.version_info >= (3, 0): - pybytes: StackObject pyunicode: StackObject pynone: StackObject pytuple: StackObject pylist: StackObject pydict: StackObject -if sys.version_info >= (3, 4): - pyset: StackObject - pyfrozenset: StackObject anyobject: StackObject markobject: StackObject stackslice: StackObject @@ -161,19 +120,9 @@ opcodes: List[OpcodeInfo] def genops(pickle: Union[bytes, IO[bytes]]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... def optimize(p: Union[bytes, IO[bytes]]) -> bytes: ... -if sys.version_info >= (3, 2): - def dis( - pickle: Union[bytes, IO[bytes]], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., - indentlevel: int = ..., - annotate: int = ..., - ) -> None: ... - -else: - def dis( - pickle: Union[bytes, IO[bytes]], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., - indentlevel: int = ..., - ) -> None: ... +def dis( + pickle: Union[bytes, IO[bytes]], + out: Optional[IO[str]] = ..., + memo: Optional[MutableMapping[int, Any]] = ..., + indentlevel: int = ..., +) -> None: ... diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 0935e922562e..a068d421f5f5 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -2,21 +2,11 @@ import sys from _typeshed import SupportsRead from typing import IO, Any, Callable, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3,): - from importlib.abc import Loader, MetaPathFinder, PathEntryFinder -else: - Loader = Any - MetaPathFinder = Any - PathEntryFinder = Any +Loader = Any +MetaPathFinder = Any +PathEntryFinder = Any -if sys.version_info >= (3, 6): - class ModuleInfo(NamedTuple): - module_finder: Union[MetaPathFinder, PathEntryFinder] - name: str - ispkg: bool - _ModuleInfoLike = ModuleInfo -else: - _ModuleInfoLike = Tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] +_ModuleInfoLike = Tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] def extend_path(path: List[str], name: str) -> List[str]: ... @@ -37,5 +27,3 @@ def walk_packages( ) -> Iterator[_ModuleInfoLike]: ... def get_data(package: str, resource: str) -> Optional[bytes]: ... -if sys.version_info >= (3, 9): - def resolve_name(name: str) -> Any: ... diff --git a/stdlib/@python2/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 5aadae9fc97b..9c4a1ff89ddd 100644 --- a/stdlib/@python2/plistlib.pyi +++ b/stdlib/@python2/plistlib.pyi @@ -1,20 +1,8 @@ import sys from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Optional, Text, Type, Union -if sys.version_info >= (3,): - from enum import Enum - class PlistFormat(Enum): - FMT_XML: int - FMT_BINARY: int - FMT_XML = PlistFormat.FMT_XML - FMT_BINARY = PlistFormat.FMT_BINARY - _Path = Union[str, Text] -if sys.version_info >= (3, 9): - def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... - def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... - elif sys.version_info >= (3, 4): def load( fp: IO[bytes], @@ -31,42 +19,24 @@ elif sys.version_info >= (3, 4): dict_type: Type[MutableMapping[str, Any]] = ..., ) -> Any: ... -if sys.version_info >= (3, 4): - def dump( - value: Mapping[str, Any], fp: IO[bytes], *, fmt: PlistFormat = ..., sort_keys: bool = ..., skipkeys: bool = ... - ) -> None: ... - def dumps(value: Mapping[str, Any], *, fmt: PlistFormat = ..., skipkeys: bool = ..., sort_keys: bool = ...) -> bytes: ... - -if sys.version_info < (3, 9): - def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... - def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... - def readPlistFromBytes(data: bytes) -> Any: ... - def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... - -if sys.version_info < (3,): - 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: ... +def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... +def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... +def readPlistFromBytes(data: bytes) -> Any: ... +def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... -if sys.version_info < (3, 7): - class Dict(DictT[str, Any]): - def __getattr__(self, attr: str) -> Any: ... - def __setattr__(self, attr: str, value: Any) -> None: ... - def __delattr__(self, attr: str) -> None: ... +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: ... -if sys.version_info < (3, 9): - class Data: - data: bytes - def __init__(self, data: bytes) -> None: ... +class Dict(DictT[str, Any]): + def __getattr__(self, attr: str) -> Any: ... + def __setattr__(self, attr: str, value: Any) -> None: ... + def __delattr__(self, attr: str) -> None: ... -if sys.version_info >= (3, 8): - class UID: - data: int - def __init__(self, data: int) -> None: ... - def __index__(self) -> int: ... - def __reduce__(self) -> Any: ... - def __hash__(self) -> int: ... +class Data: + data: bytes + def __init__(self, data: bytes) -> None: ... class InvalidFileException(ValueError): def __init__(self, message: str = ...) -> None: ... diff --git a/stdlib/@python2/poplib.pyi b/stdlib/@python2/poplib.pyi index 2c08f3586c0f..0e400db66bc2 100644 --- a/stdlib/@python2/poplib.pyi +++ b/stdlib/@python2/poplib.pyi @@ -14,9 +14,6 @@ LF: bytes CRLF: bytes class POP3: - if sys.version_info >= (3, 0): - encoding: Text - host: Text port: int sock: socket.socket @@ -38,36 +35,13 @@ class POP3: def rpop(self, user: Text) -> bytes: ... timestamp: Pattern[Text] - if sys.version_info < (3, 0): - def apop(self, user: Text, secret: Text) -> bytes: ... - else: - def apop(self, user: Text, password: Text) -> bytes: ... + 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: ... - if sys.version_info >= (3, 5): - def utf8(self) -> bytes: ... - if sys.version_info >= (3, 4): - def capa(self) -> Dict[Text, List[Text]]: ... - def stls(self, context: Optional[ssl.SSLContext] = ...) -> bytes: ... - class POP3_SSL(POP3): - if sys.version_info >= (3, 0): - def __init__( - self, - host: Text, - port: int = ..., - keyfile: Optional[Text] = ..., - certfile: Optional[Text] = ..., - timeout: float = ..., - context: Optional[ssl.SSLContext] = ..., - ) -> None: ... - else: - def __init__( - self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... - ) -> None: ... - if sys.version_info >= (3, 4): - # "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored - def stls(self, context: Any = ..., keyfile: Any = ..., certfile: Any = ...) -> bytes: ... + def __init__( + self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... + ) -> None: ... diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index 9484f92eca46..96893ed84e0f 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -1,18 +1,6 @@ import sys from typing import IO, Any, Dict, Optional, Tuple -if sys.version_info >= (3, 10): - def pformat( - object: object, - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> str: ... - elif sys.version_info >= (3, 8): def pformat( object: object, @@ -32,19 +20,6 @@ elif sys.version_info >= (3, 4): else: def pformat(object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ...) -> str: ... -if sys.version_info >= (3, 10): - def pp( - object: object, - stream: Optional[IO[str]] = ..., - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> None: ... - elif sys.version_info >= (3, 8): def pp( object: object, @@ -57,19 +32,6 @@ elif sys.version_info >= (3, 8): sort_dicts: bool = ..., ) -> None: ... -if sys.version_info >= (3, 10): - def pprint( - object: object, - stream: Optional[IO[str]] = ..., - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> None: ... - elif sys.version_info >= (3, 8): def pprint( object: object, @@ -103,18 +65,6 @@ def isrecursive(object: object) -> bool: ... def saferepr(object: object) -> str: ... class PrettyPrinter: - if sys.version_info >= (3, 10): - def __init__( - self, - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - stream: Optional[IO[str]] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> None: ... elif sys.version_info >= (3, 8): def __init__( self, diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index 9c74aeb9c3de..59eb08730680 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -7,19 +7,6 @@ from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) -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 Stats: sort_arg_dict_default: Dict[str, Tuple[Any, str]] def __init__( diff --git a/stdlib/@python2/pty.pyi b/stdlib/@python2/pty.pyi index f31e2c61ca9b..81012ac4dce7 100644 --- a/stdlib/@python2/pty.pyi +++ b/stdlib/@python2/pty.pyi @@ -14,8 +14,4 @@ def master_open() -> Tuple[int, str]: ... def slave_open(tty_name: str) -> int: ... def fork() -> Tuple[int, int]: ... -if sys.version_info >= (3, 4): - def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... - -else: - def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... +def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index 49473b17708e..111e78f4a429 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -10,25 +10,6 @@ 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 = ... - def _get_default_invalidation_mode() -> PycInvalidationMode: ... - -if sys.version_info >= (3, 8): - def compile( - file: AnyStr, - cfile: Optional[AnyStr] = ..., - dfile: Optional[AnyStr] = ..., - doraise: bool = ..., - optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., - quiet: int = ..., - ) -> Optional[AnyStr]: ... - elif sys.version_info >= (3, 7): def compile( file: AnyStr, diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 665ea43c0d4a..8dd739ef0ce6 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -9,18 +9,7 @@ class Class: file: int lineno: int - if sys.version_info >= (3, 7): - def __init__( - self, - module: str, - name: str, - super: Optional[List[Union[Class, str]]], - file: str, - lineno: int, - parent: Optional[Class] = ..., - ) -> None: ... - else: - def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... + def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... class Function: module: str @@ -28,10 +17,7 @@ class Function: file: int lineno: int - if sys.version_info >= (3, 7): - def __init__(self, module: str, name: str, file: str, lineno: int, parent: Optional[Function] = ...) -> 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) -> None: ... def readmodule(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Class]: ... def readmodule_ex(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Union[Class, Function, List[str]]]: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 39252dd9f725..52f8c92cc517 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -19,10 +19,7 @@ from typing import ( Union, ) -if sys.version_info >= (3,): - from reprlib import Repr -else: - from repr import Repr +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]] @@ -266,8 +263,7 @@ def apropos(key: str) -> None: ... def ispath(x: Any) -> bool: ... def cli() -> None: ... -if sys.version_info < (3,): - def serve( - port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ... - ) -> None: ... - def gui() -> None: ... +def serve( + port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ... +) -> None: ... +def gui() -> None: ... diff --git a/stdlib/@python2/pyexpat/errors.pyi b/stdlib/@python2/pyexpat/errors.pyi index 6cde43e3b61f..61420a6caa51 100644 --- a/stdlib/@python2/pyexpat/errors.pyi +++ b/stdlib/@python2/pyexpat/errors.pyi @@ -1,10 +1,6 @@ import sys from typing import Dict -if sys.version_info >= (3, 2): - codes: Dict[str, int] - messages: Dict[int, str] - XML_ERROR_ABORTED: str XML_ERROR_ASYNC_ENTITY: str XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: str diff --git a/stdlib/@python2/queue.pyi b/stdlib/@python2/queue.pyi index 82fde5989d34..f3d215676758 100644 --- a/stdlib/@python2/queue.pyi +++ b/stdlib/@python2/queue.pyi @@ -2,9 +2,6 @@ import sys from threading import Condition, Lock from typing import Any, Generic, Optional, TypeVar -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") class Empty(Exception): ... @@ -33,20 +30,6 @@ class Queue(Generic[_T]): def qsize(self) -> int: ... def _qsize(self) -> int: ... def task_done(self) -> None: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - class PriorityQueue(Queue[_T]): ... class LifoQueue(Queue[_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: Optional[float] = ...) -> _T: ... - def get_nowait(self) -> _T: ... - def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> 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/stdlib/@python2/readline.pyi b/stdlib/@python2/readline.pyi index 8f28a2b2b760..18bc6ff4418d 100644 --- a/stdlib/@python2/readline.pyi +++ b/stdlib/@python2/readline.pyi @@ -13,9 +13,6 @@ def redisplay() -> None: ... def read_history_file(__filename: Optional[AnyPath] = ...) -> None: ... def write_history_file(__filename: Optional[AnyPath] = ...) -> None: ... -if sys.version_info >= (3, 5): - def append_history_file(__nelements: int, __filename: Optional[AnyPath] = ...) -> None: ... - def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... @@ -25,9 +22,6 @@ def remove_history_item(__pos: int) -> None: ... def replace_history_item(__pos: int, __line: str) -> None: ... def add_history(__string: str) -> None: ... -if sys.version_info >= (3, 6): - def set_auto_history(__enabled: bool) -> None: ... - def set_startup_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... def set_pre_input_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... def set_completer(__function: _CompleterT = ...) -> None: ... diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index 3733cc13110c..12b4b4966f9e 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -1,10 +1,7 @@ import sys from typing import Any, Dict, Optional, Union -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] class Completer: def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... diff --git a/stdlib/@python2/sched.pyi b/stdlib/@python2/sched.pyi index 21d81e16ec60..7775c050776c 100644 --- a/stdlib/@python2/sched.pyi +++ b/stdlib/@python2/sched.pyi @@ -9,30 +9,10 @@ class Event(NamedTuple): kwargs: Dict[Text, Any] class scheduler: - if sys.version_info >= (3, 3): - def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], None] = ...) -> None: ... - def enterabs( - self, - time: float, - priority: Any, - action: Callable[..., Any], - 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] = ..., - ) -> Event: ... - def run(self, blocking: bool = ...) -> Optional[float]: ... - else: - 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 __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 diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index e0cf3bdd4d75..5c88d27bf66a 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -28,10 +28,7 @@ def select( __rlist: Iterable[Any], __wlist: Iterable[Any], __xlist: Iterable[Any], __timeout: Optional[float] = ... ) -> Tuple[List[Any], List[Any], List[Any]]: ... -if sys.version_info >= (3, 3): - error = OSError -else: - class error(Exception): ... +class error(Exception): ... if sys.platform != "linux" and sys.platform != "win32": # BSD only @@ -103,18 +100,7 @@ if sys.platform != "linux" and sys.platform != "win32": if sys.platform == "linux": class epoll(object): - if sys.version_info >= (3, 3): - def __init__(self, sizehint: int = ..., flags: int = ...) -> None: ... - else: - def __init__(self, sizehint: int = ...) -> None: ... - if sys.version_info >= (3, 4): - def __enter__(self) -> epoll: ... - def __exit__( - self, - exc_type: Optional[Type[BaseException]] = ..., - exc_val: Optional[BaseException] = ..., - exc_tb: Optional[TracebackType] = ..., - ) -> None: ... + def __init__(self, sizehint: int = ...) -> None: ... def close(self) -> None: ... closed: bool def fileno(self) -> int: ... @@ -139,14 +125,3 @@ if sys.platform == "linux": EPOLL_RDHUP: int if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win32": - if sys.version_info >= (3, 3): - # Solaris only - class devpoll: - if sys.version_info >= (3, 4): - 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: Optional[float] = ...) -> List[Tuple[int, int]]: ... diff --git a/stdlib/@python2/shutil.pyi b/stdlib/@python2/shutil.pyi index c0779d871c14..1dc20224ca62 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -18,12 +18,6 @@ from typing import ( overload, ) -if sys.version_info >= (3, 6): - _AnyStr = str - _AnyPath = TypeVar("_AnyPath", str, os.PathLike[str]) - # Return value of some functions that may either return a path-like object that was passed in or - # a string - _PathReturn = Any elif sys.version_info >= (3,): _AnyStr = str _AnyPath = str @@ -33,48 +27,20 @@ else: _AnyPath = TypeVar("_AnyPath", str, unicode) _PathReturn = Type[None] -if sys.version_info >= (3,): - class Error(OSError): ... - class SameFileError(Error): ... - class SpecialFileError(OSError): ... - class ExecError(OSError): ... - class ReadError(OSError): ... - class RegistryError(Exception): ... - -else: - class Error(EnvironmentError): ... - class SpecialFileError(EnvironmentError): ... - class ExecError(EnvironmentError): ... +class Error(EnvironmentError): ... +class SpecialFileError(EnvironmentError): ... +class ExecError(EnvironmentError): ... def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ... -if sys.version_info >= (3,): - def copyfile(src: StrPath, dst: _AnyPath, *, follow_symlinks: bool = ...) -> _AnyPath: ... - def copymode(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ... - def copystat(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ... - def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ... - def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ... - -else: - def copyfile(src: StrPath, dst: StrPath) -> None: ... - def copymode(src: StrPath, dst: StrPath) -> None: ... - def copystat(src: StrPath, dst: StrPath) -> None: ... - def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... - def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... +def copyfile(src: StrPath, dst: StrPath) -> None: ... +def copymode(src: StrPath, dst: StrPath) -> None: ... +def copystat(src: StrPath, dst: StrPath) -> None: ... +def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... +def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... def ignore_patterns(*patterns: StrPath) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... -if sys.version_info >= (3, 8): - def copytree( - src: StrPath, - dst: StrPath, - symlinks: bool = ..., - ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ..., - copy_function: Callable[[str, str], None] = ..., - ignore_dangling_symlinks: bool = ..., - dirs_exist_ok: bool = ..., - ) -> _PathReturn: ... - elif sys.version_info >= (3,): def copytree( src: StrPath, @@ -93,21 +59,12 @@ else: ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ..., ) -> _PathReturn: ... -if sys.version_info >= (3,): - def rmtree( - path: Union[bytes, StrPath], ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ... - ) -> None: ... - -else: - def rmtree( - path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ... - ) -> None: ... +def rmtree( + path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ... +) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] -if sys.version_info >= (3, 9): - def move(src: StrPath, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ... - elif sys.version_info >= (3, 5): # See https://bugs.python.org/issue32689 def move(src: str, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ... @@ -115,20 +72,6 @@ elif sys.version_info >= (3, 5): else: def move(src: StrPath, dst: StrPath) -> _PathReturn: ... -if sys.version_info >= (3,): - class _ntuple_diskusage(NamedTuple): - total: int - used: int - free: int - def disk_usage(path: StrPath) -> _ntuple_diskusage: ... - def chown(path: StrPath, user: Optional[Union[str, int]] = ..., group: Optional[Union[str, int]] = ...) -> None: ... - -if sys.version_info >= (3, 8): - @overload - def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... - @overload - def which(cmd: bytes, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[bytes]: ... - elif sys.version_info >= (3,): def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... @@ -152,19 +95,3 @@ def register_archive_format( ) -> None: ... def unregister_archive_format(name: str) -> None: ... -if sys.version_info >= (3,): - if sys.version_info >= (3, 7): - def unpack_archive(filename: StrPath, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... - else: - # See http://bugs.python.org/issue30218 - def unpack_archive(filename: str, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... - def register_unpack_format( - name: str, - extensions: List[str], - function: Any, - extra_args: Optional[Sequence[Tuple[str, Any]]] = ..., - description: str = ..., - ) -> None: ... - def unregister_unpack_format(name: str) -> None: ... - def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ... - def get_terminal_size(fallback: Tuple[int, int] = ...) -> os.terminal_size: ... diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index 92f078a063f6..bd0093cb98bf 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -10,39 +10,7 @@ class SMTPChannel(asynchat.async_chat): COMMAND: int DATA: int - if sys.version_info >= (3,): - command_size_limits: DefaultDict[str, int] - smtp_server: SMTPServer - conn: socket.socket - addr: Any - received_lines: List[Text] - smtp_state: int - seen_greeting: str - mailfrom: str - rcpttos: List[str] - received_data: str - fqdn: str - peer: str - - command_size_limit: int - data_size_limit: int - - enable_SMTPUTF8: bool - @property - def max_command_size_limit(self) -> int: ... - if sys.version_info >= (3,): - def __init__( - self, - server: SMTPServer, - conn: socket.socket, - addr: Any, - data_size_limit: int = ..., - map: Optional[asyncore._maptype] = ..., - enable_SMTPUTF8: bool = ..., - decode_data: bool = ..., - ) -> None: ... - else: - def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... + def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... # base asynchat.async_chat.push() accepts bytes def push(self, msg: Text) -> None: ... # type: ignore def collect_incoming_data(self, data: bytes) -> None: ... @@ -54,30 +22,13 @@ class SMTPChannel(asynchat.async_chat): def smtp_RCPT(self, arg: str) -> None: ... def smtp_RSET(self, arg: str) -> None: ... def smtp_DATA(self, arg: str) -> None: ... - if sys.version_info >= (3, 3): - def smtp_EHLO(self, arg: str) -> None: ... - def smtp_HELP(self, arg: str) -> None: ... - def smtp_VRFY(self, arg: str) -> None: ... - def smtp_EXPN(self, arg: str) -> None: ... - class SMTPServer(asyncore.dispatcher): channel_class: Type[SMTPChannel] data_size_limit: int enable_SMTPUTF8: bool - if sys.version_info >= (3,): - def __init__( - self, - localaddr: _Address, - remoteaddr: _Address, - data_size_limit: int = ..., - map: Optional[asyncore._maptype] = ..., - enable_SMTPUTF8: bool = ..., - decode_data: bool = ..., - ) -> None: ... - else: - def __init__(self, localaddr: _Address, remoteaddr: _Address, data_size_limit: int = ...) -> None: ... + 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: Union[bytes, str], **kwargs: Any diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index ef025ac571a7..3345f5f011e2 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -2,16 +2,7 @@ import sys from _typeshed import AnyPath from typing import NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3, 5): - class SndHeaders(NamedTuple): - filetype: str - framerate: int - nchannels: int - nframes: int - sampwidth: Union[int, str] - _SndHeaders = SndHeaders -else: - _SndHeaders = Tuple[str, int, int, int, Union[int, str]] +_SndHeaders = Tuple[str, int, int, int, Union[int, str]] def what(filename: AnyPath) -> Optional[_SndHeaders]: ... def whathdr(filename: AnyPath) -> Optional[_SndHeaders]: ... diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index e3f5d9b35bef..8d2722bbb01d 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -13,9 +13,6 @@ from typing_extensions import Literal # Constants defined by Python (i.e. not OS constants re-exported from C) has_ipv6: bool SocketType: Any -if sys.version_info >= (3,): - SocketIO: Any - # Re-exported errno EAGAIN: int EBADF: int @@ -263,9 +260,6 @@ TCP_NODELAY: int TCP_QUICKACK: int TCP_SYNCNT: int TCP_WINDOW_CLAMP: int -if sys.version_info >= (3, 7): - TCP_NOTSENT_LOWAT: int - # Specifically-documented constants if sys.platform == "linux" and sys.version_info >= (3,): @@ -387,8 +381,6 @@ if sys.platform == "linux" and sys.version_info >= (3,): if sys.platform == "win32": SIO_RCVALL: int SIO_KEEPALIVE_VALS: int - if sys.version_info >= (3, 6): - SIO_LOOPBACK_FAST_PATH: int RCVALL_IPLEVEL: int RCVALL_MAX: int RCVALL_OFF: int @@ -451,14 +443,6 @@ AF_LINK: AddressFamily # Availability: BSD, macOS # BDADDR_* and HCI_* listed with other bluetooth constants below -if sys.version_info >= (3, 6): - SO_DOMAIN: int - SO_PASSSEC: int - SO_PEERSEC: int - SO_PROTOCOL: int - TCP_CONGESTION: int - TCP_USER_TIMEOUT: int - if sys.platform == "linux" and sys.version_info >= (3, 8): AF_QIPCRTR: AddressFamily @@ -506,90 +490,15 @@ if sys.platform == "darwin": SYSPROTO_CONTROL: int # enum versions of above flags -if sys.version_info >= (3, 4): - from enum import IntEnum - class AddressFamily(IntEnum): - AF_UNIX: int - AF_INET: int - AF_INET6: int - AF_AAL5: int - AF_ALG: int - AF_APPLETALK: int - AF_ASH: int - AF_ATMPVC: int - AF_ATMSVC: int - AF_AX25: int - AF_BLUETOOTH: int - AF_BRIDGE: int - AF_CAN: int - AF_DECnet: int - AF_ECONET: int - AF_IPX: int - AF_IRDA: int - AF_KEY: int - AF_LINK: int - AF_LLC: int - AF_NETBEUI: int - AF_NETLINK: int - AF_NETROM: int - AF_PACKET: int - AF_PPPOX: int - AF_QIPCRTR: int - AF_RDS: int - AF_ROSE: int - AF_ROUTE: int - AF_SECURITY: int - AF_SNA: int - AF_SYSTEM: int - AF_TIPC: int - AF_UNSPEC: int - AF_VSOCK: int - AF_WANPIPE: int - AF_X25: int - class SocketKind(IntEnum): - SOCK_STREAM: int - SOCK_DGRAM: int - SOCK_RAW: int - SOCK_RDM: int - SOCK_SEQPACKET: int - SOCK_CLOEXEC: int - SOCK_NONBLOCK: int - -else: - AddressFamily = int - SocketKind = int - -if sys.version_info >= (3, 6): - from enum import IntFlag - class AddressInfo(IntFlag): - AI_ADDRCONFIG: int - AI_ALL: int - AI_CANONNAME: int - AI_NUMERICHOST: int - AI_NUMERICSERV: int - AI_PASSIVE: int - AI_V4MAPPED: int - class MsgFlag(IntFlag): - MSG_CTRUNC: int - MSG_DONTROUTE: int - MSG_DONTWAIT: int - MSG_EOR: int - MSG_OOB: int - MSG_PEEK: int - MSG_TRUNC: int - MSG_WAITALL: int +AddressFamily = int +SocketKind = int -else: - AddressInfo = int - MsgFlag = int +AddressInfo = int +MsgFlag = int # ----- Exceptions ----- -if sys.version_info < (3,): - class error(IOError): ... - -else: - error = OSError +class error(IOError): ... class herror(error): def __init__(self, herror: int = ..., string: str = ...) -> None: ... @@ -618,12 +527,7 @@ class socket: type: int proto: int - if sys.version_info < (3,): - def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... - else: - def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: Optional[int] = ...) -> None: ... - def __enter__(self: _SelfT) -> _SelfT: ... - def __exit__(self, *args: Any) -> None: ... + def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... # --- methods --- def accept(self) -> Tuple[socket, _RetAddress]: ... def bind(self, address: Union[_Address, bytes]) -> None: ... @@ -633,57 +537,22 @@ class socket: def detach(self) -> int: ... def dup(self) -> socket: ... def fileno(self) -> int: ... - if sys.version_info >= (3, 4): - def get_inheritable(self) -> bool: ... 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: ... - if sys.version_info >= (3, 7): - def getblocking(self) -> bool: ... def gettimeout(self) -> Optional[float]: ... if sys.platform == "win32" and sys.version_info >= (3, 6): def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ... elif sys.platform == "win32": def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ... - if sys.version_info >= (3, 5): - def listen(self, __backlog: int = ...) -> None: ... - else: - def listen(self, __backlog: int) -> None: ... + def listen(self, __backlog: int) -> None: ... # Note that the makefile's documented windows-specific behavior is not represented - if sys.version_info >= (3,): - # mode strings with duplicates are intentionally excluded - @overload - def makefile( - self, - mode: Literal["r", "w", "rw", "wr", ""] = ..., - buffering: Optional[int] = ..., - *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> TextIO: ... - @overload - def makefile( - self, - mode: Literal["b", "rb", "br", "wb", "bw", "rwb", "rbw", "wrb", "wbr", "brw", "bwr"], - buffering: Optional[int] = ..., - *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> BinaryIO: ... - else: - def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... + 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]: ... - if sys.version_info >= (3, 3) and sys.platform != "win32": - def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ... - def recvmsg_into( - self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ..., __flags: int = ... - ) -> Tuple[int, List[_CMSG], int, Any]: ... 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: ... @@ -692,72 +561,39 @@ class socket: def sendto(self, data: bytes, address: _Address) -> int: ... @overload def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... - if sys.version_info >= (3, 3) and sys.platform != "win32": - def sendmsg( - self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., __flags: int = ..., __address: _Address = ... - ) -> int: ... if sys.platform == "linux" and sys.version_info >= (3, 6): def sendmsg_afalg( self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... - if sys.version_info >= (3,): - def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ... - def set_inheritable(self, inheritable: bool) -> None: ... def setblocking(self, flag: bool) -> None: ... def settimeout(self, value: Optional[float]) -> None: ... - if sys.version_info < (3, 6): - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... - else: - @overload - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... - @overload - def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ... + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... if sys.platform == "win32": def share(self, process_id: int) -> bytes: ... def shutdown(self, how: int) -> None: ... # ----- Functions ----- -if sys.version_info >= (3, 7): - def close(fd: int) -> None: ... - def create_connection( address: Tuple[Optional[str], int], timeout: Optional[float] = ..., source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ..., ) -> socket: ... -if sys.version_info >= (3, 8): - def create_server( - address: _Address, *, family: int = ..., backlog: Optional[int] = ..., reuse_port: bool = ..., dualstack_ipv6: bool = ... - ) -> socket: ... - def has_dualstack_ipv6() -> bool: ... - def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... if sys.platform == "win32" and sys.version_info >= (3, 3): def fromshare(info: bytes) -> socket: ... # the 5th tuple item is an address -if sys.version_info >= (3,): - def getaddrinfo( - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], - family: int = ..., - type: int = ..., - proto: int = ..., - flags: int = ..., - ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... - -else: - def getaddrinfo( - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], - family: int = ..., - socktype: int = ..., - proto: int = ..., - flags: int = ..., - ) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]: ... +def getaddrinfo( + host: Optional[Union[bytearray, bytes, Text]], + port: Union[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: ... @@ -784,26 +620,6 @@ 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: ... -if sys.version_info >= (3, 9): - if sys.platform != "win32": - # flags and address appear to be unused in send_fds and recv_fds - def send_fds( - sock: socket, buffers: Iterable[bytes], fds: Union[bytes, Iterable[int]], flags: int = ..., address: None = ... - ) -> int: ... - def recv_fds(sock: socket, bufsize: int, maxfds: int, flags: int = ...) -> Tuple[bytes, List[int], int, Any]: ... - -if sys.version_info >= (3, 3): - def CMSG_LEN(length: int) -> int: ... - def CMSG_SPACE(length: int) -> int: ... - def getdefaulttimeout() -> Optional[float]: ... def setdefaulttimeout(timeout: Optional[float]) -> None: ... -if sys.version_info >= (3, 3): - if sys.platform != "win32": - def sethostname(name: str) -> None: ... - # Windows added these in 3.8, but didn't have them before - if sys.platform != "win32" or sys.version_info >= (3, 8): - def if_nameindex() -> List[Tuple[int, str]]: ... - def if_nametoindex(name: str) -> int: ... - def if_indextoname(index: int) -> str: ... diff --git a/stdlib/@python2/socketserver.pyi b/stdlib/@python2/socketserver.pyi index f0617e393b7e..4580fff7fe26 100644 --- a/stdlib/@python2/socketserver.pyi +++ b/stdlib/@python2/socketserver.pyi @@ -71,8 +71,6 @@ if sys.platform != "win32": timeout: Optional[float] # undocumented active_children: Optional[List[int]] # undocumented max_children: int # undocumented - if sys.version_info >= (3, 7): - block_on_close: bool def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented def handle_timeout(self) -> None: ... # undocumented def service_actions(self) -> None: ... # undocumented @@ -81,8 +79,6 @@ if sys.platform != "win32": class ThreadingMixIn: daemon_threads: bool - if sys.version_info >= (3, 7): - block_on_close: 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: ... def server_close(self) -> None: ... diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 74caa0e64cf1..40bfb7cbb9d9 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -18,10 +18,7 @@ def TimestampFromTicks(ticks: float) -> Timestamp: ... version_info: Tuple[int, int, int] sqlite_version_info: Tuple[int, int, int] -if sys.version_info >= (3,): - Binary = memoryview -else: - Binary = buffer +Binary = buffer # The remaining definitions are imported from _sqlite3. @@ -67,18 +64,6 @@ version: str def adapt(obj, protocol, alternate): ... def complete_statement(sql: str) -> bool: ... -if sys.version_info >= (3, 7): - def connect( - database: Union[bytes, Text, os.PathLike[Text]], - timeout: float = ..., - detect_types: int = ..., - isolation_level: Optional[str] = ..., - check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., - cached_statements: int = ..., - uri: bool = ..., - ) -> Connection: ... - elif sys.version_info >= (3, 4): def connect( database: Union[bytes, Text], @@ -107,11 +92,10 @@ def enable_shared_cache(enable: int) -> None: ... def register_adapter(__type: Type[_T], __caster: Callable[[_T], Union[int, float, str, bytes]]) -> None: ... def register_converter(__name: str, __converter: Callable[[bytes], Any]) -> None: ... -if sys.version_info < (3, 8): - class Cache(object): - def __init__(self, *args, **kwargs) -> None: ... - def display(self, *args, **kwargs) -> None: ... - def get(self, *args, **kwargs) -> 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: ... @@ -138,10 +122,7 @@ class Connection(object): 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: ... - if sys.version_info >= (3, 8): - def create_function(self, name: str, narg: int, func: Any, *, deterministic: bool = ...) -> None: ... - else: - def create_function(self, name: str, num_params: int, func: Any) -> None: ... + def create_function(self, name: str, num_params: int, func: Any) -> None: ... def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ... def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this @@ -161,16 +142,6 @@ class Connection(object): # 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: ... - if sys.version_info >= (3, 7): - def backup( - self, - target: Connection, - *, - pages: int = ..., - progress: Optional[Callable[[int, int, int], object]] = ..., - name: str = ..., - sleep: float = ..., - ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __enter__(self) -> Connection: ... def __exit__(self, t: Optional[type], exc: Optional[BaseException], tb: Optional[Any]) -> None: ... @@ -196,10 +167,7 @@ class Cursor(Iterator[Any]): def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ... def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ... def __iter__(self) -> Cursor: ... - if sys.version_info >= (3, 0): - def __next__(self) -> Any: ... - else: - def next(self) -> Any: ... + def next(self) -> Any: ... class DataError(DatabaseError): ... class DatabaseError(Error): ... @@ -210,73 +178,70 @@ class InternalError(DatabaseError): ... class NotSupportedError(DatabaseError): ... class OperationalError(DatabaseError): ... -if sys.version_info >= (3,): - OptimizedUnicode = str -else: - 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 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: ... @@ -297,8 +262,7 @@ class Row(object): def __lt__(self, other): ... def __ne__(self, other): ... -if sys.version_info < (3, 8): - class Statement(object): - def __init__(self, *args, **kwargs): ... +class Statement(object): + def __init__(self, *args, **kwargs): ... class Warning(Exception): ... diff --git a/stdlib/@python2/sre_compile.pyi b/stdlib/@python2/sre_compile.pyi index 9b50b75d8c31..0c48b7c38e18 100644 --- a/stdlib/@python2/sre_compile.pyi +++ b/stdlib/@python2/sre_compile.pyi @@ -15,17 +15,8 @@ from sre_constants import ( from sre_parse import SubPattern from typing import Any, List, Pattern, Tuple, Type, Union -if sys.version_info >= (3,): - from sre_constants import SRE_FLAG_ASCII as SRE_FLAG_ASCII - MAXCODE: int -if sys.version_info < (3, 0): - STRING_TYPES: Tuple[Type[str], Type[unicode]] - _IsStringType = int -else: - from sre_constants import _NamedIntConstant - def dis(code: List[_NamedIntConstant]) -> None: ... - _IsStringType = bool - +STRING_TYPES: Tuple[Type[str], Type[unicode]] +_IsStringType = int def isstring(obj: Any) -> _IsStringType: ... def compile(p: Union[str, bytes, SubPattern], flags: int = ...) -> Pattern[Any]: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 838211d959e5..7d7e3aac9b9a 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -4,9 +4,6 @@ from _typeshed import StrPath from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Text, Tuple, Type, Union, overload from typing_extensions import Literal -if sys.version_info >= (3, 4): - import enum - _PCTRTT = Tuple[Tuple[str, str], ...] _PCTRTTT = Tuple[_PCTRTT, ...] _PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] @@ -14,10 +11,7 @@ _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] _EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] _PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] -if sys.version_info >= (3, 5): - _SC1ArgT = Union[SSLSocket, SSLObject] -else: - _SC1ArgT = SSLSocket +_SC1ArgT = SSLSocket _SrvnmeCbType = Callable[[_SC1ArgT, Optional[str], SSLSocket], Optional[int]] class SSLError(OSError): @@ -30,13 +24,7 @@ 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 CertificateError(ValueError): ... def wrap_socket( sock: socket.socket, @@ -54,40 +42,21 @@ def create_default_context( purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[Text, bytes, None] = ... ) -> SSLContext: ... -if sys.version_info >= (3, 7): - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: int = ..., - check_hostname: bool = ..., - purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., - ) -> SSLContext: ... - -else: - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: Optional[int] = ..., - check_hostname: bool = ..., - purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., - ) -> SSLContext: ... +def _create_unverified_context( + protocol: int = ..., + *, + cert_reqs: Optional[int] = ..., + check_hostname: bool = ..., + purpose: Any = ..., + certfile: Optional[str] = ..., + keyfile: Optional[str] = ..., + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[Text, bytes, None] = ..., +) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] -if sys.version_info >= (3, 3): - def RAND_bytes(__num: int) -> bytes: ... - def RAND_pseudo_bytes(__num: int) -> Tuple[bytes, bool]: ... - def RAND_status() -> bool: ... def RAND_egd(path: str) -> None: ... def RAND_add(__s: bytes, __entropy: float) -> None: ... @@ -128,64 +97,17 @@ PROTOCOL_TLSv1: int PROTOCOL_TLSv1_1: int PROTOCOL_TLSv1_2: int PROTOCOL_TLS: int -if sys.version_info >= (3, 6): - PROTOCOL_TLS_CLIENT: int - PROTOCOL_TLS_SERVER: int - -if sys.version_info >= (3, 6): - class Options(enum.IntFlag): - 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_NO_TLSv1_3: int - OP_CIPHER_SERVER_PREFERENCE: int - OP_SINGLE_DH_USE: int - OP_SINGLE_ECDH_USE: int - OP_NO_COMPRESSION: int - OP_NO_TICKET: int - if sys.version_info >= (3, 7): - OP_NO_RENEGOTIATION: int - if sys.version_info >= (3, 8): - OP_ENABLE_MIDDLEBOX_COMPAT: int - OP_ALL: Options - OP_NO_SSLv2: Options - OP_NO_SSLv3: Options - OP_NO_TLSv1: Options - OP_NO_TLSv1_1: Options - OP_NO_TLSv1_2: Options - OP_NO_TLSv1_3: Options - OP_CIPHER_SERVER_PREFERENCE: Options - 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 - if sys.version_info >= (3, 8): - OP_ENABLE_MIDDLEBOX_COMPAT: Options -else: - 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 +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 -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_TLSv1_3: bool HAS_ALPN: bool HAS_ECDH: bool HAS_SNI: bool @@ -230,47 +152,35 @@ class _ASN1Object(NamedTuple): longname: str oid: str -if sys.version_info >= (3, 4): - class Purpose(_ASN1Object, enum.Enum): - SERVER_AUTH: _ASN1Object - CLIENT_AUTH: _ASN1Object - -else: - class Purpose(_ASN1Object): - SERVER_AUTH: ClassVar[Purpose] - CLIENT_AUTH: ClassVar[Purpose] +class Purpose(_ASN1Object): + SERVER_AUTH: ClassVar[Purpose] + CLIENT_AUTH: ClassVar[Purpose] class SSLSocket(socket.socket): context: SSLContext server_side: bool server_hostname: Optional[str] - if sys.version_info >= (3, 6): - session: Optional[SSLSession] - session_reused: Optional[bool] - if sys.version_info < (3, 7): - def __init__( - self, - sock: Optional[socket.socket] = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - server_side: bool = ..., - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: Optional[str] = ..., - do_handshake_on_connect: bool = ..., - family: int = ..., - type: int = ..., - proto: int = ..., - fileno: Optional[int] = ..., - suppress_ragged_eofs: bool = ..., - npn_protocols: Optional[Iterable[str]] = ..., - ciphers: Optional[str] = ..., - server_hostname: Optional[str] = ..., - _context: Optional[SSLContext] = ..., - _session: Optional[Any] = ..., - ) -> None: ... - else: - def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def __init__( + self, + sock: Optional[socket.socket] = ..., + keyfile: Optional[str] = ..., + certfile: Optional[str] = ..., + server_side: bool = ..., + cert_reqs: int = ..., + ssl_version: int = ..., + ca_certs: Optional[str] = ..., + do_handshake_on_connect: bool = ..., + family: int = ..., + type: int = ..., + proto: int = ..., + fileno: Optional[int] = ..., + suppress_ragged_eofs: bool = ..., + npn_protocols: Optional[Iterable[str]] = ..., + ciphers: Optional[str] = ..., + server_hostname: Optional[str] = ..., + _context: Optional[SSLContext] = ..., + _session: Optional[Any] = ..., + ) -> None: ... def connect(self, addr: Union[socket._Address, bytes]) -> None: ... def connect_ex(self, addr: Union[socket._Address, bytes]) -> int: ... def recv(self, buflen: int = ..., flags: int = ...) -> bytes: ... @@ -293,8 +203,6 @@ class SSLSocket(socket.socket): @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def cipher(self) -> Optional[Tuple[str, str, int]]: ... - if sys.version_info >= (3, 5): - def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... def compression(self) -> Optional[str]: ... def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... def selected_alpn_protocol(self) -> Optional[str]: ... @@ -303,39 +211,15 @@ class SSLSocket(socket.socket): def unwrap(self) -> socket.socket: ... def version(self) -> Optional[str]: ... def pending(self) -> int: ... - 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 SSLContext: check_hostname: bool - if sys.version_info >= (3, 6): - options: Options - else: - options: int - if sys.version_info >= (3, 8): - post_handshake_auth: bool - if sys.version_info >= (3, 5): - def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> SSLContext: ... - else: - def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> SSLContext: ... + options: int + def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> SSLContext: ... @property def protocol(self) -> int: ... verify_flags: int verify_mode: int - if sys.version_info >= (3, 5): - def __init__(self, protocol: int = ...) -> None: ... - else: - def __init__(self, protocol: int) -> None: ... + def __init__(self, protocol: int) -> None: ... def cert_store_stats(self) -> Dict[str, int]: ... def load_cert_chain( self, certfile: StrPath, keyfile: Optional[StrPath] = ..., password: Optional[_PasswordType] = ... @@ -348,113 +232,23 @@ class SSLContext: def set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... - if sys.version_info >= (3, 7): - sni_callback: Optional[Callable[[SSLObject, str, SSLContext], Union[None, int]]] - sslobject_class: Type[SSLObject] def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - if sys.version_info >= (3, 7): - def set_servername_callback(self, server_name_callback: Optional[_SrvnmeCbType]) -> None: ... - else: - def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> None: ... + def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> None: ... def load_dh_params(self, __path: str) -> None: ... def set_ecdh_curve(self, __name: str) -> None: ... - if sys.version_info >= (3, 6): - def wrap_socket( - self, - sock: socket.socket, - server_side: bool = ..., - do_handshake_on_connect: bool = ..., - suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ..., - session: Optional[SSLSession] = ..., - ) -> SSLSocket: ... - else: - def wrap_socket( - self, - sock: socket.socket, - server_side: bool = ..., - do_handshake_on_connect: bool = ..., - suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ..., - ) -> SSLSocket: ... - if sys.version_info >= (3, 6): - def wrap_bio( - self, - incoming: MemoryBIO, - outgoing: MemoryBIO, - server_side: bool = ..., - server_hostname: Optional[str] = ..., - session: Optional[SSLSession] = ..., - ) -> SSLObject: ... + def wrap_socket( + self, + sock: socket.socket, + server_side: bool = ..., + do_handshake_on_connect: bool = ..., + suppress_ragged_eofs: bool = ..., + server_hostname: Optional[str] = ..., + ) -> SSLSocket: ... elif sys.version_info >= (3, 5): def wrap_bio( self, incoming: MemoryBIO, outgoing: MemoryBIO, server_side: bool = ..., server_hostname: Optional[str] = ... ) -> SSLObject: ... def session_stats(self) -> Dict[str, int]: ... - if sys.version_info >= (3, 7): - hostname_checks_common_name: bool - maximum_version: TLSVersion - minimum_version: TLSVersion - -if sys.version_info >= (3, 5): - class SSLObject: - context: SSLContext - server_side: bool - server_hostname: Optional[str] - if sys.version_info >= (3, 6): - session: Optional[SSLSession] - session_reused: bool - if sys.version_info >= (3, 7): - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - else: - def __init__( - self, sslobj: Any, owner: Optional[Union[SSLSocket, SSLObject]] = ..., session: Optional[Any] = ... - ) -> None: ... - def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... - def write(self, data: bytes) -> int: ... - @overload - def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ... - @overload - def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ... - @overload - def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... - def selected_alpn_protocol(self) -> Optional[str]: ... - def selected_npn_protocol(self) -> Optional[str]: ... - def cipher(self) -> Optional[Tuple[str, str, int]]: ... - def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... - def compression(self) -> Optional[str]: ... - def pending(self) -> int: ... - def do_handshake(self) -> None: ... - def unwrap(self) -> None: ... - def version(self) -> Optional[str]: ... - def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... - if sys.version_info >= (3, 8): - def verify_client_post_handshake(self) -> None: ... - class MemoryBIO: - pending: int - eof: bool - def read(self, __size: int = ...) -> bytes: ... - def write(self, __buf: bytes) -> int: ... - def write_eof(self) -> None: ... - -if sys.version_info >= (3, 6): - class SSLSession: - id: bytes - time: int - timeout: int - ticket_lifetime_hint: int - has_ticket: bool - class VerifyFlags(enum.IntFlag): - VERIFY_DEFAULT: int - VERIFY_CRL_CHECK_LEAF: int - VERIFY_CRL_CHECK_CHAIN: int - VERIFY_X509_STRICT: int - VERIFY_X509_TRUSTED_FIRST: int - class VerifyMode(enum.IntEnum): - CERT_NONE: int - CERT_OPTIONAL: int - CERT_REQUIRED: int - # TODO below documented in cpython but not in docs.python.org # taken from python 3.4 SSL_ERROR_EOF: int @@ -469,8 +263,7 @@ SSL_ERROR_ZERO_RETURN: int def get_protocol_name(protocol_code: int) -> str: ... -if sys.version_info < (3, 9): - AF_INET: int +AF_INET: int PEM_FOOTER: str PEM_HEADER: str SOCK_STREAM: int diff --git a/stdlib/@python2/struct.pyi b/stdlib/@python2/struct.pyi index 096f8b7b85ca..f100e6aa0c81 100644 --- a/stdlib/@python2/struct.pyi +++ b/stdlib/@python2/struct.pyi @@ -6,33 +6,21 @@ from typing import Any, Iterator, Text, Tuple, Union class error(Exception): ... _FmtType = Union[bytes, Text] -if sys.version_info >= (3,): - _BufferType = Union[array[int], bytes, bytearray, memoryview, mmap] - _WriteBufferType = Union[array[Any], bytearray, memoryview, mmap] -else: - _BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] - _WriteBufferType = Union[array[Any], bytearray, buffer, memoryview, mmap] +_BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] +_WriteBufferType = Union[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, ...]: ... -if sys.version_info >= (3, 4): - def iter_unpack(__format: _FmtType, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... - def calcsize(__format: _FmtType) -> int: ... class Struct: - if sys.version_info >= (3, 7): - format: str - else: - format: bytes + 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, ...]: ... - if sys.version_info >= (3, 4): - def iter_unpack(self, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index 175068861ee9..020fac474df0 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -20,23 +20,10 @@ AUDIO_FILE_ENCODING_ADPCM_G723_5: int AUDIO_FILE_ENCODING_ALAW_8: int AUDIO_UNKNOWN_SIZE: int -if sys.version_info >= (3, 0): - class _sunau_params(NamedTuple): - nchannels: int - sampwidth: int - framerate: int - nframes: int - comptype: str - compname: str - -else: - _sunau_params = Tuple[int, int, int, int, str, str] +_sunau_params = Tuple[int, int, int, int, str, str] class Au_read: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 3): - def __enter__(self) -> Au_read: ... - def __exit__(self, *args: Any) -> None: ... def getfp(self) -> Optional[IO[bytes]]: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -55,9 +42,6 @@ class Au_read: class Au_write: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 3): - def __enter__(self) -> Au_write: ... - def __exit__(self, *args: Any) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... @@ -80,5 +64,4 @@ class Au_write: # Returns a Au_read if mode is rb and Au_write if mode is wb def open(f: _File, mode: Optional[str] = ...) -> Any: ... -if sys.version_info < (3, 9): - openfp = open +openfp = open diff --git a/stdlib/@python2/symtable.pyi b/stdlib/@python2/symtable.pyi index b528481bf510..8417f5948660 100644 --- a/stdlib/@python2/symtable.pyi +++ b/stdlib/@python2/symtable.pyi @@ -13,8 +13,7 @@ class SymbolTable(object): def is_nested(self) -> bool: ... def has_children(self) -> bool: ... def has_exec(self) -> bool: ... - if sys.version_info < (3, 0): - def has_import_star(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]: ... @@ -30,20 +29,13 @@ class Class(SymbolTable): def get_methods(self) -> Tuple[str, ...]: ... class Symbol(object): - if sys.version_info >= (3, 8): - def __init__( - self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ..., *, module_scope: bool = ... - ) -> None: ... - else: - def __init__(self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ...) -> None: ... + def __init__(self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ...) -> 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: ... - if sys.version_info >= (3, 6): - def is_annotated(self) -> bool: ... def is_free(self) -> bool: ... def is_imported(self) -> bool: ... def is_assigned(self) -> bool: ... diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index afb88161d68b..f970412f2a4d 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -46,14 +46,10 @@ GNU_TYPES: Tuple[bytes, ...] PAX_FIELDS: Tuple[str, ...] PAX_NUMBER_FIELDS: Dict[str, type] -if sys.version_info >= (3,): - PAX_NAME_FIELDS: Set[str] - ENCODING: str -if sys.version_info < (3,): - TAR_PLAIN: int - TAR_GZIPPED: int +TAR_PLAIN: int +TAR_GZIPPED: int def open( name: Optional[AnyPath] = ..., @@ -92,8 +88,7 @@ class TarFile(Iterable[TarInfo]): debug: Optional[int] errorlevel: Optional[int] offset: int # undocumented - if sys.version_info < (3,): - posix: bool + posix: bool def __init__( self, name: Optional[AnyPath] = ..., @@ -204,23 +199,10 @@ class TarFile(Iterable[TarInfo]): def getmember(self, name: str) -> TarInfo: ... def getmembers(self) -> List[TarInfo]: ... def getnames(self) -> List[str]: ... - if sys.version_info >= (3, 5): - def list(self, verbose: bool = ..., *, members: Optional[List[TarInfo]] = ...) -> None: ... - else: - def list(self, verbose: bool = ...) -> None: ... + def list(self, verbose: bool = ...) -> None: ... def next(self) -> Optional[TarInfo]: ... - if sys.version_info >= (3, 5): - def extractall( - self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ... - ) -> None: ... - else: - def extractall(self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... - if sys.version_info >= (3, 5): - def extract( - self, member: Union[str, TarInfo], path: AnyPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... - ) -> None: ... - else: - def extract(self, member: Union[str, TarInfo], path: AnyPath = ...) -> None: ... + def extractall(self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... + def extract(self, member: Union[str, TarInfo], path: AnyPath = ...) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... def makedir(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makefile(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented @@ -228,21 +210,9 @@ class TarFile(Iterable[TarInfo]): def makefifo(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makedev(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makelink(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - if sys.version_info >= (3, 5): - def chown(self, tarinfo: TarInfo, targetpath: AnyPath, numeric_owner: bool) -> None: ... # undocumented - else: - def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented + def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def chmod(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def utime(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - if sys.version_info >= (3, 7): - def add( - self, - name: StrPath, - arcname: Optional[StrPath] = ..., - recursive: bool = ..., - *, - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., - ) -> None: ... elif sys.version_info >= (3,): def add( self, @@ -268,18 +238,12 @@ class TarFile(Iterable[TarInfo]): ) -> TarInfo: ... def close(self) -> None: ... -if sys.version_info >= (3, 9): - def is_tarfile(name: Union[AnyPath, IO[bytes]]) -> bool: ... - -else: - def is_tarfile(name: AnyPath) -> bool: ... +def is_tarfile(name: AnyPath) -> bool: ... -if sys.version_info < (3, 8): - def filemode(mode: int) -> str: ... # undocumented +def filemode(mode: int) -> str: ... # undocumented -if sys.version_info < (3,): - class TarFileCompat: - def __init__(self, filename: str, mode: str = ..., compression: int = ...) -> None: ... +class TarFileCompat: + def __init__(self, filename: str, mode: str = ..., compression: int = ...) -> None: ... class TarError(Exception): ... class ReadError(TarError): ... @@ -309,12 +273,8 @@ class TarInfo: gname: str pax_headers: Mapping[str, str] def __init__(self, name: str = ...) -> None: ... - if sys.version_info >= (3,): - @classmethod - def frombuf(cls, buf: bytes, encoding: str, errors: str) -> TarInfo: ... - else: - @classmethod - def frombuf(cls, buf: bytes) -> TarInfo: ... + @classmethod + def frombuf(cls, buf: bytes) -> TarInfo: ... @classmethod def fromtarfile(cls, tarfile: TarFile) -> TarInfo: ... @property diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index 31fd3eef81cd..d59efc994be8 100644 --- a/stdlib/@python2/telnetlib.pyi +++ b/stdlib/@python2/telnetlib.pyi @@ -110,6 +110,3 @@ class Telnet: def expect( self, list: Sequence[Union[Pattern[bytes], bytes]], timeout: Optional[float] = ... ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... - if sys.version_info >= (3, 6): - def __enter__(self) -> Telnet: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index af0b0af89d9b..f8e1fc46b10a 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -12,30 +12,17 @@ __all__: List[str] def active_count() -> int: ... -if sys.version_info < (3,): - def activeCount() -> int: ... +def activeCount() -> int: ... def current_thread() -> Thread: ... def currentThread() -> Thread: ... -if sys.version_info >= (3,): - def get_ident() -> int: ... - def enumerate() -> List[Thread]: ... -if sys.version_info >= (3, 4): - def main_thread() -> Thread: ... - -if sys.version_info >= (3, 8): - from _thread import get_native_id as get_native_id - def settrace(func: _TF) -> None: ... def setprofile(func: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... -if sys.version_info >= (3,): - TIMEOUT_MAX: float - class ThreadError(Exception): ... class local(object): @@ -47,37 +34,21 @@ class Thread: name: str ident: Optional[int] daemon: bool - if sys.version_info >= (3,): - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - *, - daemon: Optional[bool] = ..., - ) -> None: ... - else: - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[Text] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., - ) -> None: ... + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[Text] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[Text, Any]] = ..., + ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: Text) -> None: ... - if sys.version_info >= (3, 8): - @property - def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - if sys.version_info < (3, 9): - def isAlive(self) -> bool: ... + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -89,10 +60,7 @@ class Lock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -102,10 +70,7 @@ class _RLock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock @@ -116,14 +81,9 @@ class Condition: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... - if sys.version_info >= (3,): - def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -133,56 +93,23 @@ class Semaphore: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - if sys.version_info >= (3, 9): - def release(self, n: int = ...) -> None: ... - else: - def release(self) -> 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: ... - if sys.version_info < (3,): - def isSet(self) -> bool: ... + def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... -if sys.version_info >= (3, 8): - from _thread import _excepthook, _ExceptHookArgs - - excepthook = _excepthook - ExceptHookArgs = _ExceptHookArgs - class Timer(Thread): - if sys.version_info >= (3,): - def __init__( - self, - interval: float, - function: Callable[..., Any], - args: Optional[Iterable[Any]] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - ) -> None: ... - else: - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... + def __init__( + self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... + ) -> None: ... def cancel(self) -> None: ... -if sys.version_info >= (3,): - class Barrier: - parties: int - n_waiting: int - broken: bool - def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> int: ... - def reset(self) -> None: ... - def abort(self) -> None: ... - class BrokenBarrierError(RuntimeError): ... diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index 6e926c68dc39..37a088682537 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -1,40 +1,14 @@ import sys from typing import Any, NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3, 3): - from types import SimpleNamespace - _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] -if sys.version_info < (3, 3): - accept2dyear: bool +accept2dyear: bool altzone: int 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.version_info >= (3, 3) and sys.platform != "win32": - CLOCK_MONOTONIC: int - CLOCK_MONOTONIC_RAW: int - CLOCK_PROCESS_CPUTIME_ID: int - CLOCK_REALTIME: int - CLOCK_THREAD_CPUTIME_ID: int - if sys.platform != "linux" and sys.platform != "darwin": - CLOCK_HIGHRES: int # Solaris only - -if sys.version_info >= (3, 8) and sys.platform == "darwin": - CLOCK_UPTIME_RAW: int - -if sys.version_info >= (3, 9) and sys.platform == "linux": - CLOCK_TAI: int - class _struct_time(NamedTuple): tm_year: int tm_mon: int @@ -52,41 +26,13 @@ class _struct_time(NamedTuple): @property def n_unnamed_fields(self) -> int: ... -if sys.version_info >= (3, 3): - class struct_time(_struct_time): - def __init__( - self, - o: Union[ - Tuple[int, int, int, int, int, int, int, int, int], - Tuple[int, int, int, int, int, int, int, int, int, str], - Tuple[int, int, int, int, int, int, int, int, int, str, int], - ], - _arg: Any = ..., - ) -> None: ... - def __new__( - cls, - o: Union[ - Tuple[int, int, int, int, int, int, int, int, int], - Tuple[int, int, int, int, int, int, int, int, int, str], - Tuple[int, int, int, int, int, int, int, int, int, str, int], - ], - _arg: Any = ..., - ) -> struct_time: ... - if sys.version_info >= (3, 6) or sys.platform != "win32": - @property - def tm_zone(self) -> str: ... - @property - def tm_gmtoff(self) -> int: ... - -else: - class struct_time(_struct_time): - def __init__(self, o: _TimeTuple, _arg: Any = ...) -> None: ... - def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ... +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: Union[_TimeTuple, struct_time] = ...) -> str: ... -if sys.version_info < (3, 8): - def clock() -> float: ... +def clock() -> float: ... def ctime(secs: Optional[float] = ...) -> str: ... def gmtime(secs: Optional[float] = ...) -> struct_time: ... @@ -100,23 +46,3 @@ def time() -> float: ... if sys.platform != "win32": def tzset() -> None: ... # Unix only -if sys.version_info >= (3, 3): - def get_clock_info(name: str) -> SimpleNamespace: ... - def monotonic() -> float: ... - def perf_counter() -> float: ... - def process_time() -> float: ... - if sys.platform != "win32": - def clock_getres(clk_id: int) -> float: ... # Unix only - 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: ... - 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/stdlib/@python2/timeit.pyi b/stdlib/@python2/timeit.pyi index 8de9af28d7ad..89ba33e31ae1 100644 --- a/stdlib/@python2/timeit.pyi +++ b/stdlib/@python2/timeit.pyi @@ -8,36 +8,14 @@ _stmt = Union[_str, Callable[[], Any]] default_timer: _Timer class Timer: - if sys.version_info >= (3, 5): - def __init__( - self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., globals: Optional[Dict[str, Any]] = ... - ) -> None: ... - else: - def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> None: ... + def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> None: ... def print_exc(self, file: Optional[IO[str]] = ...) -> None: ... def timeit(self, number: int = ...) -> float: ... def repeat(self, repeat: int = ..., number: int = ...) -> List[float]: ... - if sys.version_info >= (3, 6): - def autorange(self, callback: Optional[Callable[[int, float], Any]] = ...) -> Tuple[int, float]: ... - -if sys.version_info >= (3, 5): - def timeit( - stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., number: int = ..., globals: Optional[Dict[str, Any]] = ... - ) -> float: ... - def repeat( - stmt: _stmt = ..., - setup: _stmt = ..., - timer: _Timer = ..., - repeat: int = ..., - number: int = ..., - globals: Optional[Dict[str, Any]] = ..., - ) -> List[float]: ... - -else: - 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]: ... +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] diff --git a/stdlib/@python2/token.pyi b/stdlib/@python2/token.pyi index a806a466b8ea..8a469a87c639 100644 --- a/stdlib/@python2/token.pyi +++ b/stdlib/@python2/token.pyi @@ -26,8 +26,7 @@ GREATER: int EQUAL: int DOT: int PERCENT: int -if sys.version_info < (3,): - BACKQUOTE: int +BACKQUOTE: int LBRACE: int RBRACE: int EQEQUAL: int @@ -53,33 +52,11 @@ DOUBLESTAREQUAL: int DOUBLESLASH: int DOUBLESLASHEQUAL: int AT: int -if sys.version_info >= (3,): - RARROW: int - ELLIPSIS: int -if sys.version_info >= (3, 5): - ATEQUAL: int - if sys.version_info < (3, 7): - # These were removed in Python 3.7 but added back in Python 3.8 - AWAIT: int - ASYNC: int -if sys.version_info >= (3, 8): - AWAIT: int - ASYNC: int OP: int 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 -if sys.version_info >= (3, 8): - TYPE_COMMENT: int - TYPE_IGNORE: int - COLONEQUAL: int - EXACT_TOKEN_TYPES: Dict[str, int] - def ISTERMINAL(x: int) -> bool: ... def ISNONTERMINAL(x: int) -> bool: ... def ISEOF(x: int) -> bool: ... diff --git a/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 3c24ee21bee4..2f31d86cca9f 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -7,16 +7,6 @@ _PT = Tuple[str, int, str, Optional[str]] def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -if sys.version_info >= (3, 10): - def print_exception( - __exc: Optional[Type[BaseException]], - value: Optional[BaseException] = ..., - tb: Optional[TracebackType] = ..., - limit: Optional[int] = ..., - file: Optional[IO[str]] = ..., - chain: bool = ..., - ) -> None: ... - elif sys.version_info >= (3,): def print_exception( etype: Optional[Type[BaseException]], @@ -36,42 +26,16 @@ else: file: Optional[IO[str]] = ..., ) -> None: ... -if sys.version_info >= (3,): - def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... - def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... - -else: - def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... - def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... def print_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -if sys.version_info >= (3, 5): - def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> StackSummary: ... - def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> StackSummary: ... - def format_list(extracted_list: List[FrameSummary]) -> List[str]: ... - # undocumented - def print_list(extracted_list: List[FrameSummary], file: Optional[SupportsWrite[str]] = ...) -> None: ... +def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... +def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... +def format_list(extracted_list: List[_PT]) -> List[str]: ... -else: - def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... - def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... - def format_list(extracted_list: List[_PT]) -> List[str]: ... - -if sys.version_info >= (3, 10): - def format_exception_only(__exc: Optional[Type[BaseException]], value: Optional[BaseException] = ...) -> List[str]: ... - -else: - def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... - -if sys.version_info >= (3, 10): - def format_exception( - __exc: Optional[Type[BaseException]], - value: Optional[BaseException] = ..., - tb: Optional[TracebackType] = ..., - limit: Optional[int] = ..., - chain: bool = ..., - ) -> List[str]: ... +def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... elif sys.version_info >= (3,): def format_exception( @@ -90,108 +54,10 @@ else: limit: Optional[int] = ..., ) -> List[str]: ... -if sys.version_info >= (3,): - def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... - -else: - def format_exc(limit: Optional[int] = ...) -> str: ... +def format_exc(limit: Optional[int] = ...) -> str: ... def format_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ... def format_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[str]: ... -if sys.version_info >= (3, 4): - def clear_frames(tb: TracebackType) -> None: ... - -if sys.version_info >= (3, 5): - def walk_stack(f: Optional[FrameType]) -> Iterator[Tuple[FrameType, int]]: ... - def walk_tb(tb: Optional[TracebackType]) -> Iterator[Tuple[FrameType, int]]: ... - -if sys.version_info < (3,): - def tb_lineno(tb: TracebackType) -> int: ... +def tb_lineno(tb: TracebackType) -> int: ... -if sys.version_info >= (3, 5): - class TracebackException: - __cause__: TracebackException - __context__: TracebackException - __suppress_context__: bool - stack: StackSummary - exc_type: Type[BaseException] - filename: str - lineno: int - text: str - offset: int - msg: str - if sys.version_info >= (3, 10): - def __init__( - self, - exc_type: Type[BaseException], - exc_value: BaseException, - exc_traceback: TracebackType, - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - compact: bool = ..., - _seen: Optional[Set[int]] = ..., - ) -> None: ... - @classmethod - def from_exception( - cls, - exc: BaseException, - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - compact: bool = ..., - ) -> TracebackException: ... - else: - def __init__( - self, - exc_type: Type[BaseException], - exc_value: BaseException, - exc_traceback: TracebackType, - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - _seen: Optional[Set[int]] = ..., - ) -> None: ... - @classmethod - def from_exception( - cls, exc: BaseException, *, limit: Optional[int] = ..., lookup_lines: bool = ..., capture_locals: bool = ... - ) -> TracebackException: ... - def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ... - def format_exception_only(self) -> Generator[str, None, None]: ... - class FrameSummary(Iterable[Any]): - filename: str - lineno: int - name: str - line: str - locals: Optional[Dict[str, str]] - def __init__( - self, - filename: str, - lineno: int, - name: str, - *, - lookup_line: bool = ..., - locals: Optional[Mapping[str, str]] = ..., - line: Optional[str] = ..., - ) -> None: ... - # TODO: more precise typing for __getitem__ and __iter__, - # for a namedtuple-like view on (filename, lineno, name, str). - def __getitem__(self, i: int) -> Any: ... - def __iter__(self) -> Iterator[Any]: ... - class StackSummary(List[FrameSummary]): - @classmethod - def extract( - cls, - frame_gen: Generator[Tuple[FrameType, int], None, None], - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - ) -> StackSummary: ... - @classmethod - def from_list(cls, a_list: List[_PT]) -> StackSummary: ... - def format(self) -> List[str]: ... diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index a44b25926968..d2fd7c0708d2 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -1,12 +1,9 @@ import sys from typing import Any, Callable, Dict, List, Optional, Sequence, Text, Tuple, TypeVar, Union, overload -if sys.version_info >= (3,): - from tkinter import Canvas, PhotoImage -else: - # TODO: Replace these aliases once we have Python 2 stubs for the Tkinter module. - Canvas = Any - PhotoImage = Any +# 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 @@ -32,18 +29,6 @@ class TurtleScreenBase(object): xscale: float = ... yscale: float = ... def __init__(self, cv: Canvas) -> None: ... - if sys.version_info >= (3,): - def mainloop(self) -> None: ... - def textinput(self, title: str, prompt: str) -> Optional[str]: ... - def numinput( - self, - title: str, - prompt: str, - default: Optional[float] = ..., - minval: Optional[float] = ..., - maxval: Optional[float] = ..., - ) -> Optional[float]: ... - class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... @@ -102,10 +87,6 @@ class TurtleScreen(TurtleScreenBase): resetscreen = reset clearscreen = clear addshape = register_shape - if sys.version_info >= (3,): - def onkeypress(self, fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... - onkeyrelease = onkey - class TNavigator(object): START_ORIENTATION: Dict[str, Vec2D] = ... DEFAULT_MODE: str = ... @@ -239,19 +220,6 @@ class RawTurtle(TPen, TNavigator): def shapesize( self, stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ... ) -> None: ... - if sys.version_info >= (3,): - @overload - def shearfactor(self, shear: None = ...) -> float: ... - @overload - def shearfactor(self, shear: float) -> None: ... - # Unsafely overlaps when no arguments are provided - @overload - def shapetransform(self) -> Tuple[float, float, float, float]: ... # type: ignore - @overload - def shapetransform( - self, t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... - ) -> None: ... - def get_shapepoly(self) -> Optional[_PolygonCoords]: ... def settiltangle(self, angle: float) -> None: ... @overload def tiltangle(self, angle: None = ...) -> float: ... @@ -318,12 +286,6 @@ def write_docstringdict(filename: str = ...) -> None: ... # TurtleScreenBase in Python 3.0 def mainloop() -> None: ... -if sys.version_info >= (3,): - def textinput(title: str, prompt: str) -> Optional[str]: ... - def numinput( - title: str, prompt: str, default: Optional[float] = ..., minval: Optional[float] = ..., maxval: Optional[float] = ... - ) -> Optional[float]: ... - # Functions copied from TurtleScreen: def clear() -> None: ... @@ -375,10 +337,6 @@ onscreenclick = onclick resetscreen = reset clearscreen = clear addshape = register_shape -if sys.version_info >= (3,): - def onkeypress(fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... - onkeyrelease = onkey - # Functions copied from _Screen: def setup(width: float = ..., height: float = ..., startx: Optional[int] = ..., starty: Optional[int] = ...) -> None: ... @@ -509,20 +467,6 @@ def shapesize() -> Tuple[float, float, float]: ... # type: ignore @overload def shapesize(stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ...) -> None: ... -if sys.version_info >= (3,): - @overload - def shearfactor(shear: None = ...) -> float: ... - @overload - def shearfactor(shear: float) -> None: ... - # Unsafely overlaps when no arguments are provided - @overload - def shapetransform() -> Tuple[float, float, float, float]: ... # type: ignore - @overload - def shapetransform( - t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... - ) -> None: ... - def get_shapepoly() -> Optional[_PolygonCoords]: ... - def settiltangle(angle: float) -> None: ... @overload def tiltangle(angle: None = ...) -> float: ... diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index 0250866f3eb8..e38bcf372a9e 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -55,15 +55,10 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore def update(self: _T, __m: _T) -> None: ... - if sys.version_info >= (3, 0): - def items(self) -> ItemsView[str, object]: ... - def keys(self) -> KeysView[str]: ... - def values(self) -> ValuesView[object]: ... - else: - def has_key(self, k: str) -> bool: ... - def viewitems(self) -> ItemsView[str, object]: ... - def viewkeys(self) -> KeysView[str]: ... - def viewvalues(self) -> ValuesView[object]: ... + 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. @@ -71,21 +66,6 @@ TypedDict: object = ... OrderedDict = _Alias() -if sys.version_info >= (3, 3): - from typing import ChainMap as ChainMap - -if sys.version_info >= (3, 5): - from typing import ( - AsyncContextManager as AsyncContextManager, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - Coroutine as Coroutine, - ) - -if sys.version_info >= (3, 6): - from typing import AsyncGenerator as AsyncGenerator - def get_type_hints( obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., @@ -93,10 +73,6 @@ def get_type_hints( include_extras: bool = ..., ) -> Dict[str, Any]: ... -if sys.version_info >= (3, 7): - def get_args(tp: Any) -> Tuple[Any, ...]: ... - def get_origin(tp: Any) -> Optional[Any]: ... - Annotated: _SpecialForm = ... _AnnotatedAlias: Any = ... # undocumented @@ -106,27 +82,24 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta): def __index__(self) -> int: ... # PEP 612 support for Python < 3.9 -if sys.version_info >= (3, 10): - from typing import Concatenate as Concatenate, ParamSpec as ParamSpec, TypeAlias as TypeAlias, TypeGuard as TypeGuard -else: - 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__: Optional[Type[Any]] - __covariant__: bool - __contravariant__: bool - def __init__( - self, name: str, *, bound: Union[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 = ... +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__: Optional[Type[Any]] + __covariant__: bool + __contravariant__: bool + def __init__( + self, name: str, *, bound: Union[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/stdlib/@python2/unicodedata.pyi b/stdlib/@python2/unicodedata.pyi index a83d79ff2ed0..f45ee9a66120 100644 --- a/stdlib/@python2/unicodedata.pyi +++ b/stdlib/@python2/unicodedata.pyi @@ -15,9 +15,6 @@ def decomposition(__chr: Text) -> Text: ... def digit(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... def east_asian_width(__chr: Text) -> Text: ... -if sys.version_info >= (3, 8): - def is_normalized(__form: str, __unistr: str) -> bool: ... - def lookup(__name: Union[Text, bytes]) -> Text: ... def mirrored(__chr: Text) -> int: ... def name(__chr: Text, __default: _T = ...) -> Union[Text, _T]: ... diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index 2bb2c2a1c90e..d32bf7a4f273 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -5,12 +5,6 @@ _File = Union[Text, BinaryIO] class Error(Exception): ... -if sys.version_info >= (3, 7): - def encode( - in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ..., *, backtick: bool = ... - ) -> None: ... - -else: - def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... +def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... def decode(in_file: _File, out_file: Optional[_File] = ..., mode: Optional[int] = ..., quiet: int = ...) -> None: ... diff --git a/stdlib/@python2/uuid.pyi b/stdlib/@python2/uuid.pyi index 68b235162210..8ce48d1ed988 100644 --- a/stdlib/@python2/uuid.pyi +++ b/stdlib/@python2/uuid.pyi @@ -6,38 +6,16 @@ _Int = int _Bytes = bytes _FieldsType = 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 UUID: - if sys.version_info >= (3, 7): - def __init__( - self, - hex: Optional[Text] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., - *, - is_safe: SafeUUID = ..., - ) -> None: ... - @property - def is_safe(self) -> SafeUUID: ... - else: - def __init__( - self, - hex: Optional[Text] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., - ) -> None: ... + def __init__( + self, + hex: Optional[Text] = ..., + bytes: Optional[_Bytes] = ..., + bytes_le: Optional[_Bytes] = ..., + fields: Optional[_FieldsType] = ..., + int: Optional[_Int] = ..., + version: Optional[_Int] = ..., + ) -> None: ... @property def bytes(self) -> _Bytes: ... @property @@ -71,29 +49,22 @@ class UUID: @property def version(self) -> Optional[_Int]: ... def __int__(self) -> _Int: ... - if sys.version_info >= (3,): - def __eq__(self, other: Any) -> bool: ... - def __lt__(self, other: Any) -> bool: ... - def __le__(self, other: Any) -> bool: ... - def __gt__(self, other: Any) -> bool: ... - def __ge__(self, other: Any) -> bool: ... - else: - 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) -> Optional[_Int]: ... - def __cmp__(self, other: Any) -> _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) -> Optional[_Int]: ... + def __cmp__(self, other: Any) -> _Int: ... def getnode() -> int: ... def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ... diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index 0e64ec574775..290700c5ce8f 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -31,28 +31,15 @@ class WarningMessage: lineno: int file: Optional[TextIO] line: Optional[str] - if sys.version_info >= (3, 6): - source: Optional[Any] - def __init__( - self, - message: Union[Warning, str], - category: Type[Warning], - filename: str, - lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., - source: Optional[Any] = ..., - ) -> None: ... - else: - def __init__( - self, - message: Union[Warning, str], - category: Type[Warning], - filename: str, - lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., - ) -> None: ... + def __init__( + self, + message: Union[Warning, str], + category: Type[Warning], + filename: str, + lineno: int, + file: Optional[TextIO] = ..., + line: Optional[str] = ..., + ) -> None: ... class catch_warnings: @overload diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index d415630427da..038254666112 100644 --- a/stdlib/@python2/wave.pyi +++ b/stdlib/@python2/wave.pyi @@ -7,23 +7,10 @@ class Error(Exception): ... WAVE_FORMAT_PCM: int -if sys.version_info >= (3, 0): - class _wave_params(NamedTuple): - nchannels: int - sampwidth: int - framerate: int - nframes: int - comptype: str - compname: str - -else: - _wave_params = Tuple[int, int, int, int, str, str] +_wave_params = Tuple[int, int, int, int, str, str] class Wave_read: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 0): - def __enter__(self) -> Wave_read: ... - def __exit__(self, *args: Any) -> None: ... def getfp(self) -> Optional[BinaryIO]: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -42,9 +29,6 @@ class Wave_read: class Wave_write: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 0): - def __enter__(self) -> Wave_write: ... - def __exit__(self, *args: Any) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... @@ -70,5 +54,4 @@ class Wave_write: # Returns a Wave_read if mode is rb and Wave_write if mode is wb def open(f: _File, mode: Optional[str] = ...) -> Any: ... -if sys.version_info < (3, 9): - openfp = open +openfp = open diff --git a/stdlib/@python2/weakref.pyi b/stdlib/@python2/weakref.pyi index b43b634d6216..a107db5ea323 100644 --- a/stdlib/@python2/weakref.pyi +++ b/stdlib/@python2/weakref.pyi @@ -29,8 +29,7 @@ from _weakref import ( ref as ref, ) -if sys.version_info < (3, 0): - from exceptions import ReferenceError as ReferenceError +from exceptions import ReferenceError as ReferenceError _S = TypeVar("_S") _T = TypeVar("_T") @@ -39,11 +38,6 @@ _VT = TypeVar("_VT") ProxyTypes: Tuple[Type[Any], ...] -if sys.version_info >= (3, 4): - class WeakMethod(ref[types.MethodType]): - def __new__(cls, meth: types.MethodType, callback: Optional[Callable[[types.MethodType], Any]] = ...) -> WeakMethod: ... - def __call__(self) -> Optional[types.MethodType]: ... - class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @@ -53,24 +47,17 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... def __delitem__(self, v: _KT) -> None: ... - if sys.version_info < (3, 0): - def has_key(self, key: object) -> bool: ... + def has_key(self, key: object) -> bool: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... def copy(self) -> WeakValueDictionary[_KT, _VT]: ... - if sys.version_info >= (3, 0): - # These are incompatible with Mapping - def keys(self) -> Iterator[_KT]: ... # type: ignore - def values(self) -> Iterator[_VT]: ... # type: ignore - def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore - else: - 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 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]]: ... @@ -89,32 +76,17 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... def __delitem__(self, v: _KT) -> None: ... - if sys.version_info < (3, 0): - def has_key(self, key: object) -> bool: ... + def has_key(self, key: object) -> bool: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... def copy(self) -> WeakKeyDictionary[_KT, _VT]: ... - if sys.version_info >= (3, 0): - # These are incompatible with Mapping - def keys(self) -> Iterator[_KT]: ... # type: ignore - def values(self) -> Iterator[_VT]: ... # type: ignore - def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore - else: - 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 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]]: ... -if sys.version_info >= (3, 4): - class finalize: - def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - def __call__(self, _: Any = ...) -> Optional[Any]: ... - def detach(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... - def peek(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... - alive: bool - atexit: bool diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index 322ec2764e39..1ee0f3c563f2 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -3,15 +3,9 @@ from typing import Callable, List, Optional, Sequence, Text, Union class Error(Exception): ... -if sys.version_info >= (3, 7): - def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., *, preferred: bool = ... - ) -> None: ... - -else: - def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... - ) -> None: ... +def register( + name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... +) -> None: ... def get(using: Optional[Text] = ...) -> BaseBrowser: ... def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... diff --git a/stdlib/@python2/wsgiref/handlers.pyi b/stdlib/@python2/wsgiref/handlers.pyi index ff764e434169..ce7ea2d5e961 100644 --- a/stdlib/@python2/wsgiref/handlers.pyi +++ b/stdlib/@python2/wsgiref/handlers.pyi @@ -11,9 +11,6 @@ _exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Option def format_date_time(timestamp: Optional[float]) -> str: ... # undocumented -if sys.version_info >= (3, 2): - def read_environ() -> Dict[str, str]: ... - class BaseHandler: wsgi_version: Tuple[int, int] # undocumented wsgi_multithread: bool diff --git a/stdlib/@python2/wsgiref/headers.pyi b/stdlib/@python2/wsgiref/headers.pyi index c3e943200e40..ebdc07053ebf 100644 --- a/stdlib/@python2/wsgiref/headers.pyi +++ b/stdlib/@python2/wsgiref/headers.pyi @@ -6,16 +6,12 @@ _HeaderList = List[Tuple[str, str]] tspecials: Pattern[str] # undocumented class Headers: - if sys.version_info < (3, 5): - def __init__(self, headers: _HeaderList) -> None: ... - else: - def __init__(self, headers: Optional[_HeaderList] = ...) -> None: ... + 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) -> Optional[str]: ... - if sys.version_info < (3,): - def has_key(self, name: str) -> bool: ... + def has_key(self, name: str) -> bool: ... def __contains__(self, name: str) -> bool: ... def get_all(self, name: str) -> List[str]: ... @overload @@ -25,7 +21,5 @@ class Headers: def keys(self) -> List[str]: ... def values(self) -> List[str]: ... def items(self) -> _HeaderList: ... - if sys.version_info >= (3,): - def __bytes__(self) -> bytes: ... def setdefault(self, name: str, value: str) -> str: ... def add_header(self, _name: str, _value: Optional[str], **_params: Optional[str]) -> None: ... diff --git a/stdlib/@python2/wsgiref/simple_server.pyi b/stdlib/@python2/wsgiref/simple_server.pyi index 4e0abd7e8e9d..c10ac27beaeb 100644 --- a/stdlib/@python2/wsgiref/simple_server.pyi +++ b/stdlib/@python2/wsgiref/simple_server.pyi @@ -4,10 +4,7 @@ from typing import List, Optional, Type, TypeVar, overload from .handlers import SimpleHandler from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment -if sys.version_info >= (3, 0): - from http.server import BaseHTTPRequestHandler, HTTPServer -else: - from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer server_version: str # undocumented sys_version: str # undocumented diff --git a/stdlib/@python2/wsgiref/util.pyi b/stdlib/@python2/wsgiref/util.pyi index 1c66bc1fabdf..b77e9df72f33 100644 --- a/stdlib/@python2/wsgiref/util.pyi +++ b/stdlib/@python2/wsgiref/util.pyi @@ -10,10 +10,7 @@ class FileWrapper: def __init__(self, filelike: IO[bytes], blksize: int = ...) -> None: ... def __getitem__(self, key: Any) -> bytes: ... def __iter__(self) -> FileWrapper: ... - if sys.version_info >= (3, 0): - def __next__(self) -> bytes: ... - else: - def next(self) -> bytes: ... + def next(self) -> bytes: ... def guess_scheme(environ: WSGIEnvironment) -> str: ... def application_uri(environ: WSGIEnvironment) -> str: ... diff --git a/stdlib/@python2/wsgiref/validate.pyi b/stdlib/@python2/wsgiref/validate.pyi index bc9f0b8c680f..cd62d785b701 100644 --- a/stdlib/@python2/wsgiref/validate.pyi +++ b/stdlib/@python2/wsgiref/validate.pyi @@ -9,12 +9,8 @@ def validator(application: WSGIApplication) -> WSGIApplication: ... class InputWrapper: input: InputStream def __init__(self, wsgi_input: InputStream) -> None: ... - if sys.version_info >= (3, 0): - def read(self, size: int) -> bytes: ... - def readline(self, size: int = ...) -> bytes: ... - else: - def read(self, size: int = ...) -> bytes: ... - def readline(self) -> bytes: ... + 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: ... @@ -44,9 +40,6 @@ class IteratorWrapper: check_start_response: Optional[bool] def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: Optional[bool]) -> None: ... def __iter__(self) -> IteratorWrapper: ... - if sys.version_info >= (3, 0): - def __next__(self) -> bytes: ... - else: - def next(self) -> bytes: ... + def next(self) -> bytes: ... def close(self) -> None: ... def __del__(self) -> None: ... diff --git a/stdlib/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 67e9b1189528..47a7227bf621 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -17,14 +17,8 @@ class Node(xml.dom.Node): nextSibling: Any previousSibling: Any prefix: Any - if sys.version_info >= (3, 9): - def toxml(self, encoding: Optional[Any] = ..., standalone: Optional[Any] = ...): ... - def toprettyxml( - self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ..., standalone: Optional[Any] = ... - ): ... - else: - def toxml(self, encoding: Optional[Any] = ...): ... - def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ... + def toxml(self, encoding: Optional[Any] = ...): ... + def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ... def hasChildNodes(self) -> bool: ... def insertBefore(self, newChild, refChild): ... def appendChild(self, node): ... @@ -295,18 +289,7 @@ class Document(Node, DocumentLS): def getElementsByTagNameNS(self, namespaceURI: str, localName): ... def isSupported(self, feature, version): ... def importNode(self, node, deep): ... - if sys.version_info >= (3, 9): - def writexml( - self, - writer, - indent: str = ..., - addindent: str = ..., - newl: str = ..., - encoding: Optional[Any] = ..., - standalone: Optional[Any] = ..., - ) -> None: ... - else: - def writexml( - self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ... - ) -> None: ... + def writexml( + self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ... + ) -> None: ... def renameNode(self, n, namespaceURI: str, name): ... diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 4aa0173fa82f..60e006c2601e 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -13,13 +13,4 @@ def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[ # 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... -if sys.version_info >= (3, 9): - def include( - elem: Element, - loader: Optional[Callable[..., Union[str, Element]]] = ..., - base_url: Optional[str] = ..., - max_depth: Optional[int] = ..., - ) -> None: ... - -else: - def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... +def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index ca4e3832f37e..1982710f21a7 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -47,47 +47,13 @@ _parser_input_type = Union[bytes, Text] _str_argument_type = Union[str, Text] # Type for return values from individual tag/attr/text values -if sys.version_info >= (3,): - # note: in python3, everything comes out as str, yay: - _str_result_type = str -else: - # 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 +# 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 = Union[AnyPath, FileDescriptor, IO[Any]] -if sys.version_info >= (3, 8): - @overload - def canonicalize( - xml_data: Optional[_parser_input_type] = ..., - *, - out: None = ..., - from_file: Optional[_file_or_filename] = ..., - with_comments: bool = ..., - strip_text: bool = ..., - rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., - ) -> str: ... - @overload - def canonicalize( - xml_data: Optional[_parser_input_type] = ..., - *, - out: SupportsWrite[str], - from_file: Optional[_file_or_filename] = ..., - with_comments: bool = ..., - strip_text: bool = ..., - rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., - ) -> None: ... - class Element(MutableSequence[Element]): tag: _str_result_type attrib: Dict[_str_result_type, _str_result_type] @@ -123,10 +89,7 @@ class Element(MutableSequence[Element]): def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ... @overload def get(self, key: _str_argument_type, default: _T) -> Union[_str_result_type, _T]: ... - if sys.version_info >= (3, 2): - def insert(self, __index: int, __subelement: Element) -> None: ... - else: - def insert(self, __index: int, __element: Element) -> None: ... + def insert(self, __index: int, __element: Element) -> None: ... def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... def iterfind( @@ -147,9 +110,8 @@ class Element(MutableSequence[Element]): def __setitem__(self, i: int, o: Element) -> None: ... @overload def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ... - if sys.version_info < (3, 9): - def getchildren(self) -> List[Element]: ... - def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... + def getchildren(self) -> List[Element]: ... + def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... def SubElement( parent: Element, @@ -171,8 +133,7 @@ class ElementTree: def getroot(self) -> Element: ... def parse(self, source: _file_or_filename, parser: Optional[XMLParser] = ...) -> Element: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... - if sys.version_info < (3, 9): - def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... + def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... def find( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> Optional[Element]: ... @@ -193,91 +154,17 @@ class ElementTree: def iterfind( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> Generator[Element, None, None]: ... - if sys.version_info >= (3, 4): - def write( - self, - file_or_filename: _file_or_filename, - encoding: Optional[str] = ..., - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - method: Optional[str] = ..., - *, - short_empty_elements: bool = ..., - ) -> None: ... - else: - def write( - self, - file_or_filename: _file_or_filename, - encoding: Optional[str] = ..., - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - method: Optional[str] = ..., - ) -> None: ... - def write_c14n(self, file: _file_or_filename) -> None: ... - -def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... - -if sys.version_info >= (3, 8): - @overload - def tostring( - element: Element, - encoding: None = ..., - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> bytes: ... - @overload - def tostring( - element: Element, - encoding: Literal["unicode"], - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> str: ... - @overload - def tostring( - element: Element, - encoding: str, - method: Optional[str] = ..., - *, + def write( + self, + file_or_filename: _file_or_filename, + encoding: Optional[str] = ..., xml_declaration: Optional[bool] = ..., default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> Any: ... - @overload - def tostringlist( - element: Element, - encoding: None = ..., method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> List[bytes]: ... - @overload - def tostringlist( - element: Element, - encoding: Literal["unicode"], - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> List[str]: ... - @overload - def tostringlist( - element: Element, - encoding: str, - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> List[Any]: ... + ) -> None: ... + def write_c14n(self, file: _file_or_filename) -> None: ... + +def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... elif sys.version_info >= (3,): @overload @@ -309,21 +196,11 @@ else: def dump(elem: Element) -> None: ... -if sys.version_info >= (3, 9): - def indent(tree: Union[Element, ElementTree], space: str = ..., level: int = ...) -> None: ... - def parse(source: _file_or_filename, parser: Optional[XMLParser] = ...) -> ElementTree: ... def iterparse( source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ... ) -> Iterator[Tuple[str, Any]]: ... -if sys.version_info >= (3, 4): - class XMLPullParser: - def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ... - def feed(self, data: bytes) -> None: ... - def close(self) -> None: ... - def read_events(self) -> Iterator[Tuple[str, Element]]: ... - def XML(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Element: ... def XMLID(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ... @@ -350,31 +227,13 @@ class TreeBuilder: def start(self, __tag: _parser_input_type, __attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ... def end(self, __tag: _parser_input_type) -> Element: ... -if sys.version_info >= (3, 8): - class C14NWriterTarget: - def __init__( - self, - write: Callable[[str], Any], - *, - with_comments: bool = ..., - strip_text: bool = ..., - rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., - ) -> None: ... - class XMLParser: parser: Any target: Any # TODO-what is entity used for??? entity: Any version: str - if sys.version_info >= (3, 8): - def __init__(self, *, target: Any = ..., encoding: Optional[str] = ...) -> None: ... - else: - def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> None: ... - def doctype(self, __name: str, __pubid: str, __system: str) -> None: ... + def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> 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/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index a95fde106535..086f1c8e4580 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -22,11 +22,7 @@ class SAXReaderNotAvailable(SAXNotSupportedException): ... default_parser_list: List[str] -if sys.version_info >= (3, 8): - def make_parser(parser_list: Iterable[str] = ...) -> XMLReader: ... - -else: - def make_parser(parser_list: List[str] = ...) -> XMLReader: ... +def make_parser(parser_list: List[str] = ...) -> XMLReader: ... def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... def parseString(string: Union[bytes, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... diff --git a/stdlib/@python2/xml/sax/saxutils.pyi b/stdlib/@python2/xml/sax/saxutils.pyi index 8ae2b80d2a26..17b5d278ae59 100644 --- a/stdlib/@python2/xml/sax/saxutils.pyi +++ b/stdlib/@python2/xml/sax/saxutils.pyi @@ -10,19 +10,11 @@ def unescape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... def quoteattr(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... class XMLGenerator(handler.ContentHandler): - if sys.version_info >= (3, 0): - def __init__( - self, - out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., - encoding: str = ..., - short_empty_elements: bool = ..., - ) -> None: ... - else: - def __init__( - self, - out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., - encoding: Text = ..., - ) -> None: ... + def __init__( + self, + out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., + encoding: Text = ..., + ) -> None: ... def startDocument(self): ... def endDocument(self): ... def startPrefixMapping(self, prefix, uri): ... diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index 91727aa540fb..4bf98e2c500e 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -23,11 +23,7 @@ from typing import ( _SZI = Union[Text, ZipInfo] _DT = Tuple[int, int, int, int, int, int] -if sys.version_info >= (3,): - class BadZipFile(Exception): ... - BadZipfile = BadZipFile -else: - class BadZipfile(Exception): ... +class BadZipfile(Exception): ... error = BadZipfile @@ -37,28 +33,19 @@ class ZipExtFile(io.BufferedIOBase): MAX_N: int = ... MIN_READ_SIZE: int = ... - if sys.version_info < (3, 6): - PATTERN: Pattern[str] = ... - - if sys.version_info >= (3, 7): - MAX_SEEK_READ: int = ... + PATTERN: Pattern[str] = ... newlines: Optional[List[bytes]] mode: str name: str - if sys.version_info >= (3, 7): - def __init__( - self, fileobj: IO[bytes], mode: str, zipinfo: ZipInfo, pwd: Optional[bytes] = ..., close_fileobj: bool = ... - ) -> None: ... - else: - def __init__( - self, - fileobj: IO[bytes], - mode: str, - zipinfo: ZipInfo, - decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., - close_fileobj: bool = ..., - ) -> None: ... + def __init__( + self, + fileobj: IO[bytes], + mode: str, + zipinfo: ZipInfo, + decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., + close_fileobj: bool = ..., + ) -> None: ... def read(self, n: Optional[int] = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... # type: ignore def __repr__(self) -> str: ... @@ -76,17 +63,6 @@ class ZipFile: fp: Optional[IO[bytes]] NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented - if sys.version_info >= (3, 8): - def __init__( - self, - file: Union[StrPath, IO[bytes]], - mode: str = ..., - compression: int = ..., - allowZip64: bool = ..., - compresslevel: Optional[int] = ..., - *, - strict_timestamps: bool = ..., - ) -> None: ... elif sys.version_info >= (3, 7): def __init__( self, @@ -113,49 +89,18 @@ class ZipFile: def extractall( self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ... ) -> None: ... - if sys.version_info >= (3,): - def printdir(self, file: Optional[_Writer] = ...) -> None: ... - else: - def printdir(self) -> None: ... + def printdir(self) -> None: ... def setpassword(self, pwd: bytes) -> None: ... def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ... def testzip(self) -> Optional[str]: ... - if sys.version_info >= (3, 7): - def write( - self, - filename: StrPath, - arcname: Optional[StrPath] = ..., - compress_type: Optional[int] = ..., - compresslevel: Optional[int] = ..., - ) -> None: ... - else: - def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... - if sys.version_info >= (3, 7): - def writestr( - self, - zinfo_or_arcname: _SZI, - data: Union[bytes, str], - compress_type: Optional[int] = ..., - compresslevel: Optional[int] = ..., - ) -> None: ... + def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... elif sys.version_info >= (3,): def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ... else: def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ... class PyZipFile(ZipFile): - if sys.version_info >= (3,): - def __init__( - self, - file: Union[str, IO[bytes]], - mode: str = ..., - compression: int = ..., - allowZip64: bool = ..., - optimize: int = ..., - ) -> None: ... - def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ... - else: - def writepy(self, pathname: Text, basename: Text = ...) -> None: ... + def writepy(self, pathname: Text, basename: Text = ...) -> None: ... class ZipInfo: filename: Text @@ -176,47 +121,14 @@ class ZipInfo: compress_size: int file_size: int def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ... - if sys.version_info >= (3, 8): - @classmethod - def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ... elif sys.version_info >= (3, 6): @classmethod def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ...) -> ZipInfo: ... - if sys.version_info >= (3, 6): - def is_dir(self) -> bool: ... def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ... class _PathOpenProtocol(Protocol): def __call__(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... -if sys.version_info >= (3, 8): - class Path: - @property - def name(self) -> str: ... - @property - def parent(self) -> Path: ... # undocumented - def __init__(self, root: Union[ZipFile, StrPath, IO[bytes]], at: str = ...) -> None: ... - if sys.version_info >= (3, 9): - def open(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... - else: - @property - def open(self) -> _PathOpenProtocol: ... - def iterdir(self) -> Iterator[Path]: ... - def is_dir(self) -> bool: ... - def is_file(self) -> bool: ... - def exists(self) -> bool: ... - def read_text( - self, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - line_buffering: bool = ..., - write_through: bool = ..., - ) -> str: ... - def read_bytes(self) -> bytes: ... - def joinpath(self, add: StrPath) -> Path: ... # undocumented - def __truediv__(self, add: StrPath) -> Path: ... - def is_zipfile(filename: Union[StrPath, IO[bytes]]) -> bool: ... ZIP_STORED: int @@ -224,6 +136,3 @@ ZIP_DEFLATED: int ZIP64_LIMIT: int ZIP_FILECOUNT_LIMIT: int ZIP_MAX_COMMENT: int -if sys.version_info >= (3, 3): - ZIP_BZIP2: int - ZIP_LZMA: int diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index 0d1a330942d4..cf348c6554b1 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -3,28 +3,16 @@ import sys from types import CodeType, ModuleType from typing import Any, List, Optional, Tuple, Union -if sys.version_info >= (3, 7): - from importlib.abc import ResourceReader - class ZipImportError(ImportError): ... class zipimporter(object): archive: str prefix: str - if sys.version_info >= (3, 6): - def __init__(self, path: Union[str, bytes, os.PathLike[Any]]) -> None: ... - else: - def __init__(self, path: Union[str, bytes]) -> None: ... - if sys.version_info >= (3,): - def find_loader( - self, fullname: str, path: Optional[str] = ... - ) -> Tuple[Optional[zipimporter], List[str]]: ... # undocumented + def __init__(self, path: Union[str, bytes]) -> None: ... def find_module(self, fullname: str, path: Optional[str] = ...) -> Optional[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) -> Optional[ResourceReader]: ... # undocumented def get_source(self, fullname: str) -> Optional[str]: ... def is_package(self, fullname: str) -> bool: ... def load_module(self, fullname: str) -> ModuleType: ... diff --git a/stdlib/@python2/zlib.pyi b/stdlib/@python2/zlib.pyi index 81a9f87ce42e..2eaa418909ec 100644 --- a/stdlib/@python2/zlib.pyi +++ b/stdlib/@python2/zlib.pyi @@ -18,10 +18,6 @@ Z_HUFFMAN_ONLY: int Z_NO_FLUSH: int Z_RLE: int Z_SYNC_FLUSH: int -if sys.version_info >= (3,): - DEF_BUF_SIZE: int - ZLIB_RUNTIME_VERSION: str - class error(Exception): ... class _Compress: @@ -32,8 +28,6 @@ class _Compress: class _Decompress: unused_data: bytes unconsumed_tail: bytes - if sys.version_info >= (3,): - eof: bool def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... def flush(self, length: int = ...) -> bytes: ... def copy(self) -> _Decompress: ... @@ -41,26 +35,11 @@ class _Decompress: def adler32(__data: bytes, __value: int = ...) -> int: ... def compress(__data: bytes, level: int = ...) -> bytes: ... -if sys.version_info >= (3,): - def compressobj( - level: int = ..., - method: int = ..., - wbits: int = ..., - memLevel: int = ..., - strategy: int = ..., - zdict: Optional[bytes] = ..., - ) -> _Compress: ... - -else: - def compressobj( - level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ... - ) -> _Compress: ... +def compressobj( + level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ... +) -> _Compress: ... def crc32(__data: Union[array[Any], bytes], __value: int = ...) -> int: ... def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... -if sys.version_info >= (3,): - def decompressobj(wbits: int = ..., zdict: bytes = ...) -> _Decompress: ... - -else: - def decompressobj(wbits: int = ...) -> _Decompress: ... +def decompressobj(wbits: int = ...) -> _Decompress: ... From 0e3bd65678b7ebfdbae86744853aeadd29f2b4e5 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 15 May 2021 00:05:13 +0300 Subject: [PATCH 2/6] Revert "run script" This reverts commit baa5dbe29c33658ba21d0de8aac9afbe133c3231. --- stdlib/@python2/__future__.pyi | 9 + stdlib/@python2/_bisect.pyi | 33 +- stdlib/@python2/_codecs.pyi | 22 +- stdlib/@python2/_csv.pyi | 13 +- stdlib/@python2/_curses.pyi | 28 +- stdlib/@python2/_dummy_threading.pyi | 113 +++++-- stdlib/@python2/_heapq.pyi | 5 +- stdlib/@python2/_random.pyi | 3 +- stdlib/@python2/_thread.pyi | 12 + stdlib/@python2/_typeshed/__init__.pyi | 41 ++- stdlib/@python2/_typeshed/tkinter.pyi | 4 + stdlib/@python2/_warnings.pyi | 87 +++-- stdlib/@python2/_weakref.pyi | 8 + stdlib/@python2/_weakrefset.pyi | 5 + stdlib/@python2/aifc.pyi | 23 +- stdlib/@python2/antigravity.pyi | 2 + stdlib/@python2/argparse.pyi | 138 ++++++-- stdlib/@python2/array.pyi | 30 +- stdlib/@python2/asynchat.pyi | 15 +- stdlib/@python2/asyncore.pyi | 59 ++-- stdlib/@python2/base64.pyi | 27 +- stdlib/@python2/binascii.pyi | 30 +- stdlib/@python2/bz2.pyi | 51 ++- stdlib/@python2/cProfile.pyi | 4 + stdlib/@python2/calendar.pyi | 28 +- stdlib/@python2/cmath.pyi | 12 + stdlib/@python2/code.pyi | 20 +- stdlib/@python2/codecs.pyi | 10 +- stdlib/@python2/contextlib.pyi | 96 +++++- stdlib/@python2/crypt.pyi | 20 +- stdlib/@python2/csv.pyi | 25 +- stdlib/@python2/ctypes/__init__.pyi | 38 ++- stdlib/@python2/datetime.pyi | 276 ++++++++++++---- stdlib/@python2/decimal.pyi | 195 ++++++++--- stdlib/@python2/difflib.pyi | 63 +++- stdlib/@python2/dis.pyi | 54 ++- stdlib/@python2/doctest.pyi | 9 +- stdlib/@python2/ensurepip/__init__.pyi | 28 +- stdlib/@python2/filecmp.pyi | 46 ++- stdlib/@python2/fileinput.pyi | 65 +++- stdlib/@python2/fractions.pyi | 56 ++-- stdlib/@python2/ftplib.pyi | 54 ++- stdlib/@python2/genericpath.pyi | 4 + stdlib/@python2/hmac.pyi | 15 + stdlib/@python2/imaplib.pyi | 36 +- stdlib/@python2/imghdr.pyi | 5 +- stdlib/@python2/ipaddress.pyi | 3 + stdlib/@python2/keyword.pyi | 3 + stdlib/@python2/lib2to3/pgen2/token.pyi | 7 + stdlib/@python2/lib2to3/pytree.pyi | 5 +- stdlib/@python2/linecache.pyi | 2 + stdlib/@python2/locale.pyi | 14 +- stdlib/@python2/macpath.pyi | 53 ++- stdlib/@python2/mailbox.pyi | 9 + stdlib/@python2/math.pyi | 65 +++- stdlib/@python2/mimetypes.pyi | 7 +- stdlib/@python2/mmap.pyi | 83 ++++- stdlib/@python2/modulefinder.pyi | 25 +- stdlib/@python2/msilib/__init__.pyi | 3 +- stdlib/@python2/nntplib.pyi | 5 +- stdlib/@python2/numbers.pyi | 36 +- stdlib/@python2/opcode.pyi | 5 + stdlib/@python2/operator.pyi | 58 ++-- stdlib/@python2/optparse.pyi | 8 +- stdlib/@python2/os/__init__.pyi | 63 +++- stdlib/@python2/pdb.pyi | 163 ++++++--- stdlib/@python2/pickle.pyi | 78 +++++ stdlib/@python2/pickletools.pyi | 63 +++- stdlib/@python2/pkgutil.pyi | 20 +- stdlib/@python2/plistlib.pyi | 60 +++- stdlib/@python2/poplib.pyi | 34 +- stdlib/@python2/pprint.pyi | 50 +++ stdlib/@python2/pstats.pyi | 13 + stdlib/@python2/pty.pyi | 6 +- stdlib/@python2/py_compile.pyi | 19 ++ stdlib/@python2/pyclbr.pyi | 18 +- stdlib/@python2/pydoc.pyi | 14 +- stdlib/@python2/pyexpat/errors.pyi | 4 + stdlib/@python2/queue.pyi | 17 + stdlib/@python2/readline.pyi | 6 + stdlib/@python2/rlcompleter.pyi | 5 +- stdlib/@python2/sched.pyi | 28 +- stdlib/@python2/select.pyi | 29 +- stdlib/@python2/shutil.pyi | 95 +++++- stdlib/@python2/smtpd.pyi | 53 ++- stdlib/@python2/sndhdr.pyi | 11 +- stdlib/@python2/socket.pyi | 218 +++++++++++- stdlib/@python2/socketserver.pyi | 4 + stdlib/@python2/sqlite3/dbapi2.pyi | 182 ++++++---- stdlib/@python2/sre_compile.pyi | 13 +- stdlib/@python2/ssl.pyi | 329 +++++++++++++++---- stdlib/@python2/struct.pyi | 18 +- stdlib/@python2/sunau.pyi | 21 +- stdlib/@python2/symtable.pyi | 12 +- stdlib/@python2/tarfile.pyi | 66 +++- stdlib/@python2/telnetlib.pyi | 3 + stdlib/@python2/threading.pyi | 113 +++++-- stdlib/@python2/time.pyi | 84 ++++- stdlib/@python2/timeit.pyi | 32 +- stdlib/@python2/token.pyi | 25 +- stdlib/@python2/traceback.pyi | 150 ++++++++- stdlib/@python2/turtle.pyi | 62 +++- stdlib/@python2/typing_extensions.pyi | 77 +++-- stdlib/@python2/unicodedata.pyi | 3 + stdlib/@python2/uu.pyi | 8 +- stdlib/@python2/uuid.pyi | 79 +++-- stdlib/@python2/warnings.pyi | 31 +- stdlib/@python2/wave.pyi | 21 +- stdlib/@python2/weakref.pyi | 60 +++- stdlib/@python2/webbrowser.pyi | 12 +- stdlib/@python2/wsgiref/handlers.pyi | 3 + stdlib/@python2/wsgiref/headers.pyi | 10 +- stdlib/@python2/wsgiref/simple_server.pyi | 5 +- stdlib/@python2/wsgiref/util.pyi | 5 +- stdlib/@python2/wsgiref/validate.pyi | 13 +- stdlib/@python2/xml/dom/minidom.pyi | 27 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 11 +- stdlib/@python2/xml/etree/ElementTree.pyi | 177 +++++++++- stdlib/@python2/xml/sax/__init__.pyi | 6 +- stdlib/@python2/xml/sax/saxutils.pyi | 18 +- stdlib/@python2/zipfile.pyi | 117 ++++++- stdlib/@python2/zipimport.pyi | 14 +- stdlib/@python2/zlib.pyi | 29 +- 123 files changed, 4290 insertions(+), 925 deletions(-) diff --git a/stdlib/@python2/__future__.pyi b/stdlib/@python2/__future__.pyi index 8f5ff06ac080..8a5035271eec 100644 --- a/stdlib/@python2/__future__.pyi +++ b/stdlib/@python2/__future__.pyi @@ -14,4 +14,13 @@ nested_scopes: _Feature print_function: _Feature unicode_literals: _Feature with_statement: _Feature +if sys.version_info >= (3, 0): + barry_as_FLUFL: _Feature + +if sys.version_info >= (3, 5): + generator_stop: _Feature + +if sys.version_info >= (3, 7): + annotations: _Feature + all_feature_names: List[str] # undocumented diff --git a/stdlib/@python2/_bisect.pyi b/stdlib/@python2/_bisect.pyi index 80a0bea735a3..3ca863a2e939 100644 --- a/stdlib/@python2/_bisect.pyi +++ b/stdlib/@python2/_bisect.pyi @@ -4,7 +4,32 @@ from typing import Callable, MutableSequence, Optional, Sequence, TypeVar _T = TypeVar("_T") -def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... -def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... -def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... -def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... +if sys.version_info >= (3, 10): + def bisect_left( + a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... + ) -> int: ... + def bisect_right( + a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... + ) -> int: ... + def insort_left( + a: MutableSequence[_T], + x: _T, + lo: int = ..., + hi: Optional[int] = ..., + *, + key: Optional[Callable[[_T], SupportsLessThan]] = ..., + ) -> None: ... + def insort_right( + a: MutableSequence[_T], + x: _T, + lo: int = ..., + hi: Optional[int] = ..., + *, + key: Optional[Callable[[_T], SupportsLessThan]] = ..., + ) -> None: ... + +else: + def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... + def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... + def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... + def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index 27fad0fdcef7..fbb014aadbfb 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -6,8 +6,12 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union _Handler = Callable[[Exception], Tuple[Text, int]] _String = Union[bytes, str] _Errors = Union[str, Text, None] -_Decodable = Union[bytes, Text] -_Encodable = Union[bytes, Text] +if sys.version_info >= (3, 0): + _Decodable = bytes + _Encodable = str +else: + _Decodable = Union[bytes, Text] + _Encodable = Union[bytes, Text] # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap(object): @@ -25,7 +29,8 @@ 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]: ... +if sys.version_info < (3, 2): + def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ... def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... @@ -39,8 +44,9 @@ def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> Tuple[bytes, 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]: ... +if sys.version_info < (3, 8): + 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]: ... @@ -68,3 +74,9 @@ 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]: ... + if sys.version_info >= (3, 0): + def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... + def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... + if sys.version_info >= (3, 6): + def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... + def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index 9544ba91958c..2b4b1a743865 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_csv.pyi @@ -24,13 +24,20 @@ _DialectLike = Union[str, Dialect, Type[Dialect]] class _reader(Iterator[List[str]]): dialect: Dialect line_num: int - def next(self) -> List[str]: ... + if sys.version_info >= (3, 0): + def __next__(self) -> List[str]: ... + else: + def next(self) -> List[str]: ... class _writer: dialect: Dialect - def writerow(self, row: Sequence[Any]) -> Any: ... - def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... + if sys.version_info >= (3, 5): + def writerow(self, row: Iterable[Any]) -> Any: ... + def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... + else: + def writerow(self, row: Sequence[Any]) -> Any: ... + def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... class _Writer(Protocol): def write(self, s: str) -> Any: ... diff --git a/stdlib/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index e5591d596104..1ccd54e35edd 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -57,6 +57,8 @@ A_COLOR: int A_DIM: int A_HORIZONTAL: int A_INVIS: int +if sys.version_info >= (3, 7): + A_ITALIC: int A_LEFT: int A_LOW: int A_NORMAL: int @@ -267,7 +269,11 @@ 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: ... +if sys.version_info >= (3, 8): + def color_pair(pair_number: int) -> int: ... + +else: + def color_pair(__color_number: int) -> int: ... def curs_set(__visibility: int) -> int: ... def def_prog_mode() -> None: ... @@ -343,15 +349,23 @@ def tparm( def typeahead(__fd: int) -> None: ... def unctrl(__ch: _chtype) -> bytes: ... +if sys.version_info >= (3, 3): + def unget_wch(__ch: Union[int, str]) -> None: ... + def ungetch(__ch: _chtype) -> None: ... def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ... +if sys.version_info >= (3, 5): + def update_lines_cols() -> int: ... + def use_default_colors() -> None: ... def use_env(__flag: bool) -> None: ... class error(Exception): ... class _CursesWindow: + if sys.version_info >= (3, 3): + encoding: str @overload def addch(self, ch: _chtype, attr: int = ...) -> None: ... @overload @@ -415,6 +429,11 @@ class _CursesWindow: def getch(self) -> int: ... @overload def getch(self, y: int, x: int) -> int: ... + if sys.version_info >= (3, 3): + @overload + def get_wch(self) -> Union[int, str]: ... + @overload + def get_wch(self, y: int, x: int) -> Union[int, str]: ... @overload def getkey(self) -> str: ... @overload @@ -514,3 +533,10 @@ class _CursesWindow: @overload def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... +if sys.version_info >= (3, 8): + class _ncurses_version(NamedTuple): + major: int + minor: int + patch: int + ncurses_version: _ncurses_version + window = _CursesWindow # undocumented diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index f8e1fc46b10a..af0b0af89d9b 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -12,17 +12,30 @@ __all__: List[str] def active_count() -> int: ... -def activeCount() -> int: ... +if sys.version_info < (3,): + def activeCount() -> int: ... def current_thread() -> Thread: ... def currentThread() -> Thread: ... +if sys.version_info >= (3,): + def get_ident() -> int: ... + def enumerate() -> List[Thread]: ... +if sys.version_info >= (3, 4): + def main_thread() -> Thread: ... + +if sys.version_info >= (3, 8): + from _thread import get_native_id as get_native_id + def settrace(func: _TF) -> None: ... def setprofile(func: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... +if sys.version_info >= (3,): + TIMEOUT_MAX: float + class ThreadError(Exception): ... class local(object): @@ -34,21 +47,37 @@ class Thread: name: str ident: Optional[int] daemon: bool - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[Text] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., - ) -> None: ... + if sys.version_info >= (3,): + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[str] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[str, Any]] = ..., + *, + daemon: Optional[bool] = ..., + ) -> None: ... + else: + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[Text] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[Text, Any]] = ..., + ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: Text) -> None: ... + if sys.version_info >= (3, 8): + @property + def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - def isAlive(self) -> bool: ... + if sys.version_info < (3, 9): + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -60,7 +89,10 @@ class Lock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -70,7 +102,10 @@ class _RLock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock @@ -81,9 +116,14 @@ class Condition: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... + if sys.version_info >= (3,): + def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -93,23 +133,56 @@ class Semaphore: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... + def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... + def __enter__(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3, 9): + def release(self, n: int = ...) -> None: ... + else: + def release(self) -> None: ... class BoundedSemaphore(Semaphore): ... class Event: def __init__(self) -> None: ... def is_set(self) -> bool: ... - def isSet(self) -> bool: ... + if sys.version_info < (3,): + def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... +if sys.version_info >= (3, 8): + from _thread import _excepthook, _ExceptHookArgs + + excepthook = _excepthook + ExceptHookArgs = _ExceptHookArgs + class Timer(Thread): - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... + if sys.version_info >= (3,): + def __init__( + self, + interval: float, + function: Callable[..., Any], + args: Optional[Iterable[Any]] = ..., + kwargs: Optional[Mapping[str, Any]] = ..., + ) -> None: ... + else: + def __init__( + self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... + ) -> None: ... def cancel(self) -> None: ... +if sys.version_info >= (3,): + class Barrier: + parties: int + n_waiting: int + broken: bool + def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... + def wait(self, timeout: Optional[float] = ...) -> int: ... + def reset(self) -> None: ... + def abort(self) -> None: ... + class BrokenBarrierError(RuntimeError): ... diff --git a/stdlib/@python2/_heapq.pyi b/stdlib/@python2/_heapq.pyi index 2928f39c2c17..5b14a9de773d 100644 --- a/stdlib/@python2/_heapq.pyi +++ b/stdlib/@python2/_heapq.pyi @@ -9,5 +9,6 @@ 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: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... -def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... +if sys.version_info < (3,): + def nlargest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... + def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... diff --git a/stdlib/@python2/_random.pyi b/stdlib/@python2/_random.pyi index 3d1d6476953f..aa09693420ca 100644 --- a/stdlib/@python2/_random.pyi +++ b/stdlib/@python2/_random.pyi @@ -11,4 +11,5 @@ class Random(object): def setstate(self, __state: _State) -> None: ... def random(self) -> float: ... def getrandbits(self, __k: int) -> int: ... - def jumpahead(self, i: int) -> None: ... + if sys.version_info < (3,): + def jumpahead(self, i: int) -> None: ... diff --git a/stdlib/@python2/_thread.pyi b/stdlib/@python2/_thread.pyi index 6cf7f5f59206..513678499223 100644 --- a/stdlib/@python2/_thread.pyi +++ b/stdlib/@python2/_thread.pyi @@ -27,3 +27,15 @@ def stack_size(size: int = ...) -> int: ... TIMEOUT_MAX: float +if sys.version_info >= (3, 8): + def get_native_id() -> int: ... # only available on some platforms + class _ExceptHookArgs(Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]): + @property + def exc_type(self) -> Type[BaseException]: ... + @property + def exc_value(self) -> Optional[BaseException]: ... + @property + def exc_traceback(self) -> Optional[TracebackType]: ... + @property + def thread(self) -> Optional[Thread]: ... + _excepthook: Callable[[_ExceptHookArgs], Any] diff --git a/stdlib/@python2/_typeshed/__init__.pyi b/stdlib/@python2/_typeshed/__init__.pyi index e041aa02c2af..948d4269f575 100644 --- a/stdlib/@python2/_typeshed/__init__.pyi +++ b/stdlib/@python2/_typeshed/__init__.pyi @@ -40,8 +40,11 @@ class SupportsRDivMod(Protocol[_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]]: ... + if sys.version_info >= (3,): + def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ... + else: + # 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]: ... @@ -56,9 +59,16 @@ class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, # StrPath and AnyPath can be used in places where a # path can be used instead of a string, starting with Python 3.6. -StrPath = Text -BytesPath = bytes -AnyPath = Union[Text, bytes] +if sys.version_info >= (3, 6): + from os import PathLike + + StrPath = Union[str, PathLike[str]] + BytesPath = Union[bytes, PathLike[bytes]] + AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]] +else: + StrPath = Text + BytesPath = bytes + AnyPath = Union[Text, bytes] OpenTextModeUpdating = Literal[ "r+", @@ -145,10 +155,17 @@ class SupportsNoArgReadline(Protocol[_T_co]): class SupportsWrite(Protocol[_T_contra]): def write(self, __s: _T_contra) -> Any: ... -ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer] -WriteableBuffer = Union[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]: ... +if sys.version_info >= (3,): + ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap] + WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap] +else: + ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer] + WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, buffer] + +if sys.version_info >= (3, 10): + from types import NoneType as NoneType +else: + # Used by type checkers for checks involving None (does not exist at runtime) + @final + class NoneType: + def __bool__(self) -> Literal[False]: ... diff --git a/stdlib/@python2/_typeshed/tkinter.pyi b/stdlib/@python2/_typeshed/tkinter.pyi index a4b00506a0e3..565635adbb74 100644 --- a/stdlib/@python2/_typeshed/tkinter.pyi +++ b/stdlib/@python2/_typeshed/tkinter.pyi @@ -1,3 +1,7 @@ import sys from typing import Optional, Protocol +if sys.version_info >= (3,): + from tkinter import Event, Misc, Widget + class DndSource(Protocol): + def dnd_end(self, target: Optional[Widget], event: Optional[Event[Misc]]) -> None: ... diff --git a/stdlib/@python2/_warnings.pyi b/stdlib/@python2/_warnings.pyi index 2844b0b690fa..b4ec4e6ee794 100644 --- a/stdlib/@python2/_warnings.pyi +++ b/stdlib/@python2/_warnings.pyi @@ -1,32 +1,67 @@ import sys from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload -default_action: str -once_registry: Dict[Any, Any] +if sys.version_info >= (3, 0): + _defaultaction: str + _onceregistry: Dict[Any, Any] +else: + default_action: str + once_registry: Dict[Any, Any] filters: List[Tuple[Any, ...]] -@overload -def warn(message: str, category: Optional[Type[Warning]] = ..., 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: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., -) -> None: ... -@overload -def warn_explicit( - message: Warning, - category: Any, - filename: str, - lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., -) -> None: ... +if sys.version_info >= (3, 6): + @overload + def warn( + message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ... + ) -> None: ... + @overload + def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Optional[Any] = ...) -> None: ... + @overload + def warn_explicit( + message: str, + category: Type[Warning], + filename: str, + lineno: int, + module: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., + source: Optional[Any] = ..., + ) -> None: ... + @overload + def warn_explicit( + message: Warning, + category: Any, + filename: str, + lineno: int, + module: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., + source: Optional[Any] = ..., + ) -> None: ... + +else: + @overload + def warn(message: str, category: Optional[Type[Warning]] = ..., 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: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., + ) -> None: ... + @overload + def warn_explicit( + message: Warning, + category: Any, + filename: str, + lineno: int, + module: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., + ) -> None: ... diff --git a/stdlib/@python2/_weakref.pyi b/stdlib/@python2/_weakref.pyi index 3c395dc7206e..115a591ce4c8 100644 --- a/stdlib/@python2/_weakref.pyi +++ b/stdlib/@python2/_weakref.pyi @@ -1,6 +1,9 @@ import sys from typing import Any, Callable, Generic, List, Optional, TypeVar, overload +if sys.version_info >= (3, 9): + from types import GenericAlias + _C = TypeVar("_C", bound=Callable[..., Any]) _T = TypeVar("_T") @@ -11,9 +14,14 @@ class ProxyType(Generic[_T]): # "weakproxy" def __getattr__(self, attr: str) -> Any: ... class ReferenceType(Generic[_T]): + if sys.version_info >= (3, 4): + __callback__: Callable[[ReferenceType[_T]], Any] def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ... def __call__(self) -> Optional[_T]: ... def __hash__(self) -> int: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + ref = ReferenceType def getweakrefcount(__object: Any) -> int: ... diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index f5f4fc5241c9..c369584aa243 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -1,6 +1,9 @@ import sys from typing import Any, Generic, Iterable, Iterator, MutableSet, Optional, TypeVar, Union +if sys.version_info >= (3, 9): + from types import GenericAlias + _S = TypeVar("_S") _T = TypeVar("_T") _SelfT = TypeVar("_SelfT", bound=WeakSet[Any]) @@ -40,3 +43,5 @@ class WeakSet(MutableSet[_T], Generic[_T]): def union(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... def __or__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... def isdisjoint(self, other: Iterable[_T]) -> bool: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index 68c4286cc150..f812ac593e97 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -18,6 +18,11 @@ _Marker = Tuple[int, int, bytes] class Aifc_read: def __init__(self, f: _File) -> None: ... + if sys.version_info >= (3, 4): + def __enter__(self) -> Aifc_read: ... + def __exit__( + self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def getfp(self) -> IO[bytes]: ... def rewind(self) -> None: ... @@ -38,6 +43,11 @@ class Aifc_read: class Aifc_write: def __init__(self, f: _File) -> None: ... def __del__(self) -> None: ... + if sys.version_info >= (3, 4): + def __enter__(self) -> Aifc_write: ... + def __exit__( + self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def aiff(self) -> None: ... def aifc(self) -> None: ... @@ -69,9 +79,10 @@ def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... @overload def open(f: _File, mode: Optional[str] = ...) -> 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: Optional[str] = ...) -> Any: ... +if sys.version_info < (3, 9): + @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: Optional[str] = ...) -> Any: ... diff --git a/stdlib/@python2/antigravity.pyi b/stdlib/@python2/antigravity.pyi index 44bd5c72b94b..52e2c5d96bef 100644 --- a/stdlib/@python2/antigravity.pyi +++ b/stdlib/@python2/antigravity.pyi @@ -1,2 +1,4 @@ import sys +if sys.version_info >= (3, 0): + def geohash(latitude: float, longitude: float, datedow: bytes) -> None: ... diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 149d2c1f5f19..9dceaabd4631 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -24,7 +24,10 @@ _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) _N = TypeVar("_N") -_Text = Union[str, unicode] +if sys.version_info >= (3,): + _Text = str +else: + _Text = Union[str, unicode] ONE_OR_MORE: str OPTIONAL: str @@ -106,11 +109,31 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): fromfile_prefix_chars: Optional[_Text] add_help: bool + if sys.version_info >= (3, 5): + allow_abbrev: bool + # undocumented _positionals: _ArgumentGroup _optionals: _ArgumentGroup _subparsers: Optional[_ArgumentGroup] + if sys.version_info >= (3, 9): + def __init__( + self, + prog: Optional[str] = ..., + usage: Optional[str] = ..., + description: Optional[str] = ..., + epilog: Optional[str] = ..., + parents: Sequence[ArgumentParser] = ..., + formatter_class: _FormatterClass = ..., + prefix_chars: str = ..., + fromfile_prefix_chars: Optional[str] = ..., + argument_default: Any = ..., + conflict_handler: str = ..., + add_help: bool = ..., + allow_abbrev: bool = ..., + exit_on_error: bool = ..., + ) -> None: ... elif sys.version_info >= (3, 5): def __init__( self, @@ -154,19 +177,35 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore @overload def parse_args(self, *, namespace: _N) -> _N: ... - def add_subparsers( - self, - *, - title: Text = ..., - description: Optional[Text] = ..., - prog: Text = ..., - parser_class: Type[ArgumentParser] = ..., - action: Type[Action] = ..., - option_string: Text = ..., - dest: Optional[Text] = ..., - help: Optional[Text] = ..., - metavar: Optional[Text] = ..., - ) -> _SubParsersAction: ... + if sys.version_info >= (3, 7): + def add_subparsers( + self, + *, + title: str = ..., + description: Optional[str] = ..., + prog: str = ..., + parser_class: Type[ArgumentParser] = ..., + action: Type[Action] = ..., + option_string: str = ..., + dest: Optional[str] = ..., + required: bool = ..., + help: Optional[str] = ..., + metavar: Optional[str] = ..., + ) -> _SubParsersAction: ... + else: + def add_subparsers( + self, + *, + title: Text = ..., + description: Optional[Text] = ..., + prog: Text = ..., + parser_class: Type[ArgumentParser] = ..., + action: Type[Action] = ..., + option_string: Text = ..., + dest: Optional[Text] = ..., + help: Optional[Text] = ..., + metavar: Optional[Text] = ..., + ) -> _SubParsersAction: ... def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... def print_help(self, file: Optional[IO[str]] = ...) -> None: ... def format_usage(self) -> str: ... @@ -177,6 +216,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def convert_arg_line_to_args(self, arg_line: Text) -> List[str]: ... def exit(self, status: int = ..., message: Optional[Text] = ...) -> NoReturn: ... def error(self, message: Text) -> NoReturn: ... + if sys.version_info >= (3, 7): + def parse_intermixed_args( + self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... + ) -> Namespace: ... + def parse_known_intermixed_args( + self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... + ) -> Tuple[Namespace, List[str]]: ... # undocumented def _get_optional_actions(self) -> List[Action]: ... def _get_positional_actions(self) -> List[Action]: ... @@ -244,6 +290,9 @@ class RawDescriptionHelpFormatter(HelpFormatter): ... class RawTextHelpFormatter(RawDescriptionHelpFormatter): ... class ArgumentDefaultsHelpFormatter(HelpFormatter): ... +if sys.version_info >= (3,): + class MetavarTypeHelpFormatter(HelpFormatter): ... + class Action(_AttributeHolder): option_strings: Sequence[_Text] dest: _Text @@ -275,6 +324,23 @@ class Action(_AttributeHolder): values: Union[Text, Sequence[Any], None], option_string: Optional[Text] = ..., ) -> None: ... + if sys.version_info >= (3, 9): + def format_usage(self) -> str: ... + +if sys.version_info >= (3, 9): + class BooleanOptionalAction(Action): + def __init__( + self, + option_strings: Sequence[str], + dest: str, + default: Union[_T, str, None] = ..., + type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., + choices: Optional[Iterable[_T]] = ..., + required: bool = ..., + help: Optional[Text] = ..., + metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + ) -> None: ... + class Namespace(_AttributeHolder): def __init__(self, **kwargs: Any) -> None: ... def __getattr__(self, name: Text) -> Any: ... @@ -285,7 +351,14 @@ class FileType: # undocumented _mode: _Text _bufsize: int - def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ... + if sys.version_info >= (3,): + _encoding: Optional[str] + _errors: Optional[str] + def __init__( + self, mode: str = ..., bufsize: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ... + ) -> None: ... + else: + def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ... def __call__(self, string: Text) -> IO[Any]: ... # undocumented @@ -378,15 +451,27 @@ class _SubParsersAction(Action): _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: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - ) -> None: ... + if sys.version_info >= (3, 7): + def __init__( + self, + option_strings: Sequence[Text], + prog: Text, + parser_class: Type[ArgumentParser], + dest: Text = ..., + required: bool = ..., + help: Optional[Text] = ..., + metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + ) -> None: ... + else: + def __init__( + self, + option_strings: Sequence[Text], + prog: Text, + parser_class: Type[ArgumentParser], + dest: Text = ..., + help: Optional[Text] = ..., + metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... def _get_subactions(self) -> List[Action]: ... @@ -394,8 +479,9 @@ class _SubParsersAction(Action): # undocumented class ArgumentTypeError(Exception): ... -# undocumented -def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ... +if sys.version_info < (3, 7): + # undocumented + def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ... # undocumented def _get_action_name(argument: Optional[Action]) -> Optional[str]: ... diff --git a/stdlib/@python2/array.pyi b/stdlib/@python2/array.pyi index af694ad2d23f..498bf92919f1 100644 --- a/stdlib/@python2/array.pyi +++ b/stdlib/@python2/array.pyi @@ -9,6 +9,9 @@ _TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] _T = TypeVar("_T", int, float, Text) +if sys.version_info >= (3,): + typecodes: str + class array(MutableSequence[_T], Generic[_T]): typecode: _TypeCode itemsize: int @@ -25,21 +28,31 @@ class array(MutableSequence[_T], Generic[_T]): def byteswap(self) -> None: ... def count(self, __v: Any) -> int: ... def extend(self, __bb: Iterable[_T]) -> None: ... + if sys.version_info >= (3, 2): + def frombytes(self, __buffer: bytes) -> 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: ... # type: ignore # Overrides Sequence + if sys.version_info >= (3, 10): + def index(self, __v: _T, __start: int = ..., __stop: int = ...) -> int: ... + else: + def index(self, __v: _T) -> int: ... # type: ignore # Overrides Sequence def insert(self, __i: int, __v: _T) -> None: ... def pop(self, __i: int = ...) -> _T: ... - def read(self, f: BinaryIO, n: int) -> None: ... + if sys.version_info < (3,): + def read(self, f: BinaryIO, n: int) -> None: ... def remove(self, __v: Any) -> None: ... def reverse(self) -> None: ... + if sys.version_info >= (3, 2): + def tobytes(self) -> bytes: ... 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: ... + if sys.version_info < (3,): + def write(self, f: BinaryIO) -> None: ... + if sys.version_info < (3, 9): + def fromstring(self, __buffer: bytes) -> None: ... + def tostring(self) -> bytes: ... def __len__(self) -> int: ... @overload def __getitem__(self, i: int) -> _T: ... @@ -59,8 +72,9 @@ class array(MutableSequence[_T], Generic[_T]): 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: ... + if sys.version_info < (3,): + 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/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index 2fc5bbf07d0f..34039b993400 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -29,10 +29,11 @@ class async_chat(asyncore.dispatcher): def initiate_send(self) -> None: ... def discard_buffers(self) -> None: ... -class fifo: - def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... - def __len__(self) -> int: ... - def is_empty(self) -> bool: ... - def first(self) -> bytes: ... - def push(self, data: Union[bytes, simple_producer]) -> None: ... - def pop(self) -> Tuple[int, bytes]: ... +if sys.version_info < (3, 0): + class fifo: + def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... + def __len__(self) -> int: ... + def is_empty(self) -> bool: ... + def first(self) -> bytes: ... + def push(self, data: Union[bytes, simple_producer]) -> None: ... + def pop(self) -> Tuple[int, bytes]: ... diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index be551a040cc1..a05a205115f3 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -59,35 +59,36 @@ class dispatcher: 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: Union[Tuple[str, int], str], flags: int = ...) -> int: ... - def setblocking(self, flag: bool) -> None: ... - def settimeout(self, value: Union[float, None]) -> None: ... - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... - def shutdown(self, how: int) -> None: ... + if sys.version_info < (3, 5): + # 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: Union[Tuple[str, int], str], flags: int = ...) -> int: ... + def setblocking(self, flag: bool) -> None: ... + def settimeout(self, value: Union[float, None]) -> None: ... + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + def shutdown(self, how: int) -> None: ... class dispatcher_with_send(dispatcher): def __init__(self, sock: SocketType = ..., map: Optional[_maptype] = ...) -> None: ... diff --git a/stdlib/@python2/base64.pyi b/stdlib/@python2/base64.pyi index 999b2713a456..e217d6d3dbf2 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -1,8 +1,12 @@ import sys from typing import IO, Optional, Union -_encodable = Union[bytes, unicode] -_decodable = Union[bytes, unicode] +if sys.version_info >= (3, 0): + _encodable = bytes + _decodable = Union[bytes, str] +else: + _encodable = Union[bytes, unicode] + _decodable = Union[bytes, unicode] def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ... def b64decode(s: _decodable, altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ... @@ -15,8 +19,23 @@ def b32decode(s: _decodable, casefold: bool = ..., map01: Optional[bytes] = ...) def b16encode(s: _encodable) -> bytes: ... def b16decode(s: _decodable, casefold: bool = ...) -> bytes: ... +if sys.version_info >= (3, 10): + def b32hexencode(s: _encodable) -> bytes: ... + def b32hexdecode(s: _decodable, casefold: bool = ...) -> bytes: ... + +if sys.version_info >= (3, 4): + def a85encode(b: _encodable, *, foldspaces: bool = ..., wrapcol: int = ..., pad: bool = ..., adobe: bool = ...) -> bytes: ... + def a85decode(b: _decodable, *, foldspaces: bool = ..., adobe: bool = ..., ignorechars: Union[str, bytes] = ...) -> bytes: ... + def b85encode(b: _encodable, pad: bool = ...) -> bytes: ... + def b85decode(b: _decodable) -> 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: ... +if sys.version_info >= (3,): + def encodebytes(s: bytes) -> bytes: ... + def decodebytes(s: bytes) -> bytes: ... + +if sys.version_info < (3, 9): + def encodestring(s: bytes) -> bytes: ... + def decodestring(s: bytes) -> bytes: ... diff --git a/stdlib/@python2/binascii.pyi b/stdlib/@python2/binascii.pyi index 69233a05a8fc..db843ad6ca31 100644 --- a/stdlib/@python2/binascii.pyi +++ b/stdlib/@python2/binascii.pyi @@ -1,17 +1,31 @@ import sys from typing import Text, Union -# Python 2 accepts unicode ascii pretty much everywhere. -_Bytes = Text -_Ascii = Text +if sys.version_info >= (3, 0): + # But since Python 3.3 ASCII-only unicode strings are accepted by the + # a2b_* functions. + _Bytes = bytes + _Ascii = Union[bytes, str] +else: + # Python 2 accepts unicode ascii pretty much everywhere. + _Bytes = Text + _Ascii = Text def a2b_uu(__data: _Ascii) -> bytes: ... -def b2a_uu(__data: _Bytes) -> bytes: ... +if sys.version_info >= (3, 7): + def b2a_uu(__data: _Bytes, *, backtick: bool = ...) -> bytes: ... + +else: + def b2a_uu(__data: _Bytes) -> bytes: ... def a2b_base64(__data: _Ascii) -> bytes: ... -def b2a_base64(__data: _Bytes) -> bytes: ... +if sys.version_info >= (3, 6): + def b2a_base64(__data: _Bytes, *, newline: bool = ...) -> bytes: ... + +else: + 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: ... @@ -23,7 +37,11 @@ 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: ... +if sys.version_info >= (3, 8): + def hexlify(data: bytes, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> bytes: ... + +else: + def hexlify(__data: _Bytes) -> bytes: ... def a2b_hex(__hexstr: _Ascii) -> bytes: ... def unhexlify(__hexstr: _Ascii) -> bytes: ... diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index 77d0f8e21c20..dfc1876bf43e 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -10,11 +10,45 @@ _T = TypeVar("_T") def compress(data: bytes, compresslevel: int = ...) -> bytes: ... def decompress(data: bytes) -> bytes: ... +if sys.version_info >= (3, 3): + _OpenBinaryMode = Literal["r", "rb", "w", "wb", "x", "xb", "a", "ab"] + _OpenTextMode = Literal["rt", "wt", "xt", "at"] + @overload + def open( + filename: _PathOrFile, + mode: _OpenBinaryMode = ..., + compresslevel: int = ..., + encoding: None = ..., + errors: None = ..., + newline: None = ..., + ) -> BZ2File: ... + @overload + def open( + filename: AnyPath, + mode: _OpenTextMode, + compresslevel: int = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + ) -> TextIO: ... + @overload + def open( + filename: _PathOrFile, + mode: str, + compresslevel: int = ..., + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + ) -> Union[BZ2File, TextIO]: ... + class BZ2File(io.BufferedIOBase, IO[bytes]): def __enter__(self: _T) -> _T: ... - def __init__( - self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... - ) -> None: ... + if sys.version_info >= (3, 9): + def __init__(self, filename: _PathOrFile, mode: str = ..., *, compresslevel: int = ...) -> None: ... + else: + def __init__( + self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... + ) -> None: ... def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore @@ -30,6 +64,15 @@ class BZ2Compressor(object): def flush(self) -> bytes: ... class BZ2Decompressor(object): - def decompress(self, data: bytes) -> bytes: ... + if sys.version_info >= (3, 5): + def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... + else: + def decompress(self, data: bytes) -> bytes: ... + if sys.version_info >= (3, 3): + @property + def eof(self) -> bool: ... + if sys.version_info >= (3, 5): + @property + def needs_input(self) -> bool: ... @property def unused_data(self) -> bytes: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index cc26f9836cc1..638a2a79f2e5 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -26,4 +26,8 @@ class Profile: def run(self: _SelfT, cmd: str) -> _SelfT: ... def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... + if sys.version_info >= (3, 8): + def __enter__(self: _SelfT) -> _SelfT: ... + def __exit__(self, *exc_info: Any) -> None: ... + def label(code: Union[str, CodeType]) -> _Label: ... # undocumented diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index 752bd9a591cd..ad73132b4595 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -33,6 +33,10 @@ 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]]: ... + class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... def formatday(self, day: int, weekday: int, width: int) -> str: ... @@ -64,10 +68,26 @@ 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: Optional[str] = ..., encoding: Optional[str] = ...) -> str: ... -class TimeEncoding: - def __init__(self, locale: _LocaleType) -> None: ... - def __enter__(self) -> _LocaleType: ... - def __exit__(self, *args: Any) -> None: ... + 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 + +if sys.version_info >= (3, 0): + class different_locale: + def __init__(self, locale: _LocaleType) -> None: ... + def __enter__(self) -> _LocaleType: ... + def __exit__(self, *args: Any) -> None: ... + +else: + 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: Optional[_LocaleType] = ...) -> None: ... diff --git a/stdlib/@python2/cmath.pyi b/stdlib/@python2/cmath.pyi index 3c38ab9d04db..eaa62eafcb33 100644 --- a/stdlib/@python2/cmath.pyi +++ b/stdlib/@python2/cmath.pyi @@ -3,6 +3,13 @@ from typing import SupportsComplex, SupportsFloat, Tuple, Union e: float pi: float +if sys.version_info >= (3, 6): + inf: float + infj: complex + nan: float + nanj: complex + tau: float + _C = Union[SupportsFloat, SupportsComplex, complex] def acos(__z: _C) -> complex: ... @@ -15,6 +22,9 @@ def cos(__z: _C) -> complex: ... def cosh(__z: _C) -> complex: ... def exp(__z: _C) -> complex: ... +if sys.version_info >= (3, 5): + def isclose(a: _C, b: _C, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... + def isinf(__z: _C) -> bool: ... def isnan(__z: _C) -> bool: ... def log(__x: _C, __y_obj: _C = ...) -> complex: ... @@ -28,3 +38,5 @@ def sqrt(__z: _C) -> complex: ... def tan(__z: _C) -> complex: ... def tanh(__z: _C) -> complex: ... +if sys.version_info >= (3,): + def isfinite(__z: _C) -> bool: ... diff --git a/stdlib/@python2/code.pyi b/stdlib/@python2/code.pyi index aee7f518d655..16c2b129dd1e 100644 --- a/stdlib/@python2/code.pyi +++ b/stdlib/@python2/code.pyi @@ -12,13 +12,25 @@ class InteractiveInterpreter: class InteractiveConsole(InteractiveInterpreter): def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... - def interact(self, banner: Optional[str] = ...) -> None: ... + if sys.version_info >= (3, 6): + def interact(self, banner: Optional[str] = ..., exitmsg: Optional[str] = ...) -> None: ... + else: + def interact(self, banner: Optional[str] = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... def raw_input(self, prompt: str = ...) -> str: ... -def interact( - banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... -) -> None: ... +if sys.version_info >= (3, 6): + def interact( + banner: Optional[str] = ..., + readfunc: Optional[Callable[[str], str]] = ..., + local: Optional[Mapping[str, Any]] = ..., + exitmsg: Optional[str] = ..., + ) -> None: ... + +else: + def interact( + banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... + ) -> None: ... def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index 1132cdd18fb5..79be8e254c4c 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -234,7 +234,10 @@ class StreamReaderWriter(TextIO): def read(self, size: int = ...) -> _Decoded: ... def readline(self, size: Optional[int] = ...) -> _Decoded: ... def readlines(self, sizehint: Optional[int] = ...) -> List[_Decoded]: ... - def next(self) -> Text: ... + if sys.version_info >= (3,): + def __next__(self) -> Text: ... + else: + def next(self) -> Text: ... def __iter__(self: _T) -> _T: ... # This actually returns None, but that's incompatible with the supertype def write(self, data: _Decoded) -> int: ... @@ -274,7 +277,10 @@ class StreamRecoder(BinaryIO): def read(self, size: int = ...) -> bytes: ... def readline(self, size: Optional[int] = ...) -> bytes: ... def readlines(self, sizehint: Optional[int] = ...) -> List[bytes]: ... - def next(self) -> bytes: ... + if sys.version_info >= (3,): + def __next__(self) -> bytes: ... + else: + def next(self) -> bytes: ... def __iter__(self: _SRT) -> _SRT: ... def write(self, data: bytes) -> int: ... def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index c38d3eadb4d7..19ef45bed241 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -3,6 +3,14 @@ from types import TracebackType from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Type, TypeVar, overload from typing_extensions import Protocol +if sys.version_info >= (3, 5): + from typing import AsyncContextManager, AsyncIterator + +if sys.version_info >= (3, 6): + AbstractContextManager = ContextManager +if sys.version_info >= (3, 7): + AbstractAsyncContextManager = AsyncContextManager + _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=Optional[IO[str]]) @@ -11,11 +19,21 @@ _F = TypeVar("_F", bound=Callable[..., Any]) _ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) -class GeneratorContextManager(ContextManager[_T_co]): - def __call__(self, func: _F) -> _F: ... -def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +if sys.version_info >= (3, 2): + class _GeneratorContextManager(ContextManager[_T_co]): + def __call__(self, func: _F) -> _F: ... + def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]: ... + +else: + class GeneratorContextManager(ContextManager[_T_co]): + def __call__(self, func: _F) -> _F: ... + def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... -def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... +if sys.version_info >= (3, 7): + def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ... + +if sys.version_info < (3,): + def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... class _SupportsClose(Protocol): def close(self) -> None: ... @@ -25,3 +43,73 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) class closing(ContextManager[_SupportsCloseT]): def __init__(self, thing: _SupportsCloseT) -> None: ... +if sys.version_info >= (3, 10): + class _SupportsAclose(Protocol): + async def aclose(self) -> None: ... + _SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) + class aclosing(AsyncContextManager[_SupportsAcloseT]): + def __init__(self, thing: _SupportsAcloseT) -> None: ... + +if sys.version_info >= (3, 4): + class suppress(ContextManager[None]): + def __init__(self, *exceptions: Type[BaseException]) -> None: ... + def __exit__( + self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType] + ) -> bool: ... + class redirect_stdout(ContextManager[_T_io]): + def __init__(self, new_target: _T_io) -> None: ... + +if sys.version_info >= (3, 5): + class redirect_stderr(ContextManager[_T_io]): + def __init__(self, new_target: _T_io) -> None: ... + +if sys.version_info >= (3,): + class ContextDecorator: + def __call__(self, func: _F) -> _F: ... + _U = TypeVar("_U", bound=ExitStack) + class ExitStack(ContextManager[ExitStack]): + def __init__(self) -> None: ... + def enter_context(self, cm: ContextManager[_T]) -> _T: ... + def push(self, exit: _CM_EF) -> _CM_EF: ... + def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ... + def pop_all(self: _U) -> _U: ... + def close(self) -> None: ... + def __enter__(self: _U) -> _U: ... + def __exit__( + self, + __exc_type: Optional[Type[BaseException]], + __exc_value: Optional[BaseException], + __traceback: Optional[TracebackType], + ) -> bool: ... + +if sys.version_info >= (3, 7): + from typing import Awaitable + + _S = TypeVar("_S", bound=AsyncExitStack) + + _ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] + _CallbackCoroFunc = Callable[..., Awaitable[Any]] + _ACM_EF = TypeVar("_ACM_EF", AsyncContextManager[Any], _ExitCoroFunc) + class AsyncExitStack(AsyncContextManager[AsyncExitStack]): + def __init__(self) -> None: ... + def enter_context(self, cm: ContextManager[_T]) -> _T: ... + def enter_async_context(self, cm: AsyncContextManager[_T]) -> Awaitable[_T]: ... + def push(self, exit: _CM_EF) -> _CM_EF: ... + def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ... + def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ... + def push_async_callback(self, callback: _CallbackCoroFunc, *args: Any, **kwds: Any) -> _CallbackCoroFunc: ... + def pop_all(self: _S) -> _S: ... + def aclose(self) -> Awaitable[None]: ... + def __aenter__(self: _S) -> Awaitable[_S]: ... + def __aexit__( + self, + __exc_type: Optional[Type[BaseException]], + __exc_value: Optional[BaseException], + __traceback: Optional[TracebackType], + ) -> Awaitable[bool]: ... + +if sys.version_info >= (3, 7): + @overload + def nullcontext(enter_result: _T) -> ContextManager[_T]: ... + @overload + def nullcontext() -> ContextManager[None]: ... diff --git a/stdlib/@python2/crypt.pyi b/stdlib/@python2/crypt.pyi index bab839794f02..18893721a11f 100644 --- a/stdlib/@python2/crypt.pyi +++ b/stdlib/@python2/crypt.pyi @@ -1,4 +1,22 @@ import sys from typing import List, Optional, Union -def crypt(word: str, salt: str) -> str: ... +if sys.version_info >= (3, 3): + class _Method: ... + METHOD_CRYPT: _Method + METHOD_MD5: _Method + METHOD_SHA256: _Method + METHOD_SHA512: _Method + if sys.version_info >= (3, 7): + METHOD_BLOWFISH: _Method + + methods: List[_Method] + + if sys.version_info >= (3, 7): + def mksalt(method: Optional[_Method] = ..., *, rounds: Optional[int] = ...) -> str: ... + else: + def mksalt(method: Optional[_Method] = ...) -> str: ... + def crypt(word: str, salt: Optional[Union[str, _Method]] = ...) -> str: ... + +else: + def crypt(word: str, salt: str) -> str: ... diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index 11d78de1fc9c..db48e9e6c78a 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -19,7 +19,11 @@ from _csv import ( ) from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, TypeVar, overload -from typing import Dict as _DictReadMapping +if sys.version_info >= (3, 8) or sys.version_info < (3, 6): + from typing import Dict as _DictReadMapping +else: + from collections import OrderedDict as _DictReadMapping + _T = TypeVar("_T") class excel(Dialect): @@ -33,6 +37,15 @@ class excel(Dialect): class excel_tab(excel): delimiter: str +if sys.version_info >= (3,): + class unix_dialect(Dialect): + delimiter: str + quotechar: str + doublequote: bool + skipinitialspace: bool + lineterminator: str + quoting: int + class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): fieldnames: Optional[Sequence[_T]] restkey: Optional[str] @@ -63,7 +76,10 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): **kwds: Any, ) -> None: ... def __iter__(self) -> DictReader[_T]: ... - def next(self) -> _DictReadMapping[_T, str]: ... + if sys.version_info >= (3,): + def __next__(self) -> _DictReadMapping[_T, str]: ... + else: + def next(self) -> _DictReadMapping[_T, str]: ... class DictWriter(Generic[_T]): fieldnames: Sequence[_T] @@ -80,7 +96,10 @@ class DictWriter(Generic[_T]): *args: Any, **kwds: Any, ) -> None: ... - def writeheader(self) -> None: ... + if sys.version_info >= (3, 8): + def writeheader(self) -> Any: ... + else: + def writeheader(self) -> None: ... def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ... def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ... diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 64c447d893f6..299672ad0629 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -19,6 +19,9 @@ from typing import ( overload, ) +if sys.version_info >= (3, 9): + from types import GenericAlias + _T = TypeVar("_T") _DLLT = TypeVar("_DLLT", bound=CDLL) _CT = TypeVar("_CT", bound=_CData) @@ -33,14 +36,25 @@ class CDLL(object): _name: str = ... _handle: int = ... _FuncPtr: Type[_FuncPointer] = ... - def __init__( - self, - name: Optional[str], - mode: int = ..., - handle: Optional[int] = ..., - use_errno: bool = ..., - use_last_error: bool = ..., - ) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, + name: Optional[str], + mode: int = ..., + handle: Optional[int] = ..., + use_errno: bool = ..., + use_last_error: bool = ..., + winmode: Optional[int] = ..., + ) -> None: ... + else: + def __init__( + self, + name: Optional[str], + mode: int = ..., + handle: Optional[int] = ..., + use_errno: bool = ..., + use_last_error: bool = ..., + ) -> None: ... def __getattr__(self, name: str) -> _NamedFuncPointer: ... def __getitem__(self, name: str) -> _NamedFuncPointer: ... @@ -55,6 +69,9 @@ class LibraryLoader(Generic[_DLLT]): def __getattr__(self, name: str) -> _DLLT: ... def __getitem__(self, name: str) -> _DLLT: ... def LoadLibrary(self, name: str) -> _DLLT: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + cdll: LibraryLoader[CDLL] = ... if sys.platform == "win32": windll: LibraryLoader[WinDLL] = ... @@ -184,7 +201,8 @@ class pointer(Generic[_CT], _PointerLike, _CData): def resize(obj: _CData, size: int) -> None: ... -def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ... +if sys.version_info < (3,): + def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ... def set_errno(value: int) -> int: ... @@ -297,3 +315,5 @@ class Array(Generic[_CT], _CData): # Can't inherit from Sized because the metaclass conflict between # Sized and _CData prevents using _CDataMeta. def __len__(self) -> int: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index a8428613f775..4692f590b5b3 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -4,7 +4,10 @@ from typing import AnyStr, ClassVar, NamedTuple, Optional, SupportsAbs, Tuple, T _S = TypeVar("_S") -_Text = Union[str, unicode] +if sys.version_info >= (3,): + _Text = str +else: + _Text = Union[str, unicode] MINYEAR: int MAXYEAR: int @@ -15,6 +18,20 @@ class tzinfo: def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def fromutc(self, dt: datetime) -> datetime: ... +if sys.version_info >= (3, 2): + class timezone(tzinfo): + utc: ClassVar[timezone] + min: ClassVar[timezone] + max: ClassVar[timezone] + def __init__(self, offset: timedelta, name: str = ...) -> None: ... + def __hash__(self) -> int: ... + +if sys.version_info >= (3, 9): + class _IsoCalendarDate(NamedTuple): + year: int + week: int + weekday: int + _tzinfo = tzinfo class date: @@ -28,6 +45,12 @@ class date: def today(cls: Type[_S]) -> _S: ... @classmethod def fromordinal(cls: Type[_S], n: int) -> _S: ... + if sys.version_info >= (3, 7): + @classmethod + def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... + if sys.version_info >= (3, 8): + @classmethod + def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ... @property def year(self) -> int: ... @property @@ -36,7 +59,10 @@ class date: def day(self) -> int: ... def ctime(self) -> str: ... def strftime(self, fmt: _Text) -> str: ... - def __format__(self, fmt: AnyStr) -> AnyStr: ... + if sys.version_info >= (3,): + def __format__(self, fmt: str) -> str: ... + else: + def __format__(self, fmt: AnyStr) -> AnyStr: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... def toordinal(self) -> int: ... @@ -45,8 +71,12 @@ class date: 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: ... + if sys.version_info >= (3, 8): + def __add__(self: _S, other: timedelta) -> _S: ... + def __radd__(self: _S, other: timedelta) -> _S: ... + else: + def __add__(self, other: timedelta) -> date: ... + def __radd__(self, other: timedelta) -> date: ... @overload def __sub__(self, other: timedelta) -> date: ... @overload @@ -54,16 +84,31 @@ class date: def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... - def isocalendar(self) -> Tuple[int, int, int]: ... + if sys.version_info >= (3, 9): + def isocalendar(self) -> _IsoCalendarDate: ... + else: + def isocalendar(self) -> Tuple[int, int, int]: ... class time: min: ClassVar[time] max: ClassVar[time] resolution: ClassVar[timedelta] - def __init__( - self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... - ) -> None: ... + if sys.version_info >= (3, 6): + def __init__( + self, + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + *, + fold: int = ..., + ) -> None: ... + else: + def __init__( + self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... + ) -> None: ... @property def hour(self) -> int: ... @property @@ -74,20 +119,44 @@ class time: def microsecond(self) -> int: ... @property def tzinfo(self) -> Optional[_tzinfo]: ... + if sys.version_info >= (3, 6): + @property + def fold(self) -> int: ... 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: ... + if sys.version_info >= (3, 6): + def isoformat(self, timespec: str = ...) -> str: ... + else: + def isoformat(self) -> str: ... + if sys.version_info >= (3, 7): + @classmethod + def fromisoformat(cls: Type[_S], time_string: str) -> _S: ... def strftime(self, fmt: _Text) -> str: ... - def __format__(self, fmt: AnyStr) -> AnyStr: ... + if sys.version_info >= (3,): + def __format__(self, fmt: str) -> str: ... + else: + def __format__(self, fmt: AnyStr) -> AnyStr: ... def utcoffset(self) -> Optional[timedelta]: ... def tzname(self) -> Optional[str]: ... def dst(self) -> Optional[timedelta]: ... - def replace( - self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... - ) -> time: ... + if sys.version_info >= (3, 6): + def replace( + self, + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + *, + fold: int = ..., + ) -> time: ... + else: + def replace( + self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... + ) -> time: ... _date = date _time = time @@ -97,16 +166,30 @@ class timedelta(SupportsAbs[timedelta]): max: ClassVar[timedelta] resolution: ClassVar[timedelta] - def __init__( - self, - days: float = ..., - seconds: float = ..., - microseconds: float = ..., - milliseconds: float = ..., - minutes: float = ..., - hours: float = ..., - weeks: float = ..., - ) -> None: ... + if sys.version_info >= (3, 6): + def __init__( + self, + days: float = ..., + seconds: float = ..., + microseconds: float = ..., + milliseconds: float = ..., + minutes: float = ..., + hours: float = ..., + weeks: float = ..., + *, + fold: int = ..., + ) -> None: ... + else: + def __init__( + self, + days: float = ..., + seconds: float = ..., + microseconds: float = ..., + milliseconds: float = ..., + minutes: float = ..., + hours: float = ..., + weeks: float = ..., + ) -> None: ... @property def days(self) -> int: ... @property @@ -127,10 +210,18 @@ class timedelta(SupportsAbs[timedelta]): 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: ... + if sys.version_info >= (3,): + @overload + def __truediv__(self, other: timedelta) -> float: ... + @overload + def __truediv__(self, other: float) -> timedelta: ... + def __mod__(self, other: timedelta) -> timedelta: ... + def __divmod__(self, other: timedelta) -> Tuple[int, timedelta]: ... + else: + @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: ... @@ -142,17 +233,32 @@ class datetime(date): max: ClassVar[datetime] resolution: ClassVar[timedelta] - def __new__( - cls: Type[_S], - year: int, - month: int, - day: int, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - ) -> _S: ... + if sys.version_info >= (3, 6): + def __new__( + cls: Type[_S], + year: int, + month: int, + day: int, + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + *, + fold: int = ..., + ) -> _S: ... + else: + def __new__( + cls: Type[_S], + year: int, + month: int, + day: int, + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + ) -> _S: ... @property def year(self) -> int: ... @property @@ -169,6 +275,9 @@ class datetime(date): def microsecond(self) -> int: ... @property def tzinfo(self) -> Optional[_tzinfo]: ... + if sys.version_info >= (3, 6): + @property + def fold(self) -> int: ... @classmethod def fromtimestamp(cls: Type[_S], t: float, tz: Optional[_tzinfo] = ...) -> _S: ... @classmethod @@ -177,41 +286,77 @@ class datetime(date): def today(cls: Type[_S]) -> _S: ... @classmethod def fromordinal(cls: Type[_S], n: int) -> _S: ... - @overload - @classmethod - def now(cls: Type[_S], tz: None = ...) -> _S: ... - @overload - @classmethod - def now(cls, tz: _tzinfo) -> datetime: ... + if sys.version_info >= (3, 8): + @classmethod + def now(cls: Type[_S], tz: Optional[_tzinfo] = ...) -> _S: ... + else: + @overload + @classmethod + def now(cls: Type[_S], tz: None = ...) -> _S: ... + @overload + @classmethod + def now(cls, tz: _tzinfo) -> datetime: ... @classmethod def utcnow(cls: Type[_S]) -> _S: ... - @classmethod - def combine(cls, date: _date, time: _time) -> datetime: ... + if sys.version_info >= (3, 6): + @classmethod + def combine(cls, date: _date, time: _time, tzinfo: Optional[_tzinfo] = ...) -> datetime: ... + else: + @classmethod + def combine(cls, date: _date, time: _time) -> datetime: ... + if sys.version_info >= (3, 7): + @classmethod + def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... def strftime(self, fmt: _Text) -> str: ... - def __format__(self, fmt: AnyStr) -> AnyStr: ... + if sys.version_info >= (3,): + def __format__(self, fmt: str) -> str: ... + else: + def __format__(self, fmt: AnyStr) -> AnyStr: ... def toordinal(self) -> int: ... def timetuple(self) -> struct_time: ... + if sys.version_info >= (3, 3): + def timestamp(self) -> float: ... 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: Optional[_tzinfo] = ..., - ) -> datetime: ... + if sys.version_info >= (3, 6): + def replace( + self, + year: int = ..., + month: int = ..., + day: int = ..., + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + *, + fold: int = ..., + ) -> datetime: ... + else: + def replace( + self, + year: int = ..., + month: int = ..., + day: int = ..., + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + ) -> datetime: ... + if sys.version_info >= (3, 8): + def astimezone(self: _S, tz: Optional[_tzinfo] = ...) -> _S: ... elif sys.version_info >= (3, 3): def astimezone(self, tz: Optional[_tzinfo] = ...) -> datetime: ... else: def astimezone(self, tz: _tzinfo) -> datetime: ... def ctime(self) -> str: ... - def isoformat(self, sep: str = ...) -> str: ... + if sys.version_info >= (3, 6): + def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... + else: + def isoformat(self, sep: str = ...) -> str: ... @classmethod def strptime(cls, date_string: _Text, format: _Text) -> datetime: ... def utcoffset(self) -> Optional[timedelta]: ... @@ -221,8 +366,12 @@ class datetime(date): def __lt__(self, other: datetime) -> bool: ... # type: ignore def __ge__(self, other: datetime) -> bool: ... # type: ignore def __gt__(self, other: datetime) -> bool: ... # type: ignore - def __add__(self, other: timedelta) -> datetime: ... - def __radd__(self, other: timedelta) -> datetime: ... + if sys.version_info >= (3, 8): + def __add__(self: _S, other: timedelta) -> _S: ... + def __radd__(self: _S, other: timedelta) -> _S: ... + else: + def __add__(self, other: timedelta) -> datetime: ... + def __radd__(self, other: timedelta) -> datetime: ... @overload # type: ignore def __sub__(self, other: datetime) -> timedelta: ... @overload @@ -230,4 +379,7 @@ class datetime(date): def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... - def isocalendar(self) -> Tuple[int, int, int]: ... + if sys.version_info >= (3, 9): + def isocalendar(self) -> _IsoCalendarDate: ... + else: + def isocalendar(self) -> Tuple[int, int, int]: ... diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index ef5744a49cba..c3a671d4ba5f 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -5,7 +5,10 @@ from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, T _Decimal = Union[Decimal, int] _DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] -_ComparableNum = Union[Decimal, float] +if sys.version_info >= (3,): + _ComparableNum = Union[Decimal, float, numbers.Rational] +else: + _ComparableNum = Union[Decimal, float] _DecimalT = TypeVar("_DecimalT", bound=Decimal) class DecimalTuple(NamedTuple): @@ -22,8 +25,16 @@ ROUND_UP: str ROUND_HALF_DOWN: str ROUND_05UP: str +if sys.version_info >= (3,): + HAVE_THREADS: bool + MAX_EMAX: int + MAX_PREC: int + MIN_EMIN: int + MIN_ETINY: int + class DecimalException(ArithmeticError): - def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... + if sys.version_info < (3,): + def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... class Clamped(DecimalException): ... class InvalidOperation(DecimalException): ... @@ -38,6 +49,9 @@ class Subnormal(DecimalException): ... class Overflow(Inexact, Rounded): ... class Underflow(Inexact, Rounded, Subnormal): ... +if sys.version_info >= (3,): + class FloatOperation(DecimalException, TypeError): ... + def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... @@ -46,38 +60,69 @@ class Decimal(object): def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... @classmethod def from_float(cls, __f: float) -> Decimal: ... - def __nonzero__(self) -> bool: ... - def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... + if sys.version_info >= (3,): + def __bool__(self) -> bool: ... + else: + def __nonzero__(self) -> bool: ... + def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... + if sys.version_info >= (3, 6): + def as_integer_ratio(self) -> Tuple[int, int]: ... def to_eng_string(self, context: Optional[Context] = ...) -> str: ... - def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... - def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... - def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... - def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... - def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + if sys.version_info >= (3,): + def __abs__(self) -> Decimal: ... + def __add__(self, other: _Decimal) -> Decimal: ... + def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... + def __eq__(self, other: object) -> bool: ... + def __floordiv__(self, other: _Decimal) -> Decimal: ... + def __ge__(self, other: _ComparableNum) -> bool: ... + def __gt__(self, other: _ComparableNum) -> bool: ... + def __le__(self, other: _ComparableNum) -> bool: ... + def __lt__(self, other: _ComparableNum) -> bool: ... + def __mod__(self, other: _Decimal) -> Decimal: ... + def __mul__(self, other: _Decimal) -> Decimal: ... + def __neg__(self) -> Decimal: ... + def __pos__(self) -> Decimal: ... + def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ... + def __radd__(self, other: _Decimal) -> Decimal: ... + def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... + def __rfloordiv__(self, other: _Decimal) -> Decimal: ... + def __rmod__(self, other: _Decimal) -> Decimal: ... + def __rmul__(self, other: _Decimal) -> Decimal: ... + def __rsub__(self, other: _Decimal) -> Decimal: ... + def __rtruediv__(self, other: _Decimal) -> Decimal: ... + def __str__(self) -> str: ... + def __sub__(self, other: _Decimal) -> Decimal: ... + def __truediv__(self, other: _Decimal) -> Decimal: ... + else: + def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... + def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... + def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... + def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... + def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... + def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... + def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... + def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... + def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __float__(self) -> float: ... def __int__(self) -> int: ... @@ -88,14 +133,26 @@ class Decimal(object): def imag(self) -> Decimal: ... def conjugate(self) -> Decimal: ... def __complex__(self) -> complex: ... - def __long__(self) -> long: ... + if sys.version_info >= (3,): + @overload + def __round__(self) -> int: ... + @overload + def __round__(self, ndigits: int) -> Decimal: ... + def __floor__(self) -> int: ... + def __ceil__(self) -> int: ... + else: + def __long__(self) -> long: ... def fma(self, other: _Decimal, third: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __rpow__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def normalize(self, context: Optional[Context] = ...) -> Decimal: ... - def quantize( - self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ... - ) -> Decimal: ... - def same_quantum(self, other: _Decimal) -> bool: ... + if sys.version_info >= (3,): + def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... + def same_quantum(self, other: _Decimal, context: Optional[Context] = ...) -> bool: ... + else: + def quantize( + self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ... + ) -> Decimal: ... + def same_quantum(self, other: _Decimal) -> bool: ... def to_integral_exact(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... def to_integral_value(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... def to_integral(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... @@ -103,13 +160,23 @@ class Decimal(object): def max(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def min(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def adjusted(self) -> int: ... - def canonical(self, context: Optional[Context] = ...) -> Decimal: ... + if sys.version_info >= (3,): + def canonical(self) -> Decimal: ... + else: + def canonical(self, context: Optional[Context] = ...) -> Decimal: ... def compare_signal(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def compare_total(self, other: _Decimal) -> Decimal: ... - def compare_total_mag(self, other: _Decimal) -> Decimal: ... + if sys.version_info >= (3,): + def compare_total(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def compare_total_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + else: + 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: ... + if sys.version_info >= (3,): + def copy_sign(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + else: + def copy_sign(self, other: _Decimal) -> Decimal: ... def exp(self, context: Optional[Context] = ...) -> Decimal: ... def is_canonical(self) -> bool: ... def is_finite(self) -> bool: ... @@ -158,22 +225,46 @@ class Context(object): Emin: int Emax: int capitals: int - _clamp: int + if sys.version_info >= (3,): + clamp: int + else: + _clamp: int traps: Dict[_TrapType, bool] flags: Dict[_TrapType, bool] - def __init__( - self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - _clamp: Optional[int] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., - ) -> None: ... + if sys.version_info >= (3,): + def __init__( + self, + prec: Optional[int] = ..., + rounding: Optional[str] = ..., + Emin: Optional[int] = ..., + Emax: Optional[int] = ..., + capitals: Optional[int] = ..., + clamp: Optional[int] = ..., + flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + _ignored_flags: Optional[List[_TrapType]] = ..., + ) -> None: ... + else: + def __init__( + self, + prec: Optional[int] = ..., + rounding: Optional[str] = ..., + traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + Emin: Optional[int] = ..., + Emax: Optional[int] = ..., + capitals: Optional[int] = ..., + _clamp: Optional[int] = ..., + _ignored_flags: Optional[List[_TrapType]] = ..., + ) -> None: ... + if sys.version_info >= (3,): + # __setattr__() only allows to set a specific set of attributes, + # already defined above. + def __delattr__(self, name: str) -> None: ... + def __reduce__(self) -> Tuple[Type[Context], Tuple[Any, ...]]: ... def clear_flags(self) -> None: ... + if sys.version_info >= (3,): + def clear_traps(self) -> None: ... def copy(self) -> Context: ... def __copy__(self) -> Context: ... __hash__: Any = ... diff --git a/stdlib/@python2/difflib.pyi b/stdlib/@python2/difflib.pyi index d615f3c873da..572972ccda9e 100644 --- a/stdlib/@python2/difflib.pyi +++ b/stdlib/@python2/difflib.pyi @@ -17,10 +17,16 @@ from typing import ( overload, ) +if sys.version_info >= (3, 9): + from types import GenericAlias + _T = TypeVar("_T") -# Aliases can't point to type vars, so we need to redeclare AnyStr -_StrType = TypeVar("_StrType", Text, bytes) +if sys.version_info >= (3,): + _StrType = Text +else: + # Aliases can't point to type vars, so we need to redeclare AnyStr + _StrType = TypeVar("_StrType", Text, bytes) _JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]] @@ -36,13 +42,21 @@ class SequenceMatcher(Generic[_T]): 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: ... + if sys.version_info >= (3, 9): + def find_longest_match( + self, alo: int = ..., ahi: Optional[int] = ..., blo: int = ..., bhi: Optional[int] = ... + ) -> Match: ... + else: + 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: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + # mypy thinks the signatures of the overloads overlap, but the types still work fine @overload def get_close_matches( # type: ignore @@ -91,15 +105,28 @@ class HtmlDiff(object): linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ..., ) -> None: ... - def make_file( - self, - fromlines: Sequence[_StrType], - tolines: Sequence[_StrType], - fromdesc: _StrType = ..., - todesc: _StrType = ..., - context: bool = ..., - numlines: int = ..., - ) -> _StrType: ... + if sys.version_info >= (3, 5): + def make_file( + self, + fromlines: Sequence[_StrType], + tolines: Sequence[_StrType], + fromdesc: _StrType = ..., + todesc: _StrType = ..., + context: bool = ..., + numlines: int = ..., + *, + charset: str = ..., + ) -> _StrType: ... + else: + 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], @@ -112,3 +139,15 @@ class HtmlDiff(object): def restore(delta: Iterable[_StrType], which: int) -> Iterator[_StrType]: ... +if sys.version_info >= (3, 5): + def diff_bytes( + dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]], + a: Sequence[bytes], + b: Sequence[bytes], + fromfile: bytes = ..., + tofile: bytes = ..., + fromfiledate: bytes = ..., + tofiledate: bytes = ..., + n: int = ..., + lineterm: bytes = ..., + ) -> Iterator[bytes]: ... diff --git a/stdlib/@python2/dis.pyi b/stdlib/@python2/dis.pyi index b5c0b4d7c1e1..b52d0ed624f6 100644 --- a/stdlib/@python2/dis.pyi +++ b/stdlib/@python2/dis.pyi @@ -16,24 +16,68 @@ from opcode import ( ) from typing import IO, Any, Callable, Dict, Iterator, List, NamedTuple, Optional, Tuple, Union +if sys.version_info >= (3, 4): + from opcode import stack_effect as stack_effect + +if sys.version_info >= (3, 6): + from opcode import hasnargs as hasnargs + # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) _have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type, Callable[..., Any]] _have_code_or_string = Union[_have_code, str, bytes] +if sys.version_info >= (3, 4): + class Instruction(NamedTuple): + opname: str + opcode: int + arg: Optional[int] + argval: Any + argrepr: str + offset: int + starts_line: Optional[int] + is_jump_target: bool + class Bytecode: + codeobj: types.CodeType + first_line: int + def __init__( + self, x: _have_code_or_string, *, first_line: Optional[int] = ..., current_offset: Optional[int] = ... + ) -> None: ... + def __iter__(self) -> Iterator[Instruction]: ... + def __repr__(self) -> str: ... + def info(self) -> str: ... + def dis(self) -> str: ... + @classmethod + def from_traceback(cls, tb: types.TracebackType) -> Bytecode: ... + COMPILER_FLAG_NAMES: Dict[int, str] def findlabels(code: _have_code) -> List[int]: ... def findlinestarts(code: _have_code) -> Iterator[Tuple[int, int]]: ... +if sys.version_info >= (3, 0): + def pretty_flags(flags: int) -> str: ... + def code_info(x: _have_code_or_string) -> str: ... + +if sys.version_info >= (3, 7): + def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ..., depth: Optional[int] = ...) -> None: ... + elif sys.version_info >= (3, 4): def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ...) -> None: ... else: 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: ... -if sys.version_info >= (3, 0): - def show_code(co: _have_code) -> None: ... +if sys.version_info >= (3, 4): + def distb(tb: Optional[types.TracebackType] = ..., *, file: Optional[IO[str]] = ...) -> None: ... + def disassemble(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... + def disco(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... + def show_code(co: _have_code, *, file: Optional[IO[str]] = ...) -> None: ... + def get_instructions(x: _have_code, *, first_line: Optional[int] = ...) -> Iterator[Instruction]: ... + +else: + def distb(tb: types.TracebackType = ...) -> None: ... + def disassemble(co: _have_code, lasti: int = ...) -> None: ... + def disco(co: _have_code, lasti: int = ...) -> None: ... + if sys.version_info >= (3, 0): + def show_code(co: _have_code) -> None: ... diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index 5e10f2c5ecea..ae84c2c25efc 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -24,6 +24,9 @@ REPORT_UDIFF: int REPORT_CDIFF: int REPORT_NDIFF: int REPORT_ONLY_FIRST_FAILURE: int +if sys.version_info >= (3, 4): + FAIL_FAST: int + REPORTING_FLAGS: int BLANKLINE_MARKER: str @@ -186,7 +189,11 @@ class SkipDocTestCase(DocTestCase): def test_skip(self) -> None: ... def shortDescription(self) -> str: ... -_DocTestSuite = unittest.TestSuite +if sys.version_info >= (3, 4): + class _DocTestSuite(unittest.TestSuite): ... + +else: + _DocTestSuite = unittest.TestSuite def DocTestSuite( module: Union[None, str, types.ModuleType] = ..., diff --git a/stdlib/@python2/ensurepip/__init__.pyi b/stdlib/@python2/ensurepip/__init__.pyi index 83fd43ff002e..a411dbb456d2 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -3,11 +3,23 @@ from typing import Optional def version() -> str: ... -def bootstrap( - root: Optional[str] = ..., - upgrade: bool = ..., - user: bool = ..., - altinstall: bool = ..., - default_pip: bool = ..., - verbosity: int = ..., -) -> None: ... +if sys.version_info >= (3, 0): + def bootstrap( + *, + root: Optional[str] = ..., + upgrade: bool = ..., + user: bool = ..., + altinstall: bool = ..., + default_pip: bool = ..., + verbosity: int = ..., + ) -> None: ... + +else: + def bootstrap( + root: Optional[str] = ..., + upgrade: bool = ..., + user: bool = ..., + altinstall: bool = ..., + default_pip: bool = ..., + verbosity: int = ..., + ) -> None: ... diff --git a/stdlib/@python2/filecmp.pyi b/stdlib/@python2/filecmp.pyi index 5767ada0bd08..b05eebac07c9 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -1,17 +1,44 @@ import sys from typing import Any, AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Text, Tuple, Union +if sys.version_info >= (3, 6): + from os import PathLike + +if sys.version_info >= (3, 9): + from types import GenericAlias + DEFAULT_IGNORES: List[str] -def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ... -def cmpfiles( - a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: Union[int, bool] = ... -) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... +if sys.version_info >= (3, 6): + def cmp( + f1: Union[bytes, Text, PathLike[AnyStr]], f2: Union[bytes, Text, PathLike[AnyStr]], shallow: Union[int, bool] = ... + ) -> bool: ... + def cmpfiles( + a: Union[AnyStr, PathLike[AnyStr]], + b: Union[AnyStr, PathLike[AnyStr]], + common: Iterable[AnyStr], + shallow: Union[int, bool] = ..., + ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... + +else: + def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ... + def cmpfiles( + a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: Union[int, bool] = ... + ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... class dircmp(Generic[AnyStr]): - def __init__( - self, a: AnyStr, b: AnyStr, ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ... - ) -> None: ... + if sys.version_info >= (3, 6): + def __init__( + self, + a: Union[AnyStr, PathLike[AnyStr]], + b: Union[AnyStr, PathLike[AnyStr]], + ignore: Optional[Sequence[AnyStr]] = ..., + hide: Optional[Sequence[AnyStr]] = ..., + ) -> None: ... + else: + def __init__( + self, a: AnyStr, b: AnyStr, ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ... + ) -> None: ... left: AnyStr right: AnyStr hide: Sequence[AnyStr] @@ -39,3 +66,8 @@ class dircmp(Generic[AnyStr]): def phase3(self) -> None: ... def phase4(self) -> None: ... def phase4_closure(self) -> None: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + +if sys.version_info >= (3,): + def clear_cache() -> None: ... diff --git a/stdlib/@python2/fileinput.pyi b/stdlib/@python2/fileinput.pyi index bd6050523553..fbb602b3bf45 100644 --- a/stdlib/@python2/fileinput.pyi +++ b/stdlib/@python2/fileinput.pyi @@ -2,14 +2,25 @@ import sys from _typeshed import AnyPath from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Optional, Union -def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., -) -> FileInput[AnyStr]: ... +if sys.version_info >= (3, 8): + def input( + files: Union[AnyPath, Iterable[AnyPath], None] = ..., + inplace: bool = ..., + backup: str = ..., + *, + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + ) -> FileInput[AnyStr]: ... + +else: + def input( + files: Union[AnyPath, Iterable[AnyPath], None] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + ) -> FileInput[AnyStr]: ... def close() -> None: ... def nextfile() -> None: ... @@ -21,17 +32,31 @@ def isfirstline() -> bool: ... def isstdin() -> bool: ... class FileInput(Iterable[AnyStr], Generic[AnyStr]): - def __init__( - self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, + files: Union[None, AnyPath, Iterable[AnyPath]] = ..., + inplace: bool = ..., + backup: str = ..., + *, + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + ) -> None: ... + else: + def __init__( + self, + files: Union[None, AnyPath, Iterable[AnyPath]] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... + if sys.version_info >= (3, 2): + def __enter__(self) -> FileInput[AnyStr]: ... + def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... def __iter__(self) -> Iterator[AnyStr]: ... def __next__(self) -> AnyStr: ... def __getitem__(self, i: int) -> AnyStr: ... @@ -46,4 +71,8 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): def hook_compressed(filename: AnyPath, mode: str) -> IO[Any]: ... -def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... +if sys.version_info >= (3, 6): + def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[AnyPath, str], IO[Any]]: ... + +else: + def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index a51fcda41e3e..75cfa48a1cf6 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -7,14 +7,15 @@ from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] _T = TypeVar("_T") -@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: ... +if sys.version_info < (3, 9): + @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 @@ -32,6 +33,8 @@ class Fraction(Rational): @classmethod def from_decimal(cls, dec: Decimal) -> Fraction: ... def limit_denominator(self, max_denominator: int = ...) -> Fraction: ... + if sys.version_info >= (3, 8): + def as_integer_ratio(self) -> Tuple[int, int]: ... @property def numerator(self) -> int: ... @property @@ -84,18 +87,19 @@ class Fraction(Rational): def __rtruediv__(self, other: float) -> float: ... @overload def __rtruediv__(self, other: complex) -> complex: ... - @overload - def __div__(self, other: Union[int, Fraction]) -> Fraction: ... - @overload - def __div__(self, other: float) -> float: ... - @overload - def __div__(self, other: complex) -> complex: ... - @overload - def __rdiv__(self, other: Union[int, Fraction]) -> Fraction: ... - @overload - def __rdiv__(self, other: float) -> float: ... - @overload - def __rdiv__(self, other: complex) -> complex: ... + if sys.version_info < (3, 0): + @overload + def __div__(self, other: Union[int, Fraction]) -> Fraction: ... + @overload + def __div__(self, other: float) -> float: ... + @overload + def __div__(self, other: complex) -> complex: ... + @overload + def __rdiv__(self, other: Union[int, Fraction]) -> Fraction: ... + @overload + def __rdiv__(self, other: float) -> float: ... + @overload + def __rdiv__(self, other: complex) -> complex: ... @overload def __floordiv__(self, other: Union[int, Fraction]) -> int: ... @overload @@ -134,13 +138,23 @@ class Fraction(Rational): def __neg__(self) -> Fraction: ... def __abs__(self) -> Fraction: ... def __trunc__(self) -> int: ... + if sys.version_info >= (3, 0): + def __floor__(self) -> int: ... + def __ceil__(self) -> int: ... + @overload + def __round__(self, ndigits: None = ...) -> int: ... + @overload + def __round__(self, ndigits: int) -> Fraction: ... 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: ... + if sys.version_info >= (3, 0): + def __bool__(self) -> bool: ... + else: + def __nonzero__(self) -> bool: ... # Not actually defined within fractions.py, but provides more useful # overrides @property diff --git a/stdlib/@python2/ftplib.pyi b/stdlib/@python2/ftplib.pyi index 7658630f2b58..bdb1716549c0 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -13,6 +13,9 @@ MSG_OOB: int FTP_PORT: int MAXLINE: int CRLF: str +if sys.version_info >= (3,): + B_CRLF: bytes + class Error(Exception): ... class error_reply(Error): ... class error_temp(Error): ... @@ -37,12 +40,35 @@ class FTP: af: int lastresp: str - file: Optional[BinaryIO] + if sys.version_info >= (3,): + file: Optional[TextIO] + encoding: str + def __enter__(self: _T) -> _T: ... + def __exit__( + self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + ) -> None: ... + else: + file: Optional[BinaryIO] - def __init__( - self, host: Text = ..., user: Text = ..., passwd: Text = ..., acct: Text = ..., timeout: float = ... - ) -> None: ... - def connect(self, host: Text = ..., port: int = ..., timeout: float = ...) -> str: ... + if sys.version_info >= (3, 3): + source_address: Optional[Tuple[str, int]] + def __init__( + self, + host: Text = ..., + user: Text = ..., + passwd: Text = ..., + acct: Text = ..., + timeout: float = ..., + source_address: Optional[Tuple[str, int]] = ..., + ) -> None: ... + def connect( + self, host: Text = ..., port: int = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ... + ) -> str: ... + else: + 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: ... @@ -82,6 +108,8 @@ class FTP: def nlst(self, *args: Text) -> List[str]: ... # Technically only the last arg can be a Callable but ... def dir(self, *args: Union[str, Callable[[str], None]]) -> None: ... + if sys.version_info >= (3, 3): + def mlsd(self, path: Text = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, Dict[str, str]]]: ... def rename(self, fromname: Text, toname: Text) -> str: ... def delete(self, filename: Text) -> str: ... def cwd(self, dirname: Text) -> str: ... @@ -113,12 +141,16 @@ class FTP_TLS(FTP): def auth(self) -> str: ... def prot_p(self) -> str: ... def prot_c(self) -> str: ... -class Netrc: - def __init__(self, filename: Optional[Text] = ...) -> None: ... - def get_hosts(self) -> List[str]: ... - def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ... - def get_macros(self) -> List[str]: ... - def get_macro(self, macro: Text) -> Tuple[str, ...]: ... + if sys.version_info >= (3, 3): + def ccc(self) -> str: ... + +if sys.version_info < (3,): + class Netrc: + def __init__(self, filename: Optional[Text] = ...) -> None: ... + def get_hosts(self) -> List[str]: ... + def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ... + def get_macros(self) -> List[str]: ... + def get_macro(self, macro: Text) -> Tuple[str, ...]: ... def parse150(resp: str) -> Optional[int]: ... # undocumented def parse227(resp: str) -> Tuple[str, int]: ... # undocumented diff --git a/stdlib/@python2/genericpath.pyi b/stdlib/@python2/genericpath.pyi index 04b9884998e4..17a0df575c56 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -26,3 +26,7 @@ def getatime(filename: AnyPath) -> float: ... def getmtime(filename: AnyPath) -> float: ... def getctime(filename: AnyPath) -> float: ... +if sys.version_info >= (3, 4): + def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... + def sameopenfile(fp1: int, fp2: int) -> bool: ... + def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/@python2/hmac.pyi b/stdlib/@python2/hmac.pyi index e300307c664d..ca4013da7879 100644 --- a/stdlib/@python2/hmac.pyi +++ b/stdlib/@python2/hmac.pyi @@ -9,6 +9,14 @@ _DigestMod = Union[str, Callable[[], _Hash], ModuleType] digest_size: None +if sys.version_info >= (3, 8): + # In reality digestmod has a default value, but the function always throws an error + # if the argument is not given, so we pretend it is a required argument. + @overload + def new(key: bytes, msg: Optional[ReadableBuffer], digestmod: _DigestMod) -> HMAC: ... + @overload + def new(key: bytes, *, digestmod: _DigestMod) -> HMAC: ... + elif sys.version_info >= (3, 4): def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... @@ -16,6 +24,11 @@ else: def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... class HMAC: + if sys.version_info >= (3,): + digest_size: int + if sys.version_info >= (3, 4): + block_size: int + name: str def __init__(self, key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: _DigestMod = ...) -> None: ... def update(self, msg: ReadableBuffer) -> None: ... def digest(self) -> bytes: ... @@ -27,3 +40,5 @@ 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: str) -> bytes: ... diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index 2b60cba7b2a6..bb9e9c6db132 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -31,8 +31,12 @@ class IMAP4: welcome: bytes = ... capabilities: Tuple[str] = ... PROTOCOL_VERSION: str = ... - def __init__(self, host: str = ..., port: int = ...) -> None: ... - def open(self, host: str = ..., port: int = ...) -> None: ... + if sys.version_info >= (3, 9): + def __init__(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... + def open(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... + else: + 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 = ... @@ -54,6 +58,10 @@ class IMAP4: def create(self, mailbox: str) -> _CommandResults: ... def delete(self, mailbox: str) -> _CommandResults: ... def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... + if sys.version_info >= (3, 5): + def enable(self, capability: str) -> _CommandResults: ... + def __enter__(self) -> IMAP4: ... + def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... @@ -77,18 +85,32 @@ class IMAP4: 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: ... + if sys.version_info >= (3,): + def starttls(self, ssl_context: Optional[Any] = ...) -> Tuple[Literal["OK"], List[None]]: ... 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: ... + if sys.version_info >= (3, 9): + def unselect(self) -> _CommandResults: ... def xatom(self, name: str, *args: str) -> _CommandResults: ... def print_log(self) -> None: ... class IMAP4_SSL(IMAP4): keyfile: str = ... certfile: str = ... + if sys.version_info >= (3, 9): + def __init__( + self, + host: str = ..., + port: int = ..., + keyfile: Optional[str] = ..., + certfile: Optional[str] = ..., + ssl_context: Optional[SSLContext] = ..., + timeout: Optional[float] = ..., + ) -> None: ... elif sys.version_info >= (3, 3): def __init__( self, @@ -107,7 +129,10 @@ class IMAP4_SSL(IMAP4): sock: _socket = ... sslobj: SSLSocket = ... file: IO[Any] = ... - def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... + if sys.version_info >= (3, 9): + def open(self, host: str = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... + else: + def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... @@ -125,7 +150,10 @@ class IMAP4_stream(IMAP4): process: subprocess.Popen[bytes] = ... writefile: IO[Any] = ... readfile: IO[Any] = ... - def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ... + if sys.version_info >= (3, 9): + def open(self, host: Optional[str] = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... + else: + def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... diff --git a/stdlib/@python2/imghdr.pyi b/stdlib/@python2/imghdr.pyi index 77b1fc75e583..ffdbbf20e97b 100644 --- a/stdlib/@python2/imghdr.pyi +++ b/stdlib/@python2/imghdr.pyi @@ -7,7 +7,10 @@ class _ReadableBinary(Protocol): def read(self, size: int) -> bytes: ... def seek(self, offset: int) -> Any: ... -_File = Union[Text, _ReadableBinary] +if sys.version_info >= (3, 6): + _File = Union[Text, os.PathLike[Text], _ReadableBinary] +else: + _File = Union[Text, _ReadableBinary] @overload def what(file: _File, h: None = ...) -> Optional[str]: ... diff --git a/stdlib/@python2/ipaddress.pyi b/stdlib/@python2/ipaddress.pyi index a742ac76be7d..b4e2b2c4b3f9 100644 --- a/stdlib/@python2/ipaddress.pyi +++ b/stdlib/@python2/ipaddress.pyi @@ -87,6 +87,9 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): def overlaps(self, other: _BaseNetwork[_A]) -> bool: ... @property def prefixlen(self) -> int: ... + if sys.version_info >= (3, 7): + def subnet_of(self: _T, other: _T) -> bool: ... + def supernet_of(self: _T, other: _T) -> bool: ... def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ... def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ... @property diff --git a/stdlib/@python2/keyword.pyi b/stdlib/@python2/keyword.pyi index fb113141222e..3e095ed5f94c 100644 --- a/stdlib/@python2/keyword.pyi +++ b/stdlib/@python2/keyword.pyi @@ -5,3 +5,6 @@ def iskeyword(s: Text) -> bool: ... kwlist: Sequence[str] +if sys.version_info >= (3, 9): + def issoftkeyword(s: str) -> bool: ... + softkwlist: Sequence[str] diff --git a/stdlib/@python2/lib2to3/pgen2/token.pyi b/stdlib/@python2/lib2to3/pgen2/token.pyi index a933c291b32d..19660cb0ce26 100644 --- a/stdlib/@python2/lib2to3/pgen2/token.pyi +++ b/stdlib/@python2/lib2to3/pgen2/token.pyi @@ -54,6 +54,13 @@ DOUBLESLASHEQUAL: int OP: int COMMENT: int NL: int +if sys.version_info >= (3,): + RARROW: int +if sys.version_info >= (3, 5): + AT: int + ATEQUAL: int + AWAIT: int + ASYNC: int ERRORTOKEN: int N_TOKENS: int NT_OFFSET: int diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 2f52b66d45c9..955763588cd1 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -36,8 +36,9 @@ class Base: 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: ... + if sys.version_info < (3,): + def get_prefix(self) -> Text: ... + def set_prefix(self, prefix: Text) -> None: ... class Node(Base): fixers_applied: List[Any] diff --git a/stdlib/@python2/linecache.pyi b/stdlib/@python2/linecache.pyi index 62c94d4b9770..f52267bdba98 100644 --- a/stdlib/@python2/linecache.pyi +++ b/stdlib/@python2/linecache.pyi @@ -9,3 +9,5 @@ def getlines(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> def checkcache(filename: Optional[Text] = ...) -> None: ... def updatecache(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... +if sys.version_info >= (3, 5): + def lazycache(filename: Text, module_globals: _ModuleGlobals) -> bool: ... diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 1d1ec020e707..9be4aa2735e1 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -3,7 +3,10 @@ from decimal import Decimal from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union # workaround for mypy#2010 -from __builtin__ import str as _str +if sys.version_info >= (3, 0): + from builtins import str as _str +else: + from __builtin__ import str as _str CODESET: int D_T_FMT: int @@ -88,10 +91,17 @@ def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... def format(percent: _str, value: Union[float, Decimal], grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... -def format_string(f: _str, val: Any, grouping: bool = ...) -> _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 currency(val: Union[int, float, Decimal], symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ... +if sys.version_info >= (3, 5): + def delocalize(string: _str) -> _str: ... + def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... def str(val: float) -> _str: ... diff --git a/stdlib/@python2/macpath.pyi b/stdlib/@python2/macpath.pyi index 84c7b42539c9..296f3a9ba151 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -11,6 +11,9 @@ from genericpath import ( isfile as isfile, ) +if sys.version_info >= (3, 4): + from genericpath import samefile as samefile, sameopenfile as sameopenfile, samestat as samestat + # Re-export common definitions from posixpath to reduce duplication from posixpath import ( abspath as abspath, @@ -33,14 +36,45 @@ from typing import AnyStr, Optional, Text, Tuple, overload altsep: Optional[str] -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: ... +if sys.version_info >= (3, 6): + from os import PathLike + @overload + def basename(s: PathLike[AnyStr]) -> AnyStr: ... + @overload + def basename(s: AnyStr) -> AnyStr: ... + @overload + def dirname(s: PathLike[AnyStr]) -> AnyStr: ... + @overload + def dirname(s: AnyStr) -> AnyStr: ... + @overload + def normcase(path: PathLike[AnyStr]) -> AnyStr: ... + @overload + def normcase(path: AnyStr) -> AnyStr: ... + @overload + def normpath(s: PathLike[AnyStr]) -> AnyStr: ... + @overload + def normpath(s: AnyStr) -> AnyStr: ... + @overload + def realpath(path: PathLike[AnyStr]) -> AnyStr: ... + @overload + def realpath(path: AnyStr) -> AnyStr: ... + +else: + 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: AnyPath) -> bool: ... +if sys.version_info >= (3, 6): + # Mypy complains that the signatures overlap, but things seem to behave correctly anyway. + @overload + def join(s: StrPath, *paths: StrPath) -> Text: ... + @overload + def join(s: BytesPath, *paths: BytesPath) -> bytes: ... + elif sys.version_info >= (3, 0): def join(s: AnyStr, *paths: AnyStr) -> AnyStr: ... @@ -60,4 +94,11 @@ else: @overload def join(__p1: Text, *p: AnyPath) -> Text: ... -def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +if sys.version_info >= (3, 6): + @overload + def split(s: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + @overload + def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + +else: + def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index 3bef884d0d5e..d968e7d77244 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -25,6 +25,9 @@ from typing import ( ) from typing_extensions import Literal +if sys.version_info >= (3, 9): + from types import GenericAlias + _T = TypeVar("_T") _MessageT = TypeVar("_MessageT", bound=Message) _MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]] @@ -77,6 +80,9 @@ class Mailbox(Generic[_MessageT]): def lock(self) -> None: ... def unlock(self) -> None: ... def close(self) -> None: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + class Maildir(Mailbox[MaildirMessage]): colon: str @@ -184,6 +190,9 @@ class _ProxyFile(Generic[AnyStr]): def flush(self) -> None: ... @property def closed(self) -> bool: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + class _PartialFile(_ProxyFile[AnyStr]): def __init__(self, f: IO[AnyStr], start: Optional[int] = ..., stop: Optional[int] = ...) -> None: ... diff --git a/stdlib/@python2/math.pyi b/stdlib/@python2/math.pyi index 59819554ba7a..6f9a89996dc0 100644 --- a/stdlib/@python2/math.pyi +++ b/stdlib/@python2/math.pyi @@ -3,6 +3,12 @@ from typing import Iterable, Optional, SupportsFloat, SupportsInt, Tuple, overlo e: float pi: float +if sys.version_info >= (3, 5): + inf: float + nan: float +if sys.version_info >= (3, 6): + tau: float + def acos(__x: SupportsFloat) -> float: ... def acosh(__x: SupportsFloat) -> float: ... def asin(__x: SupportsFloat) -> float: ... @@ -11,13 +17,23 @@ def atan(__x: SupportsFloat) -> float: ... def atan2(__y: SupportsFloat, __x: SupportsFloat) -> float: ... def atanh(__x: SupportsFloat) -> float: ... -def ceil(__x: SupportsFloat) -> float: ... +if sys.version_info >= (3,): + def ceil(__x: SupportsFloat) -> int: ... + +else: + def ceil(__x: SupportsFloat) -> float: ... + +if sys.version_info >= (3, 8): + def comb(__n: int, __k: int) -> int: ... def copysign(__x: SupportsFloat, __y: SupportsFloat) -> float: ... def cos(__x: SupportsFloat) -> float: ... def cosh(__x: SupportsFloat) -> float: ... def degrees(__x: SupportsFloat) -> float: ... +if sys.version_info >= (3, 8): + def dist(__p: Iterable[SupportsFloat], __q: Iterable[SupportsFloat]) -> float: ... + def erf(__x: SupportsFloat) -> float: ... def erfc(__x: SupportsFloat) -> float: ... def exp(__x: SupportsFloat) -> float: ... @@ -25,34 +41,75 @@ def expm1(__x: SupportsFloat) -> float: ... def fabs(__x: SupportsFloat) -> float: ... def factorial(__x: SupportsInt) -> int: ... -def floor(__x: SupportsFloat) -> float: ... +if sys.version_info >= (3,): + def floor(__x: SupportsFloat) -> int: ... + +else: + 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: ... +if sys.version_info >= (3, 9): + def gcd(*integers: int) -> int: ... + elif sys.version_info >= (3, 5): def gcd(__x: int, __y: int) -> int: ... -def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... +if sys.version_info >= (3, 8): + def hypot(*coordinates: SupportsFloat) -> float: ... + +else: + def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... + +if sys.version_info >= (3, 5): + def isclose(a: SupportsFloat, b: SupportsFloat, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... def isinf(__x: SupportsFloat) -> bool: ... +if sys.version_info >= (3,): + def isfinite(__x: SupportsFloat) -> bool: ... + def isnan(__x: SupportsFloat) -> bool: ... +if sys.version_info >= (3, 8): + def isqrt(__n: int) -> int: ... + +if sys.version_info >= (3, 9): + def lcm(*integers: int) -> int: ... + 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: ... +if sys.version_info >= (3, 3): + def log2(__x: SupportsFloat) -> float: ... + def modf(__x: SupportsFloat) -> Tuple[float, float]: ... +if sys.version_info >= (3, 9): + def nextafter(__x: SupportsFloat, __y: SupportsFloat) -> float: ... + +if sys.version_info >= (3, 8): + def perm(__n: int, __k: Optional[int] = ...) -> int: ... + def pow(__x: SupportsFloat, __y: SupportsFloat) -> float: ... +if sys.version_info >= (3, 8): + @overload + def prod(__iterable: Iterable[int], *, start: int = ...) -> int: ... # type: ignore + @overload + def prod(__iterable: Iterable[SupportsFloat], *, start: SupportsFloat = ...) -> float: ... + def radians(__x: SupportsFloat) -> float: ... +if sys.version_info >= (3, 7): + def remainder(__x: SupportsFloat, __y: SupportsFloat) -> float: ... + def sin(__x: SupportsFloat) -> float: ... def sinh(__x: SupportsFloat) -> float: ... def sqrt(__x: SupportsFloat) -> float: ... @@ -60,3 +117,5 @@ def tan(__x: SupportsFloat) -> float: ... def tanh(__x: SupportsFloat) -> float: ... def trunc(__x: SupportsFloat) -> int: ... +if sys.version_info >= (3, 9): + def ulp(__x: SupportsFloat) -> float: ... diff --git a/stdlib/@python2/mimetypes.pyi b/stdlib/@python2/mimetypes.pyi index f4c7b6132d2f..f0cfac32cafd 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -1,7 +1,12 @@ import sys from typing import IO, Dict, List, Optional, Sequence, Text, Tuple, Union -def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... +if sys.version_info >= (3, 8): + from os import PathLike + def guess_type(url: Union[Text, PathLike[str]], strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... + +else: + def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> Optional[str]: ... diff --git a/stdlib/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index 485ddcdc2545..0ba69e5896d7 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -34,7 +34,10 @@ class _mmap(Generic[AnyStr]): 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: ... + if sys.version_info >= (3, 8): + def flush(self, offset: int = ..., size: int = ...) -> None: ... + else: + def flush(self, offset: int = ..., size: int = ...) -> int: ... def move(self, dest: int, src: int, count: int) -> None: ... def read_byte(self) -> AnyStr: ... def readline(self) -> AnyStr: ... @@ -45,13 +48,73 @@ class _mmap(Generic[AnyStr]): def write_byte(self, byte: AnyStr) -> None: ... def __len__(self) -> int: ... -class mmap(_mmap[bytes], Sequence[bytes]): - 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: Union[int, slice]) -> bytes: ... - def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... - def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... +if sys.version_info >= (3,): + class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], Sized): + closed: bool + if sys.version_info >= (3, 8) and sys.platform != "win32": + def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ... + def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... + def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... + def read(self, n: Optional[int] = ...) -> bytes: ... + if sys.version_info >= (3, 6): + def write(self, bytes: ReadableBuffer) -> int: ... + else: + def write(self, bytes: ReadableBuffer) -> None: ... + @overload + def __getitem__(self, index: int) -> int: ... + @overload + def __getitem__(self, index: slice) -> bytes: ... + def __delitem__(self, index: Union[int, slice]) -> None: ... + @overload + def __setitem__(self, index: int, object: int) -> None: ... + @overload + def __setitem__(self, index: slice, object: bytes) -> None: ... + # Doesn't actually exist, but the object is actually iterable because it has __getitem__ and + # __len__, so we claim that there is also an __iter__ to help type checkers. + def __iter__(self) -> Iterator[bytes]: ... + +else: + class mmap(_mmap[bytes], Sequence[bytes]): + 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: Union[int, slice]) -> bytes: ... + def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... + def __delitem__(self, index: Union[int, slice]) -> None: ... + def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... + +if sys.version_info >= (3, 8) and sys.platform != "win32": + MADV_NORMAL: int + MADV_RANDOM: int + MADV_SEQUENTIAL: int + MADV_WILLNEED: int + MADV_DONTNEED: int + + if sys.platform == "linux": + MADV_REMOVE: int + MADV_DONTFORK: int + MADV_DOFORK: int + MADV_HWPOISON: int + MADV_MERGEABLE: int + MADV_UNMERGEABLE: int + # Seems like this constant is not defined in glibc. + # See https://github.com/python/typeshed/pull/5360 for details + # MADV_SOFT_OFFLINE: int + MADV_HUGEPAGE: int + MADV_NOHUGEPAGE: int + MADV_DONTDUMP: int + MADV_DODUMP: int + MADV_FREE: int + + # This Values are defined for FreeBSD but type checkers do not support conditions for these + if sys.platform != "linux" and sys.platform != "darwin": + MADV_NOSYNC: int + MADV_AUTOSYNC: int + MADV_NOCORE: int + MADV_CORE: int + MADV_PROTECT: int +if sys.version_info >= (3, 10) and sys.platform == "darwin": + MADV_FREE_REUSABLE: int + MADV_FREE_REUSE: int diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index b8884b8b62bf..89119b6029df 100644 --- a/stdlib/@python2/modulefinder.pyi +++ b/stdlib/@python2/modulefinder.pyi @@ -31,13 +31,22 @@ class ModuleFinder: excludes: Container[str] # undocumented replace_paths: Sequence[Tuple[str, str]] # undocumented - def __init__( - self, - path: Optional[List[str]] = ..., - debug: int = ..., - excludes: Container[str] = ..., - replace_paths: Sequence[Tuple[str, str]] = ..., - ) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, + path: Optional[List[str]] = ..., + debug: int = ..., + excludes: Optional[Container[str]] = ..., + replace_paths: Optional[Sequence[Tuple[str, str]]] = ..., + ) -> None: ... + else: + def __init__( + self, + path: Optional[List[str]] = ..., + 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 @@ -53,6 +62,8 @@ class ModuleFinder: def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented def import_module(self, partname: str, fqname: str, parent: Module) -> Optional[Module]: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: Tuple[str, str, str]) -> Module: ... # undocumented + if sys.version_info >= (3, 6): + def scan_opcodes(self, co: CodeType) -> Iterator[Tuple[str, Tuple[Any, ...]]]: ... # 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 diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index c783493f315e..0442ffaaec83 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -7,7 +7,8 @@ if sys.platform == "win32": from _msi import _Database AMD64: bool - Itanium: bool + if sys.version_info < (3, 7): + Itanium: bool Win64: bool datasizemask: Literal[0x00FF] diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index cb52934f9f17..36fe063c8486 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -74,8 +74,9 @@ class _NNTPBase: def over( self, message_spec: Union[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]: ... + if sys.version_info < (3, 9): + 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: Union[bytes, Iterable[bytes]]) -> str: ... def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ... diff --git a/stdlib/@python2/numbers.pyi b/stdlib/@python2/numbers.pyi index 796b44366aa3..4f8a5a5d67fc 100644 --- a/stdlib/@python2/numbers.pyi +++ b/stdlib/@python2/numbers.pyi @@ -12,7 +12,10 @@ class Number(metaclass=ABCMeta): class Complex(Number): @abstractmethod def __complex__(self) -> complex: ... - def __nonzero__(self) -> bool: ... + if sys.version_info >= (3, 0): + def __bool__(self) -> bool: ... + else: + def __nonzero__(self) -> bool: ... @property @abstractmethod def real(self) -> Any: ... @@ -33,10 +36,11 @@ class Complex(Number): def __mul__(self, other: Any) -> Any: ... @abstractmethod def __rmul__(self, other: Any) -> Any: ... - @abstractmethod - def __div__(self, other): ... - @abstractmethod - def __rdiv__(self, other): ... + if sys.version_info < (3, 0): + @abstractmethod + def __div__(self, other): ... + @abstractmethod + def __rdiv__(self, other): ... @abstractmethod def __truediv__(self, other: Any) -> Any: ... @abstractmethod @@ -48,13 +52,25 @@ class Complex(Number): def __abs__(self) -> Real: ... def conjugate(self) -> Any: ... def __eq__(self, other: Any) -> bool: ... - def __ne__(self, other: Any) -> bool: ... + if sys.version_info < (3, 0): + def __ne__(self, other: Any) -> bool: ... class Real(Complex, SupportsFloat): @abstractmethod def __float__(self) -> float: ... @abstractmethod def __trunc__(self) -> int: ... + if sys.version_info >= (3, 0): + @abstractmethod + def __floor__(self) -> int: ... + @abstractmethod + def __ceil__(self) -> int: ... + @abstractmethod + @overload + def __round__(self, ndigits: None = ...) -> int: ... + @abstractmethod + @overload + def __round__(self, ndigits: int) -> Any: ... def __divmod__(self, other: Any) -> Any: ... def __rdivmod__(self, other: Any) -> Any: ... @abstractmethod @@ -86,8 +102,12 @@ class Rational(Real): def __float__(self) -> float: ... class Integral(Rational): - @abstractmethod - def __long__(self) -> long: ... + if sys.version_info >= (3, 0): + @abstractmethod + def __int__(self) -> int: ... + else: + @abstractmethod + def __long__(self) -> long: ... def __index__(self) -> int: ... @abstractmethod def __pow__(self, exponent: Any, modulus: Optional[Any] = ...) -> Any: ... diff --git a/stdlib/@python2/opcode.pyi b/stdlib/@python2/opcode.pyi index fc10d0148dce..6307c280aebe 100644 --- a/stdlib/@python2/opcode.pyi +++ b/stdlib/@python2/opcode.pyi @@ -15,6 +15,11 @@ opmap: Dict[str, int] HAVE_ARGUMENT: int EXTENDED_ARG: int +if sys.version_info >= (3, 8): + def stack_effect(__opcode: int, __oparg: Optional[int] = ..., *, jump: Optional[bool] = ...) -> int: ... + elif sys.version_info >= (3, 4): def stack_effect(__opcode: int, __oparg: Optional[int] = ...) -> int: ... +if sys.version_info >= (3, 6): + hasnargs: List[int] diff --git a/stdlib/@python2/operator.pyi b/stdlib/@python2/operator.pyi index 0bbf22c9a2c8..03510fed90fc 100644 --- a/stdlib/@python2/operator.pyi +++ b/stdlib/@python2/operator.pyi @@ -42,8 +42,9 @@ 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: ... +if sys.version_info < (3,): + 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: ... @@ -60,6 +61,10 @@ def __mod__(a: Any, b: Any) -> Any: ... def mul(__a: Any, __b: Any) -> Any: ... def __mul__(a: Any, b: Any) -> Any: ... +if sys.version_info >= (3, 5): + def matmul(__a: Any, __b: Any) -> Any: ... + def __matmul__(a: Any, b: Any) -> Any: ... + def neg(__a: Any) -> Any: ... def __neg__(a: Any) -> Any: ... def or_(__a: Any, __b: Any) -> Any: ... @@ -94,8 +99,9 @@ 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: ... +if sys.version_info < (3,): + 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: ... @@ -110,15 +116,18 @@ 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]: ... +if sys.version_info < (3,): + 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: ... +if sys.version_info < (3,): + def repeat(a: Any, b: int) -> Any: ... + def __repeat__(a: Any, b: int) -> Any: ... -def sequenceIncludes(a: Container[Any], b: Any) -> bool: ... +if sys.version_info < (3,): + def sequenceIncludes(a: Container[Any], b: Any) -> bool: ... @overload def setitem(__a: MutableSequence[_T], __b: int, __c: _T) -> None: ... @@ -133,8 +142,12 @@ 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: ... +if sys.version_info < (3,): + 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: ... + +if sys.version_info >= (3, 4): + def length_hint(__obj: Any, __default: int = ...) -> int: ... class attrgetter(Generic[_T_co]): @overload @@ -173,8 +186,9 @@ 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: ... +if sys.version_info < (3,): + 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: ... @@ -185,13 +199,18 @@ def __imod__(a: Any, b: Any) -> Any: ... def imul(__a: Any, __b: Any) -> Any: ... def __imul__(a: Any, b: Any) -> Any: ... +if sys.version_info >= (3, 5): + def imatmul(__a: Any, __b: Any) -> Any: ... + def __imatmul__(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: ... +if sys.version_info < (3,): + 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: ... @@ -202,7 +221,8 @@ 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: ... +if sys.version_info < (3,): + def isCallable(x: Any) -> bool: ... + def isMappingType(x: Any) -> bool: ... + def isNumberType(x: Any) -> bool: ... + def isSequenceType(x: Any) -> bool: ... diff --git a/stdlib/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index 6726d827aa4d..2229807bc641 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -2,7 +2,10 @@ import sys from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g -_Text = Union[str, unicode] +if sys.version_info >= (3,): + _Text = str +else: + _Text = Union[str, unicode] NO_DEFAULT: Tuple[_Text, ...] SUPPRESS_HELP: _Text @@ -11,7 +14,8 @@ 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: ... +if sys.version_info < (3,): + def isbasestring(x: Any) -> bool: ... class OptParseError(Exception): msg: _Text diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 3be2b0a24da1..7b32f5087495 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -37,6 +37,15 @@ _T = TypeVar("_T") error = OSError +if sys.version_info >= (3, 2): + supports_bytes_environ: bool + +if sys.version_info >= (3, 3): + supports_dir_fd: Set[Callable[..., Any]] + supports_fd: Set[Callable[..., Any]] + supports_effective_ids: Set[Callable[..., Any]] + supports_follow_symlinks: Set[Callable[..., Any]] + SEEK_SET: int SEEK_CUR: int SEEK_END: int @@ -101,6 +110,9 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): def __len__(self) -> int: ... environ: _Environ[str] +if sys.version_info >= (3, 2): + environb: _Environ[bytes] + if sys.platform != "win32": # Unix only confstr_names: Dict[str, int] @@ -233,7 +245,11 @@ def symlink(source: AnyPath, link_name: AnyPath) -> None: ... def unlink(path: AnyPath) -> None: ... # TODO: add ns, dir_fd, follow_symlinks argument -def utime(path: AnyPath, times: Optional[Tuple[float, float]]) -> None: ... +if sys.version_info >= (3, 0): + def utime(path: AnyPath, times: Optional[Tuple[float, float]] = ...) -> None: ... + +else: + def utime(path: AnyPath, times: Optional[Tuple[float, float]]) -> None: ... if sys.platform != "win32": # Unix only @@ -259,9 +275,18 @@ if sys.platform != "win32": def pathconf(path: AnyPath, name: Union[str, int]) -> int: ... def statvfs(path: AnyPath) -> _StatVFS: ... -def walk( - top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... -) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... +if sys.version_info >= (3, 6): + def walk( + top: Union[AnyStr, PathLike[AnyStr]], + topdown: bool = ..., + onerror: Optional[Callable[[OSError], Any]] = ..., + followlinks: bool = ..., + ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... + +else: + def walk( + top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... + ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... def abort() -> NoReturn: ... @@ -292,10 +317,17 @@ if sys.platform != "win32": 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]]: ... +if sys.version_info >= (3, 0): + class popen(_TextIOWrapper): + # TODO 'b' modes or bytes command not accepted? + def __init__(self, command: str, mode: str = ..., bufsize: int = ...) -> None: ... + def close(self) -> Any: ... # may return int + +else: + 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: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, path: AnyPath, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig @@ -330,9 +362,18 @@ else: def getloadavg() -> Tuple[float, float, float]: ... def sysconf(name: Union[str, int]) -> int: ... -def tmpfile() -> IO[Any]: ... -def tmpnam() -> str: ... -def tempnam(dir: str = ..., prefix: str = ...) -> str: ... +if sys.version_info >= (3, 0): + def sched_getaffinity(id: int) -> Set[int]: ... + +if sys.version_info >= (3, 3): + class waitresult: + si_pid: int + def waitid(idtype: int, id: int, options: int) -> waitresult: ... + +if sys.version_info < (3, 0): + def tmpfile() -> IO[Any]: ... + def tmpnam() -> str: ... + def tempnam(dir: str = ..., prefix: str = ...) -> str: ... P_ALL: int WEXITED: int diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index dff9e3467a4e..2750e9ea0f4b 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -17,7 +17,11 @@ def runeval(expression: str, globals: Optional[Dict[str, Any]] = ..., locals: Op def runctx(statement: str, globals: Dict[str, Any], locals: Mapping[str, Any]) -> None: ... def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... -def set_trace() -> None: ... +if sys.version_info >= (3, 7): + def set_trace(*, header: Optional[str] = ...) -> None: ... + +else: + def set_trace() -> None: ... def post_mortem(t: Optional[TracebackType] = ...) -> None: ... def pm() -> None: ... @@ -42,6 +46,16 @@ class Pdb(Bdb, Cmd): curframe: Optional[FrameType] curframe_locals: Mapping[str, Any] + if sys.version_info >= (3, 6): + def __init__( + self, + completekey: str = ..., + stdin: Optional[IO[str]] = ..., + stdout: Optional[IO[str]] = ..., + skip: Optional[Iterable[str]] = ..., + nosigint: bool = ..., + readrc: bool = ..., + ) -> None: ... elif sys.version_info >= (3, 2): def __init__( self, @@ -126,54 +140,101 @@ class Pdb(Bdb, Cmd): 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 + if sys.version_info < (3, 2): + 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 + + if sys.version_info >= (3, 2): + def sigint_handler(self, signum: signal.Signals, frame: FrameType) -> None: ... + def message(self, msg: str) -> None: ... + def error(self, msg: str) -> None: ... + def _select_frame(self, number: int) -> None: ... + def _getval_except(self, arg: str, frame: Optional[FrameType] = ...) -> object: ... + def _print_lines( + self, lines: Sequence[str], start: int, breaks: Sequence[int] = ..., frame: Optional[FrameType] = ... + ) -> None: ... + def _cmdloop(self) -> None: ... + def do_display(self, arg: str) -> Optional[bool]: ... + def do_interact(self, arg: str) -> Optional[bool]: ... + def do_longlist(self, arg: str) -> Optional[bool]: ... + def do_source(self, arg: str) -> Optional[bool]: ... + def do_undisplay(self, arg: str) -> Optional[bool]: ... + do_ll = do_longlist + + if sys.version_info >= (3, 3): + def _complete_location(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... + def _complete_bpnumber(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... + def _complete_expression(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... + def complete_undisplay(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... + def complete_unalias(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... + complete_commands = _complete_bpnumber + complete_break = _complete_location + complete_b = _complete_location + complete_tbreak = _complete_location + complete_enable = _complete_bpnumber + complete_disable = _complete_bpnumber + complete_condition = _complete_bpnumber + complete_ignore = _complete_bpnumber + complete_clear = _complete_location + complete_cl = _complete_location + complete_debug = _complete_expression + complete_print = _complete_expression + complete_p = _complete_expression + complete_pp = _complete_expression + complete_source = _complete_expression + complete_whatis = _complete_expression + complete_display = _complete_expression + + if sys.version_info >= (3, 7): + def _runmodule(self, module_name: str) -> None: ... + if sys.version_info >= (3,) and sys.version_info < (3, 4): + do_print = do_p # undocumented @@ -181,5 +242,9 @@ def find_function(funcname: str, filename: str) -> Optional[Tuple[str, str, int] def main() -> None: ... def help() -> None: ... +if sys.version_info >= (3, 2): + def getsourcelines(obj: _SourceObjectType) -> Tuple[List[str], int]: ... + def lasti2lineno(code: CodeType, lasti: int) -> int: ... + class _rstr(str): def __repr__(self) -> _rstr: ... diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index d68198889730..ddf8a4401399 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -2,8 +2,42 @@ import sys from typing import IO, Any, Callable, Iterable, Iterator, Mapping, Optional, Tuple, Type, Union HIGHEST_PROTOCOL: int +if sys.version_info >= (3, 0): + DEFAULT_PROTOCOL: int + bytes_types: Tuple[Type[Any], ...] # undocumented +if sys.version_info >= (3, 8): + # TODO: holistic design for buffer interface (typing.Buffer?) + class PickleBuffer: + # buffer must be a buffer-providing object + def __init__(self, buffer: Any) -> None: ... + def raw(self) -> memoryview: ... + def release(self) -> None: ... + _BufferCallback = Optional[Callable[[PickleBuffer], Any]] + def dump( + obj: Any, + file: IO[bytes], + protocol: Optional[int] = ..., + *, + fix_imports: bool = ..., + buffer_callback: _BufferCallback = ..., + ) -> None: ... + def dumps( + obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... + ) -> bytes: ... + def load( + file: IO[bytes], + *, + fix_imports: bool = ..., + encoding: str = ..., + errors: str = ..., + buffers: Optional[Iterable[Any]] = ..., + ) -> Any: ... + def loads( + __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Optional[Iterable[Any]] = ... + ) -> Any: ... + elif sys.version_info >= (3, 0): def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... def dumps(obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> bytes: ... @@ -30,6 +64,19 @@ _reducedtype = Union[ class Pickler: fast: bool + if sys.version_info >= (3, 3): + dispatch_table: Mapping[type, Callable[[Any], _reducedtype]] + + if sys.version_info >= (3, 8): + def __init__( + self, + file: IO[bytes], + protocol: Optional[int] = ..., + *, + fix_imports: bool = ..., + buffer_callback: _BufferCallback = ..., + ) -> None: ... + def reducer_override(self, obj: Any) -> Any: ... elif sys.version_info >= (3, 0): def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... else: @@ -39,12 +86,25 @@ class Pickler: def persistent_id(self, obj: Any) -> Any: ... class Unpickler: + if sys.version_info >= (3, 8): + def __init__( + self, + file: IO[bytes], + *, + fix_imports: bool = ..., + encoding: str = ..., + errors: str = ..., + buffers: Optional[Iterable[Any]] = ..., + ) -> None: ... elif sys.version_info >= (3, 0): def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> None: ... else: def __init__(self, file: IO[bytes]) -> None: ... def load(self) -> Any: ... def find_class(self, __module_name: str, __global_name: str) -> Any: ... + if sys.version_info >= (3, 0): + def persistent_load(self, pid: Any) -> Any: ... + MARK: bytes STOP: bytes POP: bytes @@ -104,5 +164,23 @@ NEWFALSE: bytes LONG1: bytes LONG4: bytes +if sys.version_info >= (3, 0): + # protocol 3 + BINBYTES: bytes + SHORT_BINBYTES: bytes + +if sys.version_info >= (3, 4): + # protocol 4 + SHORT_BINUNICODE: bytes + BINUNICODE8: bytes + BINBYTES8: bytes + EMPTY_SET: bytes + ADDITEMS: bytes + FROZENSET: bytes + NEWOBJ_EX: bytes + STACK_GLOBAL: bytes + MEMOIZE: bytes + FRAME: bytes + def encode_long(x: int) -> bytes: ... # undocumented def decode_long(data: bytes) -> int: ... # undocumented diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index 4ad75fb8bbbf..ec279524bc50 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -3,9 +3,17 @@ from typing import IO, Any, Callable, Iterator, List, MutableMapping, Optional, _Reader = Callable[[IO[bytes]], Any] +if sys.version_info >= (3, 0): + bytes_types: Tuple[Type[Any], ...] + UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int TAKEN_FROM_ARGUMENT4: int +if sys.version_info >= (3, 3): + TAKEN_FROM_ARGUMENT4U: int +if sys.version_info >= (3, 4): + TAKEN_FROM_ARGUMENT8U: int + class ArgumentDescriptor(object): name: str n: int @@ -25,6 +33,14 @@ def read_int4(f: IO[bytes]) -> int: ... int4: ArgumentDescriptor +if sys.version_info >= (3, 3): + def read_uint4(f: IO[bytes]) -> int: ... + uint4: ArgumentDescriptor + +if sys.version_info >= (3, 5): + def read_uint8(f: IO[bytes]) -> int: ... + uint8: ArgumentDescriptor + def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, Text]: ... stringnl: ArgumentDescriptor @@ -45,14 +61,32 @@ def read_string4(f: IO[bytes]) -> str: ... string4: ArgumentDescriptor +if sys.version_info >= (3, 3): + def read_bytes1(f: IO[bytes]) -> bytes: ... + bytes1: ArgumentDescriptor + def read_bytes4(f: IO[bytes]) -> bytes: ... + bytes4: ArgumentDescriptor + +if sys.version_info >= (3, 4): + def read_bytes8(f: IO[bytes]) -> bytes: ... + bytes8: ArgumentDescriptor + def read_unicodestringnl(f: IO[bytes]) -> Text: ... unicodestringnl: ArgumentDescriptor +if sys.version_info >= (3, 4): + def read_unicodestring1(f: IO[bytes]) -> Text: ... + unicodestring1: ArgumentDescriptor + def read_unicodestring4(f: IO[bytes]) -> Text: ... unicodestring4: ArgumentDescriptor +if sys.version_info >= (3, 4): + def read_unicodestring8(f: IO[bytes]) -> Text: ... + unicodestring8: ArgumentDescriptor + def read_decimalnl_short(f: IO[bytes]) -> int: ... def read_decimalnl_long(f: IO[bytes]) -> int: ... @@ -86,12 +120,19 @@ pylong: StackObject pyinteger_or_bool: StackObject pybool: StackObject pyfloat: StackObject +if sys.version_info >= (3, 4): + pybytes_or_str: StackObject pystring: StackObject +if sys.version_info >= (3, 0): + pybytes: StackObject pyunicode: StackObject pynone: StackObject pytuple: StackObject pylist: StackObject pydict: StackObject +if sys.version_info >= (3, 4): + pyset: StackObject + pyfrozenset: StackObject anyobject: StackObject markobject: StackObject stackslice: StackObject @@ -120,9 +161,19 @@ opcodes: List[OpcodeInfo] def genops(pickle: Union[bytes, IO[bytes]]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... def optimize(p: Union[bytes, IO[bytes]]) -> bytes: ... -def dis( - pickle: Union[bytes, IO[bytes]], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., - indentlevel: int = ..., -) -> None: ... +if sys.version_info >= (3, 2): + def dis( + pickle: Union[bytes, IO[bytes]], + out: Optional[IO[str]] = ..., + memo: Optional[MutableMapping[int, Any]] = ..., + indentlevel: int = ..., + annotate: int = ..., + ) -> None: ... + +else: + def dis( + pickle: Union[bytes, IO[bytes]], + out: Optional[IO[str]] = ..., + memo: Optional[MutableMapping[int, Any]] = ..., + indentlevel: int = ..., + ) -> None: ... diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index a068d421f5f5..0935e922562e 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -2,11 +2,21 @@ import sys from _typeshed import SupportsRead from typing import IO, Any, Callable, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Union -Loader = Any -MetaPathFinder = Any -PathEntryFinder = Any +if sys.version_info >= (3,): + from importlib.abc import Loader, MetaPathFinder, PathEntryFinder +else: + Loader = Any + MetaPathFinder = Any + PathEntryFinder = Any -_ModuleInfoLike = Tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] +if sys.version_info >= (3, 6): + class ModuleInfo(NamedTuple): + module_finder: Union[MetaPathFinder, PathEntryFinder] + name: str + ispkg: bool + _ModuleInfoLike = ModuleInfo +else: + _ModuleInfoLike = Tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] def extend_path(path: List[str], name: str) -> List[str]: ... @@ -27,3 +37,5 @@ def walk_packages( ) -> Iterator[_ModuleInfoLike]: ... def get_data(package: str, resource: str) -> Optional[bytes]: ... +if sys.version_info >= (3, 9): + def resolve_name(name: str) -> Any: ... diff --git a/stdlib/@python2/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 9c4a1ff89ddd..5aadae9fc97b 100644 --- a/stdlib/@python2/plistlib.pyi +++ b/stdlib/@python2/plistlib.pyi @@ -1,8 +1,20 @@ import sys from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Optional, Text, Type, Union +if sys.version_info >= (3,): + from enum import Enum + class PlistFormat(Enum): + FMT_XML: int + FMT_BINARY: int + FMT_XML = PlistFormat.FMT_XML + FMT_BINARY = PlistFormat.FMT_BINARY + _Path = Union[str, Text] +if sys.version_info >= (3, 9): + def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... + def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... + elif sys.version_info >= (3, 4): def load( fp: IO[bytes], @@ -19,24 +31,42 @@ elif sys.version_info >= (3, 4): dict_type: Type[MutableMapping[str, Any]] = ..., ) -> Any: ... -def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... -def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... -def readPlistFromBytes(data: bytes) -> Any: ... -def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... +if sys.version_info >= (3, 4): + def dump( + value: Mapping[str, Any], fp: IO[bytes], *, fmt: PlistFormat = ..., sort_keys: bool = ..., skipkeys: bool = ... + ) -> None: ... + def dumps(value: Mapping[str, Any], *, fmt: PlistFormat = ..., skipkeys: bool = ..., sort_keys: bool = ...) -> bytes: ... + +if sys.version_info < (3, 9): + def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... + def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... + def readPlistFromBytes(data: bytes) -> Any: ... + def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... + +if sys.version_info < (3,): + 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: ... -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: ... +if sys.version_info < (3, 7): + class Dict(DictT[str, Any]): + def __getattr__(self, attr: str) -> Any: ... + def __setattr__(self, attr: str, value: Any) -> None: ... + def __delattr__(self, attr: str) -> None: ... -class Dict(DictT[str, Any]): - def __getattr__(self, attr: str) -> Any: ... - def __setattr__(self, attr: str, value: Any) -> None: ... - def __delattr__(self, attr: str) -> None: ... +if sys.version_info < (3, 9): + class Data: + data: bytes + def __init__(self, data: bytes) -> None: ... -class Data: - data: bytes - def __init__(self, data: bytes) -> None: ... +if sys.version_info >= (3, 8): + class UID: + data: int + def __init__(self, data: int) -> None: ... + def __index__(self) -> int: ... + def __reduce__(self) -> Any: ... + def __hash__(self) -> int: ... class InvalidFileException(ValueError): def __init__(self, message: str = ...) -> None: ... diff --git a/stdlib/@python2/poplib.pyi b/stdlib/@python2/poplib.pyi index 0e400db66bc2..2c08f3586c0f 100644 --- a/stdlib/@python2/poplib.pyi +++ b/stdlib/@python2/poplib.pyi @@ -14,6 +14,9 @@ LF: bytes CRLF: bytes class POP3: + if sys.version_info >= (3, 0): + encoding: Text + host: Text port: int sock: socket.socket @@ -35,13 +38,36 @@ class POP3: def rpop(self, user: Text) -> bytes: ... timestamp: Pattern[Text] - def apop(self, user: Text, secret: Text) -> bytes: ... + if sys.version_info < (3, 0): + def apop(self, user: Text, secret: Text) -> bytes: ... + else: + def apop(self, user: Text, password: Text) -> bytes: ... def top(self, which: Any, howmuch: int) -> _LongResp: ... @overload def uidl(self) -> _LongResp: ... @overload def uidl(self, which: Any) -> bytes: ... + if sys.version_info >= (3, 5): + def utf8(self) -> bytes: ... + if sys.version_info >= (3, 4): + def capa(self) -> Dict[Text, List[Text]]: ... + def stls(self, context: Optional[ssl.SSLContext] = ...) -> bytes: ... + class POP3_SSL(POP3): - def __init__( - self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... - ) -> None: ... + if sys.version_info >= (3, 0): + def __init__( + self, + host: Text, + port: int = ..., + keyfile: Optional[Text] = ..., + certfile: Optional[Text] = ..., + timeout: float = ..., + context: Optional[ssl.SSLContext] = ..., + ) -> None: ... + else: + def __init__( + self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... + ) -> None: ... + if sys.version_info >= (3, 4): + # "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored + def stls(self, context: Any = ..., keyfile: Any = ..., certfile: Any = ...) -> bytes: ... diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index 96893ed84e0f..9484f92eca46 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -1,6 +1,18 @@ import sys from typing import IO, Any, Dict, Optional, Tuple +if sys.version_info >= (3, 10): + def pformat( + object: object, + indent: int = ..., + width: int = ..., + depth: Optional[int] = ..., + *, + compact: bool = ..., + sort_dicts: bool = ..., + underscore_numbers: bool = ..., + ) -> str: ... + elif sys.version_info >= (3, 8): def pformat( object: object, @@ -20,6 +32,19 @@ elif sys.version_info >= (3, 4): else: def pformat(object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ...) -> str: ... +if sys.version_info >= (3, 10): + def pp( + object: object, + stream: Optional[IO[str]] = ..., + indent: int = ..., + width: int = ..., + depth: Optional[int] = ..., + *, + compact: bool = ..., + sort_dicts: bool = ..., + underscore_numbers: bool = ..., + ) -> None: ... + elif sys.version_info >= (3, 8): def pp( object: object, @@ -32,6 +57,19 @@ elif sys.version_info >= (3, 8): sort_dicts: bool = ..., ) -> None: ... +if sys.version_info >= (3, 10): + def pprint( + object: object, + stream: Optional[IO[str]] = ..., + indent: int = ..., + width: int = ..., + depth: Optional[int] = ..., + *, + compact: bool = ..., + sort_dicts: bool = ..., + underscore_numbers: bool = ..., + ) -> None: ... + elif sys.version_info >= (3, 8): def pprint( object: object, @@ -65,6 +103,18 @@ def isrecursive(object: object) -> bool: ... def saferepr(object: object) -> str: ... class PrettyPrinter: + if sys.version_info >= (3, 10): + def __init__( + self, + indent: int = ..., + width: int = ..., + depth: Optional[int] = ..., + stream: Optional[IO[str]] = ..., + *, + compact: bool = ..., + sort_dicts: bool = ..., + underscore_numbers: bool = ..., + ) -> None: ... elif sys.version_info >= (3, 8): def __init__( self, diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index 59eb08730680..9c74aeb9c3de 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -7,6 +7,19 @@ from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) +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 Stats: sort_arg_dict_default: Dict[str, Tuple[Any, str]] def __init__( diff --git a/stdlib/@python2/pty.pyi b/stdlib/@python2/pty.pyi index 81012ac4dce7..f31e2c61ca9b 100644 --- a/stdlib/@python2/pty.pyi +++ b/stdlib/@python2/pty.pyi @@ -14,4 +14,8 @@ def master_open() -> Tuple[int, str]: ... def slave_open(tty_name: str) -> int: ... def fork() -> Tuple[int, int]: ... -def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... +if sys.version_info >= (3, 4): + def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... + +else: + def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index 111e78f4a429..49473b17708e 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -10,6 +10,25 @@ 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 = ... + def _get_default_invalidation_mode() -> PycInvalidationMode: ... + +if sys.version_info >= (3, 8): + def compile( + file: AnyStr, + cfile: Optional[AnyStr] = ..., + dfile: Optional[AnyStr] = ..., + doraise: bool = ..., + optimize: int = ..., + invalidation_mode: Optional[PycInvalidationMode] = ..., + quiet: int = ..., + ) -> Optional[AnyStr]: ... + elif sys.version_info >= (3, 7): def compile( file: AnyStr, diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 8dd739ef0ce6..665ea43c0d4a 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -9,7 +9,18 @@ class Class: file: int lineno: int - def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... + if sys.version_info >= (3, 7): + def __init__( + self, + module: str, + name: str, + super: Optional[List[Union[Class, str]]], + file: str, + lineno: int, + parent: Optional[Class] = ..., + ) -> None: ... + else: + def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... class Function: module: str @@ -17,7 +28,10 @@ class Function: file: int lineno: int - def __init__(self, module: str, name: str, file: str, lineno: int) -> None: ... + if sys.version_info >= (3, 7): + def __init__(self, module: str, name: str, file: str, lineno: int, parent: Optional[Function] = ...) -> None: ... + else: + def __init__(self, module: str, name: str, file: str, lineno: int) -> None: ... def readmodule(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Class]: ... def readmodule_ex(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Union[Class, Function, List[str]]]: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 52f8c92cc517..39252dd9f725 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -19,7 +19,10 @@ from typing import ( Union, ) -from repr import Repr +if sys.version_info >= (3,): + from reprlib import Repr +else: + 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]] @@ -263,7 +266,8 @@ def apropos(key: str) -> None: ... def ispath(x: Any) -> bool: ... def cli() -> None: ... -def serve( - port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ... -) -> None: ... -def gui() -> None: ... +if sys.version_info < (3,): + def serve( + port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ... + ) -> None: ... + def gui() -> None: ... diff --git a/stdlib/@python2/pyexpat/errors.pyi b/stdlib/@python2/pyexpat/errors.pyi index 61420a6caa51..6cde43e3b61f 100644 --- a/stdlib/@python2/pyexpat/errors.pyi +++ b/stdlib/@python2/pyexpat/errors.pyi @@ -1,6 +1,10 @@ import sys from typing import Dict +if sys.version_info >= (3, 2): + codes: Dict[str, int] + messages: Dict[int, str] + XML_ERROR_ABORTED: str XML_ERROR_ASYNC_ENTITY: str XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: str diff --git a/stdlib/@python2/queue.pyi b/stdlib/@python2/queue.pyi index f3d215676758..82fde5989d34 100644 --- a/stdlib/@python2/queue.pyi +++ b/stdlib/@python2/queue.pyi @@ -2,6 +2,9 @@ import sys from threading import Condition, Lock from typing import Any, Generic, Optional, TypeVar +if sys.version_info >= (3, 9): + from types import GenericAlias + _T = TypeVar("_T") class Empty(Exception): ... @@ -30,6 +33,20 @@ class Queue(Generic[_T]): def qsize(self) -> int: ... def _qsize(self) -> int: ... def task_done(self) -> None: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + class PriorityQueue(Queue[_T]): ... class LifoQueue(Queue[_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: Optional[float] = ...) -> _T: ... + def get_nowait(self) -> _T: ... + def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> 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/stdlib/@python2/readline.pyi b/stdlib/@python2/readline.pyi index 18bc6ff4418d..8f28a2b2b760 100644 --- a/stdlib/@python2/readline.pyi +++ b/stdlib/@python2/readline.pyi @@ -13,6 +13,9 @@ def redisplay() -> None: ... def read_history_file(__filename: Optional[AnyPath] = ...) -> None: ... def write_history_file(__filename: Optional[AnyPath] = ...) -> None: ... +if sys.version_info >= (3, 5): + def append_history_file(__nelements: int, __filename: Optional[AnyPath] = ...) -> None: ... + def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... @@ -22,6 +25,9 @@ def remove_history_item(__pos: int) -> None: ... def replace_history_item(__pos: int, __line: str) -> None: ... def add_history(__string: str) -> None: ... +if sys.version_info >= (3, 6): + def set_auto_history(__enabled: bool) -> None: ... + def set_startup_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... def set_pre_input_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... def set_completer(__function: _CompleterT = ...) -> None: ... diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index 12b4b4966f9e..3733cc13110c 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -1,7 +1,10 @@ import sys from typing import Any, Dict, Optional, Union -_Text = Union[str, unicode] +if sys.version_info >= (3,): + _Text = str +else: + _Text = Union[str, unicode] class Completer: def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... diff --git a/stdlib/@python2/sched.pyi b/stdlib/@python2/sched.pyi index 7775c050776c..21d81e16ec60 100644 --- a/stdlib/@python2/sched.pyi +++ b/stdlib/@python2/sched.pyi @@ -9,10 +9,30 @@ class Event(NamedTuple): 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: ... + if sys.version_info >= (3, 3): + def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], None] = ...) -> None: ... + def enterabs( + self, + time: float, + priority: Any, + action: Callable[..., Any], + 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] = ..., + ) -> Event: ... + def run(self, blocking: bool = ...) -> Optional[float]: ... + else: + 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 diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index 5c88d27bf66a..e0cf3bdd4d75 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -28,7 +28,10 @@ def select( __rlist: Iterable[Any], __wlist: Iterable[Any], __xlist: Iterable[Any], __timeout: Optional[float] = ... ) -> Tuple[List[Any], List[Any], List[Any]]: ... -class error(Exception): ... +if sys.version_info >= (3, 3): + error = OSError +else: + class error(Exception): ... if sys.platform != "linux" and sys.platform != "win32": # BSD only @@ -100,7 +103,18 @@ if sys.platform != "linux" and sys.platform != "win32": if sys.platform == "linux": class epoll(object): - def __init__(self, sizehint: int = ...) -> None: ... + if sys.version_info >= (3, 3): + def __init__(self, sizehint: int = ..., flags: int = ...) -> None: ... + else: + def __init__(self, sizehint: int = ...) -> None: ... + if sys.version_info >= (3, 4): + def __enter__(self) -> epoll: ... + def __exit__( + self, + exc_type: Optional[Type[BaseException]] = ..., + exc_val: Optional[BaseException] = ..., + exc_tb: Optional[TracebackType] = ..., + ) -> None: ... def close(self) -> None: ... closed: bool def fileno(self) -> int: ... @@ -125,3 +139,14 @@ if sys.platform == "linux": EPOLL_RDHUP: int if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win32": + if sys.version_info >= (3, 3): + # Solaris only + class devpoll: + if sys.version_info >= (3, 4): + 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: Optional[float] = ...) -> List[Tuple[int, int]]: ... diff --git a/stdlib/@python2/shutil.pyi b/stdlib/@python2/shutil.pyi index 1dc20224ca62..c0779d871c14 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -18,6 +18,12 @@ from typing import ( overload, ) +if sys.version_info >= (3, 6): + _AnyStr = str + _AnyPath = TypeVar("_AnyPath", str, os.PathLike[str]) + # Return value of some functions that may either return a path-like object that was passed in or + # a string + _PathReturn = Any elif sys.version_info >= (3,): _AnyStr = str _AnyPath = str @@ -27,20 +33,48 @@ else: _AnyPath = TypeVar("_AnyPath", str, unicode) _PathReturn = Type[None] -class Error(EnvironmentError): ... -class SpecialFileError(EnvironmentError): ... -class ExecError(EnvironmentError): ... +if sys.version_info >= (3,): + class Error(OSError): ... + class SameFileError(Error): ... + class SpecialFileError(OSError): ... + class ExecError(OSError): ... + class ReadError(OSError): ... + class RegistryError(Exception): ... + +else: + class Error(EnvironmentError): ... + class SpecialFileError(EnvironmentError): ... + class ExecError(EnvironmentError): ... def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ... -def copyfile(src: StrPath, dst: StrPath) -> None: ... -def copymode(src: StrPath, dst: StrPath) -> None: ... -def copystat(src: StrPath, dst: StrPath) -> None: ... -def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... -def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... +if sys.version_info >= (3,): + def copyfile(src: StrPath, dst: _AnyPath, *, follow_symlinks: bool = ...) -> _AnyPath: ... + def copymode(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ... + def copystat(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ... + def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ... + def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ... + +else: + def copyfile(src: StrPath, dst: StrPath) -> None: ... + def copymode(src: StrPath, dst: StrPath) -> None: ... + def copystat(src: StrPath, dst: StrPath) -> None: ... + def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... + def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... def ignore_patterns(*patterns: StrPath) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... +if sys.version_info >= (3, 8): + def copytree( + src: StrPath, + dst: StrPath, + symlinks: bool = ..., + ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ..., + copy_function: Callable[[str, str], None] = ..., + ignore_dangling_symlinks: bool = ..., + dirs_exist_ok: bool = ..., + ) -> _PathReturn: ... + elif sys.version_info >= (3,): def copytree( src: StrPath, @@ -59,12 +93,21 @@ else: ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ..., ) -> _PathReturn: ... -def rmtree( - path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ... -) -> None: ... +if sys.version_info >= (3,): + def rmtree( + path: Union[bytes, StrPath], ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ... + ) -> None: ... + +else: + def rmtree( + path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ... + ) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] +if sys.version_info >= (3, 9): + def move(src: StrPath, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ... + elif sys.version_info >= (3, 5): # See https://bugs.python.org/issue32689 def move(src: str, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ... @@ -72,6 +115,20 @@ elif sys.version_info >= (3, 5): else: def move(src: StrPath, dst: StrPath) -> _PathReturn: ... +if sys.version_info >= (3,): + class _ntuple_diskusage(NamedTuple): + total: int + used: int + free: int + def disk_usage(path: StrPath) -> _ntuple_diskusage: ... + def chown(path: StrPath, user: Optional[Union[str, int]] = ..., group: Optional[Union[str, int]] = ...) -> None: ... + +if sys.version_info >= (3, 8): + @overload + def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... + @overload + def which(cmd: bytes, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[bytes]: ... + elif sys.version_info >= (3,): def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... @@ -95,3 +152,19 @@ def register_archive_format( ) -> None: ... def unregister_archive_format(name: str) -> None: ... +if sys.version_info >= (3,): + if sys.version_info >= (3, 7): + def unpack_archive(filename: StrPath, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... + else: + # See http://bugs.python.org/issue30218 + def unpack_archive(filename: str, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... + def register_unpack_format( + name: str, + extensions: List[str], + function: Any, + extra_args: Optional[Sequence[Tuple[str, Any]]] = ..., + description: str = ..., + ) -> None: ... + def unregister_unpack_format(name: str) -> None: ... + def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ... + def get_terminal_size(fallback: Tuple[int, int] = ...) -> os.terminal_size: ... diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index bd0093cb98bf..92f078a063f6 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -10,7 +10,39 @@ class SMTPChannel(asynchat.async_chat): COMMAND: int DATA: int - def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... + if sys.version_info >= (3,): + command_size_limits: DefaultDict[str, int] + smtp_server: SMTPServer + conn: socket.socket + addr: Any + received_lines: List[Text] + smtp_state: int + seen_greeting: str + mailfrom: str + rcpttos: List[str] + received_data: str + fqdn: str + peer: str + + command_size_limit: int + data_size_limit: int + + enable_SMTPUTF8: bool + @property + def max_command_size_limit(self) -> int: ... + if sys.version_info >= (3,): + def __init__( + self, + server: SMTPServer, + conn: socket.socket, + addr: Any, + data_size_limit: int = ..., + map: Optional[asyncore._maptype] = ..., + enable_SMTPUTF8: bool = ..., + decode_data: bool = ..., + ) -> None: ... + else: + def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... # base asynchat.async_chat.push() accepts bytes def push(self, msg: Text) -> None: ... # type: ignore def collect_incoming_data(self, data: bytes) -> None: ... @@ -22,13 +54,30 @@ class SMTPChannel(asynchat.async_chat): def smtp_RCPT(self, arg: str) -> None: ... def smtp_RSET(self, arg: str) -> None: ... def smtp_DATA(self, arg: str) -> None: ... + if sys.version_info >= (3, 3): + def smtp_EHLO(self, arg: str) -> None: ... + def smtp_HELP(self, arg: str) -> None: ... + def smtp_VRFY(self, arg: str) -> None: ... + def smtp_EXPN(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: ... + if sys.version_info >= (3,): + def __init__( + self, + localaddr: _Address, + remoteaddr: _Address, + data_size_limit: int = ..., + map: Optional[asyncore._maptype] = ..., + enable_SMTPUTF8: bool = ..., + decode_data: bool = ..., + ) -> None: ... + else: + 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: Union[bytes, str], **kwargs: Any diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index 3345f5f011e2..ef025ac571a7 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -2,7 +2,16 @@ import sys from _typeshed import AnyPath from typing import NamedTuple, Optional, Tuple, Union -_SndHeaders = Tuple[str, int, int, int, Union[int, str]] +if sys.version_info >= (3, 5): + class SndHeaders(NamedTuple): + filetype: str + framerate: int + nchannels: int + nframes: int + sampwidth: Union[int, str] + _SndHeaders = SndHeaders +else: + _SndHeaders = Tuple[str, int, int, int, Union[int, str]] def what(filename: AnyPath) -> Optional[_SndHeaders]: ... def whathdr(filename: AnyPath) -> Optional[_SndHeaders]: ... diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index 8d2722bbb01d..e3f5d9b35bef 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -13,6 +13,9 @@ from typing_extensions import Literal # Constants defined by Python (i.e. not OS constants re-exported from C) has_ipv6: bool SocketType: Any +if sys.version_info >= (3,): + SocketIO: Any + # Re-exported errno EAGAIN: int EBADF: int @@ -260,6 +263,9 @@ TCP_NODELAY: int TCP_QUICKACK: int TCP_SYNCNT: int TCP_WINDOW_CLAMP: int +if sys.version_info >= (3, 7): + TCP_NOTSENT_LOWAT: int + # Specifically-documented constants if sys.platform == "linux" and sys.version_info >= (3,): @@ -381,6 +387,8 @@ if sys.platform == "linux" and sys.version_info >= (3,): if sys.platform == "win32": SIO_RCVALL: int SIO_KEEPALIVE_VALS: int + if sys.version_info >= (3, 6): + SIO_LOOPBACK_FAST_PATH: int RCVALL_IPLEVEL: int RCVALL_MAX: int RCVALL_OFF: int @@ -443,6 +451,14 @@ AF_LINK: AddressFamily # Availability: BSD, macOS # BDADDR_* and HCI_* listed with other bluetooth constants below +if sys.version_info >= (3, 6): + SO_DOMAIN: int + SO_PASSSEC: int + SO_PEERSEC: int + SO_PROTOCOL: int + TCP_CONGESTION: int + TCP_USER_TIMEOUT: int + if sys.platform == "linux" and sys.version_info >= (3, 8): AF_QIPCRTR: AddressFamily @@ -490,15 +506,90 @@ if sys.platform == "darwin": SYSPROTO_CONTROL: int # enum versions of above flags -AddressFamily = int -SocketKind = int +if sys.version_info >= (3, 4): + from enum import IntEnum + class AddressFamily(IntEnum): + AF_UNIX: int + AF_INET: int + AF_INET6: int + AF_AAL5: int + AF_ALG: int + AF_APPLETALK: int + AF_ASH: int + AF_ATMPVC: int + AF_ATMSVC: int + AF_AX25: int + AF_BLUETOOTH: int + AF_BRIDGE: int + AF_CAN: int + AF_DECnet: int + AF_ECONET: int + AF_IPX: int + AF_IRDA: int + AF_KEY: int + AF_LINK: int + AF_LLC: int + AF_NETBEUI: int + AF_NETLINK: int + AF_NETROM: int + AF_PACKET: int + AF_PPPOX: int + AF_QIPCRTR: int + AF_RDS: int + AF_ROSE: int + AF_ROUTE: int + AF_SECURITY: int + AF_SNA: int + AF_SYSTEM: int + AF_TIPC: int + AF_UNSPEC: int + AF_VSOCK: int + AF_WANPIPE: int + AF_X25: int + class SocketKind(IntEnum): + SOCK_STREAM: int + SOCK_DGRAM: int + SOCK_RAW: int + SOCK_RDM: int + SOCK_SEQPACKET: int + SOCK_CLOEXEC: int + SOCK_NONBLOCK: int + +else: + AddressFamily = int + SocketKind = int + +if sys.version_info >= (3, 6): + from enum import IntFlag + class AddressInfo(IntFlag): + AI_ADDRCONFIG: int + AI_ALL: int + AI_CANONNAME: int + AI_NUMERICHOST: int + AI_NUMERICSERV: int + AI_PASSIVE: int + AI_V4MAPPED: int + class MsgFlag(IntFlag): + MSG_CTRUNC: int + MSG_DONTROUTE: int + MSG_DONTWAIT: int + MSG_EOR: int + MSG_OOB: int + MSG_PEEK: int + MSG_TRUNC: int + MSG_WAITALL: int -AddressInfo = int -MsgFlag = int +else: + AddressInfo = int + MsgFlag = int # ----- Exceptions ----- -class error(IOError): ... +if sys.version_info < (3,): + class error(IOError): ... + +else: + error = OSError class herror(error): def __init__(self, herror: int = ..., string: str = ...) -> None: ... @@ -527,7 +618,12 @@ class socket: type: int proto: int - def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... + if sys.version_info < (3,): + def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... + else: + def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: Optional[int] = ...) -> None: ... + def __enter__(self: _SelfT) -> _SelfT: ... + def __exit__(self, *args: Any) -> None: ... # --- methods --- def accept(self) -> Tuple[socket, _RetAddress]: ... def bind(self, address: Union[_Address, bytes]) -> None: ... @@ -537,22 +633,57 @@ class socket: def detach(self) -> int: ... def dup(self) -> socket: ... def fileno(self) -> int: ... + if sys.version_info >= (3, 4): + def get_inheritable(self) -> bool: ... 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: ... + if sys.version_info >= (3, 7): + def getblocking(self) -> bool: ... def gettimeout(self) -> Optional[float]: ... if sys.platform == "win32" and sys.version_info >= (3, 6): def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ... elif sys.platform == "win32": def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ... - def listen(self, __backlog: int) -> None: ... + if sys.version_info >= (3, 5): + def listen(self, __backlog: int = ...) -> None: ... + else: + 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: ... + if sys.version_info >= (3,): + # mode strings with duplicates are intentionally excluded + @overload + def makefile( + self, + mode: Literal["r", "w", "rw", "wr", ""] = ..., + buffering: Optional[int] = ..., + *, + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + ) -> TextIO: ... + @overload + def makefile( + self, + mode: Literal["b", "rb", "br", "wb", "bw", "rwb", "rbw", "wrb", "wbr", "brw", "bwr"], + buffering: Optional[int] = ..., + *, + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + ) -> BinaryIO: ... + else: + 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]: ... + if sys.version_info >= (3, 3) and sys.platform != "win32": + def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ... + def recvmsg_into( + self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ..., __flags: int = ... + ) -> Tuple[int, List[_CMSG], int, Any]: ... 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: ... @@ -561,39 +692,72 @@ class socket: def sendto(self, data: bytes, address: _Address) -> int: ... @overload def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... + if sys.version_info >= (3, 3) and sys.platform != "win32": + def sendmsg( + self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., __flags: int = ..., __address: _Address = ... + ) -> int: ... if sys.platform == "linux" and sys.version_info >= (3, 6): def sendmsg_afalg( self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... + if sys.version_info >= (3,): + def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ... + def set_inheritable(self, inheritable: bool) -> None: ... def setblocking(self, flag: bool) -> None: ... def settimeout(self, value: Optional[float]) -> None: ... - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + if sys.version_info < (3, 6): + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + else: + @overload + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + @overload + def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ... if sys.platform == "win32": def share(self, process_id: int) -> bytes: ... def shutdown(self, how: int) -> None: ... # ----- Functions ----- +if sys.version_info >= (3, 7): + def close(fd: int) -> None: ... + def create_connection( address: Tuple[Optional[str], int], timeout: Optional[float] = ..., source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ..., ) -> socket: ... +if sys.version_info >= (3, 8): + def create_server( + address: _Address, *, family: int = ..., backlog: Optional[int] = ..., reuse_port: bool = ..., dualstack_ipv6: bool = ... + ) -> socket: ... + def has_dualstack_ipv6() -> bool: ... + def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... if sys.platform == "win32" and sys.version_info >= (3, 3): def fromshare(info: bytes) -> socket: ... # the 5th tuple item is an address -def getaddrinfo( - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], - family: int = ..., - socktype: int = ..., - proto: int = ..., - flags: int = ..., -) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]: ... +if sys.version_info >= (3,): + def getaddrinfo( + host: Optional[Union[bytearray, bytes, Text]], + port: Union[str, int, None], + family: int = ..., + type: int = ..., + proto: int = ..., + flags: int = ..., + ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... + +else: + def getaddrinfo( + host: Optional[Union[bytearray, bytes, Text]], + port: Union[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: ... @@ -620,6 +784,26 @@ 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: ... +if sys.version_info >= (3, 9): + if sys.platform != "win32": + # flags and address appear to be unused in send_fds and recv_fds + def send_fds( + sock: socket, buffers: Iterable[bytes], fds: Union[bytes, Iterable[int]], flags: int = ..., address: None = ... + ) -> int: ... + def recv_fds(sock: socket, bufsize: int, maxfds: int, flags: int = ...) -> Tuple[bytes, List[int], int, Any]: ... + +if sys.version_info >= (3, 3): + def CMSG_LEN(length: int) -> int: ... + def CMSG_SPACE(length: int) -> int: ... + def getdefaulttimeout() -> Optional[float]: ... def setdefaulttimeout(timeout: Optional[float]) -> None: ... +if sys.version_info >= (3, 3): + if sys.platform != "win32": + def sethostname(name: str) -> None: ... + # Windows added these in 3.8, but didn't have them before + if sys.platform != "win32" or sys.version_info >= (3, 8): + def if_nameindex() -> List[Tuple[int, str]]: ... + def if_nametoindex(name: str) -> int: ... + def if_indextoname(index: int) -> str: ... diff --git a/stdlib/@python2/socketserver.pyi b/stdlib/@python2/socketserver.pyi index 4580fff7fe26..f0617e393b7e 100644 --- a/stdlib/@python2/socketserver.pyi +++ b/stdlib/@python2/socketserver.pyi @@ -71,6 +71,8 @@ if sys.platform != "win32": timeout: Optional[float] # undocumented active_children: Optional[List[int]] # undocumented max_children: int # undocumented + if sys.version_info >= (3, 7): + block_on_close: bool def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented def handle_timeout(self) -> None: ... # undocumented def service_actions(self) -> None: ... # undocumented @@ -79,6 +81,8 @@ if sys.platform != "win32": class ThreadingMixIn: daemon_threads: bool + if sys.version_info >= (3, 7): + block_on_close: 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: ... def server_close(self) -> None: ... diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 40bfb7cbb9d9..74caa0e64cf1 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -18,7 +18,10 @@ def TimestampFromTicks(ticks: float) -> Timestamp: ... version_info: Tuple[int, int, int] sqlite_version_info: Tuple[int, int, int] -Binary = buffer +if sys.version_info >= (3,): + Binary = memoryview +else: + Binary = buffer # The remaining definitions are imported from _sqlite3. @@ -64,6 +67,18 @@ version: str def adapt(obj, protocol, alternate): ... def complete_statement(sql: str) -> bool: ... +if sys.version_info >= (3, 7): + def connect( + database: Union[bytes, Text, os.PathLike[Text]], + timeout: float = ..., + detect_types: int = ..., + isolation_level: Optional[str] = ..., + check_same_thread: bool = ..., + factory: Optional[Type[Connection]] = ..., + cached_statements: int = ..., + uri: bool = ..., + ) -> Connection: ... + elif sys.version_info >= (3, 4): def connect( database: Union[bytes, Text], @@ -92,10 +107,11 @@ def enable_shared_cache(enable: int) -> None: ... def register_adapter(__type: Type[_T], __caster: Callable[[_T], Union[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: ... +if sys.version_info < (3, 8): + 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: ... @@ -122,7 +138,10 @@ class Connection(object): 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: ... + if sys.version_info >= (3, 8): + def create_function(self, name: str, narg: int, func: Any, *, deterministic: bool = ...) -> None: ... + else: + def create_function(self, name: str, num_params: int, func: Any) -> None: ... def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ... def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this @@ -142,6 +161,16 @@ class Connection(object): # 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: ... + if sys.version_info >= (3, 7): + def backup( + self, + target: Connection, + *, + pages: int = ..., + progress: Optional[Callable[[int, int, int], object]] = ..., + name: str = ..., + sleep: float = ..., + ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __enter__(self) -> Connection: ... def __exit__(self, t: Optional[type], exc: Optional[BaseException], tb: Optional[Any]) -> None: ... @@ -167,7 +196,10 @@ class Cursor(Iterator[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: ... + if sys.version_info >= (3, 0): + def __next__(self) -> Any: ... + else: + def next(self) -> Any: ... class DataError(DatabaseError): ... class DatabaseError(Error): ... @@ -178,70 +210,73 @@ 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): ... +if sys.version_info >= (3,): + OptimizedUnicode = str +else: + 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: ... @@ -262,7 +297,8 @@ class Row(object): def __lt__(self, other): ... def __ne__(self, other): ... -class Statement(object): - def __init__(self, *args, **kwargs): ... +if sys.version_info < (3, 8): + class Statement(object): + def __init__(self, *args, **kwargs): ... class Warning(Exception): ... diff --git a/stdlib/@python2/sre_compile.pyi b/stdlib/@python2/sre_compile.pyi index 0c48b7c38e18..9b50b75d8c31 100644 --- a/stdlib/@python2/sre_compile.pyi +++ b/stdlib/@python2/sre_compile.pyi @@ -15,8 +15,17 @@ from sre_constants import ( from sre_parse import SubPattern from typing import Any, List, Pattern, Tuple, Type, Union +if sys.version_info >= (3,): + from sre_constants import SRE_FLAG_ASCII as SRE_FLAG_ASCII + MAXCODE: int -STRING_TYPES: Tuple[Type[str], Type[unicode]] -_IsStringType = int +if sys.version_info < (3, 0): + STRING_TYPES: Tuple[Type[str], Type[unicode]] + _IsStringType = int +else: + from sre_constants import _NamedIntConstant + def dis(code: List[_NamedIntConstant]) -> None: ... + _IsStringType = bool + def isstring(obj: Any) -> _IsStringType: ... def compile(p: Union[str, bytes, SubPattern], flags: int = ...) -> Pattern[Any]: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 7d7e3aac9b9a..838211d959e5 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -4,6 +4,9 @@ from _typeshed import StrPath from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Text, Tuple, Type, Union, overload from typing_extensions import Literal +if sys.version_info >= (3, 4): + import enum + _PCTRTT = Tuple[Tuple[str, str], ...] _PCTRTTT = Tuple[_PCTRTT, ...] _PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] @@ -11,7 +14,10 @@ _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] _EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] _PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] -_SC1ArgT = SSLSocket +if sys.version_info >= (3, 5): + _SC1ArgT = Union[SSLSocket, SSLObject] +else: + _SC1ArgT = SSLSocket _SrvnmeCbType = Callable[[_SC1ArgT, Optional[str], SSLSocket], Optional[int]] class SSLError(OSError): @@ -24,7 +30,13 @@ class SSLWantWriteError(SSLError): ... class SSLSyscallError(SSLError): ... class SSLEOFError(SSLError): ... -class CertificateError(ValueError): ... +if sys.version_info >= (3, 7): + class SSLCertVerificationError(SSLError, ValueError): + verify_code: int + verify_message: str + CertificateError = SSLCertVerificationError +else: + class CertificateError(ValueError): ... def wrap_socket( sock: socket.socket, @@ -42,21 +54,40 @@ def create_default_context( purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[Text, bytes, None] = ... ) -> SSLContext: ... -def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: Optional[int] = ..., - check_hostname: bool = ..., - purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., -) -> SSLContext: ... +if sys.version_info >= (3, 7): + def _create_unverified_context( + protocol: int = ..., + *, + cert_reqs: int = ..., + check_hostname: bool = ..., + purpose: Any = ..., + certfile: Optional[str] = ..., + keyfile: Optional[str] = ..., + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[Text, bytes, None] = ..., + ) -> SSLContext: ... + +else: + def _create_unverified_context( + protocol: int = ..., + *, + cert_reqs: Optional[int] = ..., + check_hostname: bool = ..., + purpose: Any = ..., + certfile: Optional[str] = ..., + keyfile: Optional[str] = ..., + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[Text, bytes, None] = ..., + ) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] +if sys.version_info >= (3, 3): + def RAND_bytes(__num: int) -> bytes: ... + def RAND_pseudo_bytes(__num: int) -> Tuple[bytes, bool]: ... + def RAND_status() -> bool: ... def RAND_egd(path: str) -> None: ... def RAND_add(__s: bytes, __entropy: float) -> None: ... @@ -97,17 +128,64 @@ 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 +if sys.version_info >= (3, 6): + PROTOCOL_TLS_CLIENT: int + PROTOCOL_TLS_SERVER: int + +if sys.version_info >= (3, 6): + class Options(enum.IntFlag): + 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_NO_TLSv1_3: int + OP_CIPHER_SERVER_PREFERENCE: int + OP_SINGLE_DH_USE: int + OP_SINGLE_ECDH_USE: int + OP_NO_COMPRESSION: int + OP_NO_TICKET: int + if sys.version_info >= (3, 7): + OP_NO_RENEGOTIATION: int + if sys.version_info >= (3, 8): + OP_ENABLE_MIDDLEBOX_COMPAT: int + OP_ALL: Options + OP_NO_SSLv2: Options + OP_NO_SSLv3: Options + OP_NO_TLSv1: Options + OP_NO_TLSv1_1: Options + OP_NO_TLSv1_2: Options + OP_NO_TLSv1_3: Options + OP_CIPHER_SERVER_PREFERENCE: Options + 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 + if sys.version_info >= (3, 8): + OP_ENABLE_MIDDLEBOX_COMPAT: Options +else: + 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 +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_TLSv1_3: bool HAS_ALPN: bool HAS_ECDH: bool HAS_SNI: bool @@ -152,35 +230,47 @@ class _ASN1Object(NamedTuple): longname: str oid: str -class Purpose(_ASN1Object): - SERVER_AUTH: ClassVar[Purpose] - CLIENT_AUTH: ClassVar[Purpose] +if sys.version_info >= (3, 4): + class Purpose(_ASN1Object, enum.Enum): + SERVER_AUTH: _ASN1Object + CLIENT_AUTH: _ASN1Object + +else: + class Purpose(_ASN1Object): + SERVER_AUTH: ClassVar[Purpose] + CLIENT_AUTH: ClassVar[Purpose] class SSLSocket(socket.socket): context: SSLContext server_side: bool server_hostname: Optional[str] - def __init__( - self, - sock: Optional[socket.socket] = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - server_side: bool = ..., - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: Optional[str] = ..., - do_handshake_on_connect: bool = ..., - family: int = ..., - type: int = ..., - proto: int = ..., - fileno: Optional[int] = ..., - suppress_ragged_eofs: bool = ..., - npn_protocols: Optional[Iterable[str]] = ..., - ciphers: Optional[str] = ..., - server_hostname: Optional[str] = ..., - _context: Optional[SSLContext] = ..., - _session: Optional[Any] = ..., - ) -> None: ... + if sys.version_info >= (3, 6): + session: Optional[SSLSession] + session_reused: Optional[bool] + if sys.version_info < (3, 7): + def __init__( + self, + sock: Optional[socket.socket] = ..., + keyfile: Optional[str] = ..., + certfile: Optional[str] = ..., + server_side: bool = ..., + cert_reqs: int = ..., + ssl_version: int = ..., + ca_certs: Optional[str] = ..., + do_handshake_on_connect: bool = ..., + family: int = ..., + type: int = ..., + proto: int = ..., + fileno: Optional[int] = ..., + suppress_ragged_eofs: bool = ..., + npn_protocols: Optional[Iterable[str]] = ..., + ciphers: Optional[str] = ..., + server_hostname: Optional[str] = ..., + _context: Optional[SSLContext] = ..., + _session: Optional[Any] = ..., + ) -> None: ... + else: + def __init__(self, *args: Any, **kwargs: Any) -> None: ... def connect(self, addr: Union[socket._Address, bytes]) -> None: ... def connect_ex(self, addr: Union[socket._Address, bytes]) -> int: ... def recv(self, buflen: int = ..., flags: int = ...) -> bytes: ... @@ -203,6 +293,8 @@ class SSLSocket(socket.socket): @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def cipher(self) -> Optional[Tuple[str, str, int]]: ... + if sys.version_info >= (3, 5): + def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... def compression(self) -> Optional[str]: ... def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... def selected_alpn_protocol(self) -> Optional[str]: ... @@ -211,15 +303,39 @@ class SSLSocket(socket.socket): def unwrap(self) -> socket.socket: ... def version(self) -> Optional[str]: ... def pending(self) -> int: ... + 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 SSLContext: check_hostname: bool - options: int - def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> SSLContext: ... + if sys.version_info >= (3, 6): + options: Options + else: + options: int + if sys.version_info >= (3, 8): + post_handshake_auth: bool + if sys.version_info >= (3, 5): + def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> SSLContext: ... + else: + def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> SSLContext: ... @property def protocol(self) -> int: ... verify_flags: int verify_mode: int - def __init__(self, protocol: int) -> None: ... + if sys.version_info >= (3, 5): + def __init__(self, protocol: int = ...) -> None: ... + else: + def __init__(self, protocol: int) -> None: ... def cert_store_stats(self) -> Dict[str, int]: ... def load_cert_chain( self, certfile: StrPath, keyfile: Optional[StrPath] = ..., password: Optional[_PasswordType] = ... @@ -232,23 +348,113 @@ class SSLContext: def set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... + if sys.version_info >= (3, 7): + sni_callback: Optional[Callable[[SSLObject, str, SSLContext], Union[None, int]]] + sslobject_class: Type[SSLObject] def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> None: ... + if sys.version_info >= (3, 7): + def set_servername_callback(self, server_name_callback: Optional[_SrvnmeCbType]) -> None: ... + else: + def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> 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: Optional[str] = ..., - ) -> SSLSocket: ... + if sys.version_info >= (3, 6): + def wrap_socket( + self, + sock: socket.socket, + server_side: bool = ..., + do_handshake_on_connect: bool = ..., + suppress_ragged_eofs: bool = ..., + server_hostname: Optional[str] = ..., + session: Optional[SSLSession] = ..., + ) -> SSLSocket: ... + else: + def wrap_socket( + self, + sock: socket.socket, + server_side: bool = ..., + do_handshake_on_connect: bool = ..., + suppress_ragged_eofs: bool = ..., + server_hostname: Optional[str] = ..., + ) -> SSLSocket: ... + if sys.version_info >= (3, 6): + def wrap_bio( + self, + incoming: MemoryBIO, + outgoing: MemoryBIO, + server_side: bool = ..., + server_hostname: Optional[str] = ..., + session: Optional[SSLSession] = ..., + ) -> SSLObject: ... elif sys.version_info >= (3, 5): def wrap_bio( self, incoming: MemoryBIO, outgoing: MemoryBIO, server_side: bool = ..., server_hostname: Optional[str] = ... ) -> SSLObject: ... def session_stats(self) -> Dict[str, int]: ... + if sys.version_info >= (3, 7): + hostname_checks_common_name: bool + maximum_version: TLSVersion + minimum_version: TLSVersion + +if sys.version_info >= (3, 5): + class SSLObject: + context: SSLContext + server_side: bool + server_hostname: Optional[str] + if sys.version_info >= (3, 6): + session: Optional[SSLSession] + session_reused: bool + if sys.version_info >= (3, 7): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + else: + def __init__( + self, sslobj: Any, owner: Optional[Union[SSLSocket, SSLObject]] = ..., session: Optional[Any] = ... + ) -> None: ... + def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... + def write(self, data: bytes) -> int: ... + @overload + def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ... + @overload + def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ... + @overload + def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... + def selected_alpn_protocol(self) -> Optional[str]: ... + def selected_npn_protocol(self) -> Optional[str]: ... + def cipher(self) -> Optional[Tuple[str, str, int]]: ... + def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... + def compression(self) -> Optional[str]: ... + def pending(self) -> int: ... + def do_handshake(self) -> None: ... + def unwrap(self) -> None: ... + def version(self) -> Optional[str]: ... + def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... + if sys.version_info >= (3, 8): + def verify_client_post_handshake(self) -> None: ... + class MemoryBIO: + pending: int + eof: bool + def read(self, __size: int = ...) -> bytes: ... + def write(self, __buf: bytes) -> int: ... + def write_eof(self) -> None: ... + +if sys.version_info >= (3, 6): + class SSLSession: + id: bytes + time: int + timeout: int + ticket_lifetime_hint: int + has_ticket: bool + class VerifyFlags(enum.IntFlag): + VERIFY_DEFAULT: int + VERIFY_CRL_CHECK_LEAF: int + VERIFY_CRL_CHECK_CHAIN: int + VERIFY_X509_STRICT: int + VERIFY_X509_TRUSTED_FIRST: int + class VerifyMode(enum.IntEnum): + CERT_NONE: int + CERT_OPTIONAL: int + CERT_REQUIRED: int + # TODO below documented in cpython but not in docs.python.org # taken from python 3.4 SSL_ERROR_EOF: int @@ -263,7 +469,8 @@ SSL_ERROR_ZERO_RETURN: int def get_protocol_name(protocol_code: int) -> str: ... -AF_INET: int +if sys.version_info < (3, 9): + AF_INET: int PEM_FOOTER: str PEM_HEADER: str SOCK_STREAM: int diff --git a/stdlib/@python2/struct.pyi b/stdlib/@python2/struct.pyi index f100e6aa0c81..096f8b7b85ca 100644 --- a/stdlib/@python2/struct.pyi +++ b/stdlib/@python2/struct.pyi @@ -6,21 +6,33 @@ from typing import Any, Iterator, Text, Tuple, Union class error(Exception): ... _FmtType = Union[bytes, Text] -_BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] -_WriteBufferType = Union[array[Any], bytearray, buffer, memoryview, mmap] +if sys.version_info >= (3,): + _BufferType = Union[array[int], bytes, bytearray, memoryview, mmap] + _WriteBufferType = Union[array[Any], bytearray, memoryview, mmap] +else: + _BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] + _WriteBufferType = Union[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, ...]: ... +if sys.version_info >= (3, 4): + def iter_unpack(__format: _FmtType, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... + def calcsize(__format: _FmtType) -> int: ... class Struct: - format: bytes + if sys.version_info >= (3, 7): + format: str + else: + 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, ...]: ... + if sys.version_info >= (3, 4): + def iter_unpack(self, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index 020fac474df0..175068861ee9 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -20,10 +20,23 @@ 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] +if sys.version_info >= (3, 0): + class _sunau_params(NamedTuple): + nchannels: int + sampwidth: int + framerate: int + nframes: int + comptype: str + compname: str + +else: + _sunau_params = Tuple[int, int, int, int, str, str] class Au_read: def __init__(self, f: _File) -> None: ... + if sys.version_info >= (3, 3): + def __enter__(self) -> Au_read: ... + def __exit__(self, *args: Any) -> None: ... def getfp(self) -> Optional[IO[bytes]]: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -42,6 +55,9 @@ class Au_read: class Au_write: def __init__(self, f: _File) -> None: ... + if sys.version_info >= (3, 3): + def __enter__(self) -> Au_write: ... + def __exit__(self, *args: Any) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... @@ -64,4 +80,5 @@ class Au_write: # Returns a Au_read if mode is rb and Au_write if mode is wb def open(f: _File, mode: Optional[str] = ...) -> Any: ... -openfp = open +if sys.version_info < (3, 9): + openfp = open diff --git a/stdlib/@python2/symtable.pyi b/stdlib/@python2/symtable.pyi index 8417f5948660..b528481bf510 100644 --- a/stdlib/@python2/symtable.pyi +++ b/stdlib/@python2/symtable.pyi @@ -13,7 +13,8 @@ class SymbolTable(object): def is_nested(self) -> bool: ... def has_children(self) -> bool: ... def has_exec(self) -> bool: ... - def has_import_star(self) -> bool: ... + if sys.version_info < (3, 0): + def has_import_star(self) -> bool: ... def get_identifiers(self) -> Sequence[str]: ... def lookup(self, name: str) -> Symbol: ... def get_symbols(self) -> List[Symbol]: ... @@ -29,13 +30,20 @@ class Class(SymbolTable): def get_methods(self) -> Tuple[str, ...]: ... class Symbol(object): - def __init__(self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ...) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ..., *, module_scope: bool = ... + ) -> None: ... + else: + def __init__(self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ...) -> 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: ... + if sys.version_info >= (3, 6): + def is_annotated(self) -> bool: ... def is_free(self) -> bool: ... def is_imported(self) -> bool: ... def is_assigned(self) -> bool: ... diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index f970412f2a4d..afb88161d68b 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -46,10 +46,14 @@ GNU_TYPES: Tuple[bytes, ...] PAX_FIELDS: Tuple[str, ...] PAX_NUMBER_FIELDS: Dict[str, type] +if sys.version_info >= (3,): + PAX_NAME_FIELDS: Set[str] + ENCODING: str -TAR_PLAIN: int -TAR_GZIPPED: int +if sys.version_info < (3,): + TAR_PLAIN: int + TAR_GZIPPED: int def open( name: Optional[AnyPath] = ..., @@ -88,7 +92,8 @@ class TarFile(Iterable[TarInfo]): debug: Optional[int] errorlevel: Optional[int] offset: int # undocumented - posix: bool + if sys.version_info < (3,): + posix: bool def __init__( self, name: Optional[AnyPath] = ..., @@ -199,10 +204,23 @@ class TarFile(Iterable[TarInfo]): def getmember(self, name: str) -> TarInfo: ... def getmembers(self) -> List[TarInfo]: ... def getnames(self) -> List[str]: ... - def list(self, verbose: bool = ...) -> None: ... + if sys.version_info >= (3, 5): + def list(self, verbose: bool = ..., *, members: Optional[List[TarInfo]] = ...) -> None: ... + else: + def list(self, verbose: bool = ...) -> None: ... def next(self) -> Optional[TarInfo]: ... - def extractall(self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... - def extract(self, member: Union[str, TarInfo], path: AnyPath = ...) -> None: ... + if sys.version_info >= (3, 5): + def extractall( + self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ... + ) -> None: ... + else: + def extractall(self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... + if sys.version_info >= (3, 5): + def extract( + self, member: Union[str, TarInfo], path: AnyPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... + ) -> None: ... + else: + def extract(self, member: Union[str, TarInfo], path: AnyPath = ...) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... def makedir(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makefile(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented @@ -210,9 +228,21 @@ class TarFile(Iterable[TarInfo]): def makefifo(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makedev(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makelink(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented + if sys.version_info >= (3, 5): + def chown(self, tarinfo: TarInfo, targetpath: AnyPath, numeric_owner: bool) -> None: ... # undocumented + else: + def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def chmod(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def utime(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented + if sys.version_info >= (3, 7): + def add( + self, + name: StrPath, + arcname: Optional[StrPath] = ..., + recursive: bool = ..., + *, + filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., + ) -> None: ... elif sys.version_info >= (3,): def add( self, @@ -238,12 +268,18 @@ class TarFile(Iterable[TarInfo]): ) -> TarInfo: ... def close(self) -> None: ... -def is_tarfile(name: AnyPath) -> bool: ... +if sys.version_info >= (3, 9): + def is_tarfile(name: Union[AnyPath, IO[bytes]]) -> bool: ... + +else: + def is_tarfile(name: AnyPath) -> bool: ... -def filemode(mode: int) -> str: ... # undocumented +if sys.version_info < (3, 8): + def filemode(mode: int) -> str: ... # undocumented -class TarFileCompat: - def __init__(self, filename: str, mode: str = ..., compression: int = ...) -> None: ... +if sys.version_info < (3,): + class TarFileCompat: + def __init__(self, filename: str, mode: str = ..., compression: int = ...) -> None: ... class TarError(Exception): ... class ReadError(TarError): ... @@ -273,8 +309,12 @@ class TarInfo: gname: str pax_headers: Mapping[str, str] def __init__(self, name: str = ...) -> None: ... - @classmethod - def frombuf(cls, buf: bytes) -> TarInfo: ... + if sys.version_info >= (3,): + @classmethod + def frombuf(cls, buf: bytes, encoding: str, errors: str) -> TarInfo: ... + else: + @classmethod + def frombuf(cls, buf: bytes) -> TarInfo: ... @classmethod def fromtarfile(cls, tarfile: TarFile) -> TarInfo: ... @property diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index d59efc994be8..31fd3eef81cd 100644 --- a/stdlib/@python2/telnetlib.pyi +++ b/stdlib/@python2/telnetlib.pyi @@ -110,3 +110,6 @@ class Telnet: def expect( self, list: Sequence[Union[Pattern[bytes], bytes]], timeout: Optional[float] = ... ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... + if sys.version_info >= (3, 6): + def __enter__(self) -> Telnet: ... + def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index f8e1fc46b10a..af0b0af89d9b 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -12,17 +12,30 @@ __all__: List[str] def active_count() -> int: ... -def activeCount() -> int: ... +if sys.version_info < (3,): + def activeCount() -> int: ... def current_thread() -> Thread: ... def currentThread() -> Thread: ... +if sys.version_info >= (3,): + def get_ident() -> int: ... + def enumerate() -> List[Thread]: ... +if sys.version_info >= (3, 4): + def main_thread() -> Thread: ... + +if sys.version_info >= (3, 8): + from _thread import get_native_id as get_native_id + def settrace(func: _TF) -> None: ... def setprofile(func: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... +if sys.version_info >= (3,): + TIMEOUT_MAX: float + class ThreadError(Exception): ... class local(object): @@ -34,21 +47,37 @@ class Thread: name: str ident: Optional[int] daemon: bool - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[Text] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., - ) -> None: ... + if sys.version_info >= (3,): + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[str] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[str, Any]] = ..., + *, + daemon: Optional[bool] = ..., + ) -> None: ... + else: + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[Text] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[Text, Any]] = ..., + ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: Text) -> None: ... + if sys.version_info >= (3, 8): + @property + def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - def isAlive(self) -> bool: ... + if sys.version_info < (3, 9): + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -60,7 +89,10 @@ class Lock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -70,7 +102,10 @@ class _RLock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock @@ -81,9 +116,14 @@ class Condition: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... + if sys.version_info >= (3,): + def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -93,23 +133,56 @@ class Semaphore: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - def release(self) -> None: ... + if sys.version_info >= (3,): + def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... + def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... + else: + def acquire(self, blocking: bool = ...) -> bool: ... + def __enter__(self, blocking: bool = ...) -> bool: ... + if sys.version_info >= (3, 9): + def release(self, n: int = ...) -> None: ... + else: + def release(self) -> None: ... class BoundedSemaphore(Semaphore): ... class Event: def __init__(self) -> None: ... def is_set(self) -> bool: ... - def isSet(self) -> bool: ... + if sys.version_info < (3,): + def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... +if sys.version_info >= (3, 8): + from _thread import _excepthook, _ExceptHookArgs + + excepthook = _excepthook + ExceptHookArgs = _ExceptHookArgs + class Timer(Thread): - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... + if sys.version_info >= (3,): + def __init__( + self, + interval: float, + function: Callable[..., Any], + args: Optional[Iterable[Any]] = ..., + kwargs: Optional[Mapping[str, Any]] = ..., + ) -> None: ... + else: + def __init__( + self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... + ) -> None: ... def cancel(self) -> None: ... +if sys.version_info >= (3,): + class Barrier: + parties: int + n_waiting: int + broken: bool + def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... + def wait(self, timeout: Optional[float] = ...) -> int: ... + def reset(self) -> None: ... + def abort(self) -> None: ... + class BrokenBarrierError(RuntimeError): ... diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index 37a088682537..6e926c68dc39 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -1,14 +1,40 @@ import sys from typing import Any, NamedTuple, Optional, Tuple, Union +if sys.version_info >= (3, 3): + from types import SimpleNamespace + _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] -accept2dyear: bool +if sys.version_info < (3, 3): + accept2dyear: bool altzone: int 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.version_info >= (3, 3) and sys.platform != "win32": + CLOCK_MONOTONIC: int + CLOCK_MONOTONIC_RAW: int + CLOCK_PROCESS_CPUTIME_ID: int + CLOCK_REALTIME: int + CLOCK_THREAD_CPUTIME_ID: int + if sys.platform != "linux" and sys.platform != "darwin": + CLOCK_HIGHRES: int # Solaris only + +if sys.version_info >= (3, 8) and sys.platform == "darwin": + CLOCK_UPTIME_RAW: int + +if sys.version_info >= (3, 9) and sys.platform == "linux": + CLOCK_TAI: int + class _struct_time(NamedTuple): tm_year: int tm_mon: int @@ -26,13 +52,41 @@ class _struct_time(NamedTuple): @property def n_unnamed_fields(self) -> int: ... -class struct_time(_struct_time): - def __init__(self, o: _TimeTuple, _arg: Any = ...) -> None: ... - def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ... +if sys.version_info >= (3, 3): + class struct_time(_struct_time): + def __init__( + self, + o: Union[ + Tuple[int, int, int, int, int, int, int, int, int], + Tuple[int, int, int, int, int, int, int, int, int, str], + Tuple[int, int, int, int, int, int, int, int, int, str, int], + ], + _arg: Any = ..., + ) -> None: ... + def __new__( + cls, + o: Union[ + Tuple[int, int, int, int, int, int, int, int, int], + Tuple[int, int, int, int, int, int, int, int, int, str], + Tuple[int, int, int, int, int, int, int, int, int, str, int], + ], + _arg: Any = ..., + ) -> struct_time: ... + if sys.version_info >= (3, 6) or sys.platform != "win32": + @property + def tm_zone(self) -> str: ... + @property + def tm_gmtoff(self) -> int: ... + +else: + 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: Union[_TimeTuple, struct_time] = ...) -> str: ... -def clock() -> float: ... +if sys.version_info < (3, 8): + def clock() -> float: ... def ctime(secs: Optional[float] = ...) -> str: ... def gmtime(secs: Optional[float] = ...) -> struct_time: ... @@ -46,3 +100,23 @@ def time() -> float: ... if sys.platform != "win32": def tzset() -> None: ... # Unix only +if sys.version_info >= (3, 3): + def get_clock_info(name: str) -> SimpleNamespace: ... + def monotonic() -> float: ... + def perf_counter() -> float: ... + def process_time() -> float: ... + if sys.platform != "win32": + def clock_getres(clk_id: int) -> float: ... # Unix only + 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: ... + 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/stdlib/@python2/timeit.pyi b/stdlib/@python2/timeit.pyi index 89ba33e31ae1..8de9af28d7ad 100644 --- a/stdlib/@python2/timeit.pyi +++ b/stdlib/@python2/timeit.pyi @@ -8,14 +8,36 @@ _stmt = Union[_str, Callable[[], Any]] default_timer: _Timer class Timer: - def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> None: ... + if sys.version_info >= (3, 5): + def __init__( + self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., globals: Optional[Dict[str, Any]] = ... + ) -> None: ... + else: + def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> None: ... def print_exc(self, file: Optional[IO[str]] = ...) -> 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]: ... + if sys.version_info >= (3, 6): + def autorange(self, callback: Optional[Callable[[int, float], Any]] = ...) -> Tuple[int, float]: ... + +if sys.version_info >= (3, 5): + def timeit( + stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., number: int = ..., globals: Optional[Dict[str, Any]] = ... + ) -> float: ... + def repeat( + stmt: _stmt = ..., + setup: _stmt = ..., + timer: _Timer = ..., + repeat: int = ..., + number: int = ..., + globals: Optional[Dict[str, Any]] = ..., + ) -> List[float]: ... + +else: + 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] diff --git a/stdlib/@python2/token.pyi b/stdlib/@python2/token.pyi index 8a469a87c639..a806a466b8ea 100644 --- a/stdlib/@python2/token.pyi +++ b/stdlib/@python2/token.pyi @@ -26,7 +26,8 @@ GREATER: int EQUAL: int DOT: int PERCENT: int -BACKQUOTE: int +if sys.version_info < (3,): + BACKQUOTE: int LBRACE: int RBRACE: int EQEQUAL: int @@ -52,11 +53,33 @@ DOUBLESTAREQUAL: int DOUBLESLASH: int DOUBLESLASHEQUAL: int AT: int +if sys.version_info >= (3,): + RARROW: int + ELLIPSIS: int +if sys.version_info >= (3, 5): + ATEQUAL: int + if sys.version_info < (3, 7): + # These were removed in Python 3.7 but added back in Python 3.8 + AWAIT: int + ASYNC: int +if sys.version_info >= (3, 8): + AWAIT: int + ASYNC: int OP: int 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 +if sys.version_info >= (3, 8): + TYPE_COMMENT: int + TYPE_IGNORE: int + COLONEQUAL: int + EXACT_TOKEN_TYPES: Dict[str, int] + def ISTERMINAL(x: int) -> bool: ... def ISNONTERMINAL(x: int) -> bool: ... def ISEOF(x: int) -> bool: ... diff --git a/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 2f31d86cca9f..3c24ee21bee4 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -7,6 +7,16 @@ _PT = Tuple[str, int, str, Optional[str]] def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +if sys.version_info >= (3, 10): + def print_exception( + __exc: Optional[Type[BaseException]], + value: Optional[BaseException] = ..., + tb: Optional[TracebackType] = ..., + limit: Optional[int] = ..., + file: Optional[IO[str]] = ..., + chain: bool = ..., + ) -> None: ... + elif sys.version_info >= (3,): def print_exception( etype: Optional[Type[BaseException]], @@ -26,16 +36,42 @@ else: file: Optional[IO[str]] = ..., ) -> None: ... -def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +if sys.version_info >= (3,): + def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... + def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... + +else: + def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... + def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... def print_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... -def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... -def format_list(extracted_list: List[_PT]) -> List[str]: ... +if sys.version_info >= (3, 5): + def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> StackSummary: ... + def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> StackSummary: ... + def format_list(extracted_list: List[FrameSummary]) -> List[str]: ... + # undocumented + def print_list(extracted_list: List[FrameSummary], file: Optional[SupportsWrite[str]] = ...) -> None: ... -def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... +else: + def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... + def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... + def format_list(extracted_list: List[_PT]) -> List[str]: ... + +if sys.version_info >= (3, 10): + def format_exception_only(__exc: Optional[Type[BaseException]], value: Optional[BaseException] = ...) -> List[str]: ... + +else: + def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... + +if sys.version_info >= (3, 10): + def format_exception( + __exc: Optional[Type[BaseException]], + value: Optional[BaseException] = ..., + tb: Optional[TracebackType] = ..., + limit: Optional[int] = ..., + chain: bool = ..., + ) -> List[str]: ... elif sys.version_info >= (3,): def format_exception( @@ -54,10 +90,108 @@ else: limit: Optional[int] = ..., ) -> List[str]: ... -def format_exc(limit: Optional[int] = ...) -> str: ... +if sys.version_info >= (3,): + def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... + +else: + def format_exc(limit: Optional[int] = ...) -> str: ... def format_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ... def format_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[str]: ... -def tb_lineno(tb: TracebackType) -> int: ... +if sys.version_info >= (3, 4): + def clear_frames(tb: TracebackType) -> None: ... + +if sys.version_info >= (3, 5): + def walk_stack(f: Optional[FrameType]) -> Iterator[Tuple[FrameType, int]]: ... + def walk_tb(tb: Optional[TracebackType]) -> Iterator[Tuple[FrameType, int]]: ... + +if sys.version_info < (3,): + def tb_lineno(tb: TracebackType) -> int: ... +if sys.version_info >= (3, 5): + class TracebackException: + __cause__: TracebackException + __context__: TracebackException + __suppress_context__: bool + stack: StackSummary + exc_type: Type[BaseException] + filename: str + lineno: int + text: str + offset: int + msg: str + if sys.version_info >= (3, 10): + def __init__( + self, + exc_type: Type[BaseException], + exc_value: BaseException, + exc_traceback: TracebackType, + *, + limit: Optional[int] = ..., + lookup_lines: bool = ..., + capture_locals: bool = ..., + compact: bool = ..., + _seen: Optional[Set[int]] = ..., + ) -> None: ... + @classmethod + def from_exception( + cls, + exc: BaseException, + *, + limit: Optional[int] = ..., + lookup_lines: bool = ..., + capture_locals: bool = ..., + compact: bool = ..., + ) -> TracebackException: ... + else: + def __init__( + self, + exc_type: Type[BaseException], + exc_value: BaseException, + exc_traceback: TracebackType, + *, + limit: Optional[int] = ..., + lookup_lines: bool = ..., + capture_locals: bool = ..., + _seen: Optional[Set[int]] = ..., + ) -> None: ... + @classmethod + def from_exception( + cls, exc: BaseException, *, limit: Optional[int] = ..., lookup_lines: bool = ..., capture_locals: bool = ... + ) -> TracebackException: ... + def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ... + def format_exception_only(self) -> Generator[str, None, None]: ... + class FrameSummary(Iterable[Any]): + filename: str + lineno: int + name: str + line: str + locals: Optional[Dict[str, str]] + def __init__( + self, + filename: str, + lineno: int, + name: str, + *, + lookup_line: bool = ..., + locals: Optional[Mapping[str, str]] = ..., + line: Optional[str] = ..., + ) -> None: ... + # TODO: more precise typing for __getitem__ and __iter__, + # for a namedtuple-like view on (filename, lineno, name, str). + def __getitem__(self, i: int) -> Any: ... + def __iter__(self) -> Iterator[Any]: ... + class StackSummary(List[FrameSummary]): + @classmethod + def extract( + cls, + frame_gen: Generator[Tuple[FrameType, int], None, None], + *, + limit: Optional[int] = ..., + lookup_lines: bool = ..., + capture_locals: bool = ..., + ) -> StackSummary: ... + @classmethod + def from_list(cls, a_list: List[_PT]) -> StackSummary: ... + def format(self) -> List[str]: ... diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index d2fd7c0708d2..a44b25926968 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -1,9 +1,12 @@ import sys from typing import Any, Callable, Dict, List, Optional, Sequence, Text, Tuple, TypeVar, Union, overload -# TODO: Replace these aliases once we have Python 2 stubs for the Tkinter module. -Canvas = Any -PhotoImage = Any +if sys.version_info >= (3,): + from tkinter import Canvas, PhotoImage +else: + # 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 @@ -29,6 +32,18 @@ class TurtleScreenBase(object): xscale: float = ... yscale: float = ... def __init__(self, cv: Canvas) -> None: ... + if sys.version_info >= (3,): + def mainloop(self) -> None: ... + def textinput(self, title: str, prompt: str) -> Optional[str]: ... + def numinput( + self, + title: str, + prompt: str, + default: Optional[float] = ..., + minval: Optional[float] = ..., + maxval: Optional[float] = ..., + ) -> Optional[float]: ... + class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... @@ -87,6 +102,10 @@ class TurtleScreen(TurtleScreenBase): resetscreen = reset clearscreen = clear addshape = register_shape + if sys.version_info >= (3,): + def onkeypress(self, fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... + onkeyrelease = onkey + class TNavigator(object): START_ORIENTATION: Dict[str, Vec2D] = ... DEFAULT_MODE: str = ... @@ -220,6 +239,19 @@ class RawTurtle(TPen, TNavigator): def shapesize( self, stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ... ) -> None: ... + if sys.version_info >= (3,): + @overload + def shearfactor(self, shear: None = ...) -> float: ... + @overload + def shearfactor(self, shear: float) -> None: ... + # Unsafely overlaps when no arguments are provided + @overload + def shapetransform(self) -> Tuple[float, float, float, float]: ... # type: ignore + @overload + def shapetransform( + self, t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... + ) -> None: ... + def get_shapepoly(self) -> Optional[_PolygonCoords]: ... def settiltangle(self, angle: float) -> None: ... @overload def tiltangle(self, angle: None = ...) -> float: ... @@ -286,6 +318,12 @@ def write_docstringdict(filename: str = ...) -> None: ... # TurtleScreenBase in Python 3.0 def mainloop() -> None: ... +if sys.version_info >= (3,): + def textinput(title: str, prompt: str) -> Optional[str]: ... + def numinput( + title: str, prompt: str, default: Optional[float] = ..., minval: Optional[float] = ..., maxval: Optional[float] = ... + ) -> Optional[float]: ... + # Functions copied from TurtleScreen: def clear() -> None: ... @@ -337,6 +375,10 @@ onscreenclick = onclick resetscreen = reset clearscreen = clear addshape = register_shape +if sys.version_info >= (3,): + def onkeypress(fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... + onkeyrelease = onkey + # Functions copied from _Screen: def setup(width: float = ..., height: float = ..., startx: Optional[int] = ..., starty: Optional[int] = ...) -> None: ... @@ -467,6 +509,20 @@ def shapesize() -> Tuple[float, float, float]: ... # type: ignore @overload def shapesize(stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ...) -> None: ... +if sys.version_info >= (3,): + @overload + def shearfactor(shear: None = ...) -> float: ... + @overload + def shearfactor(shear: float) -> None: ... + # Unsafely overlaps when no arguments are provided + @overload + def shapetransform() -> Tuple[float, float, float, float]: ... # type: ignore + @overload + def shapetransform( + t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... + ) -> None: ... + def get_shapepoly() -> Optional[_PolygonCoords]: ... + def settiltangle(angle: float) -> None: ... @overload def tiltangle(angle: None = ...) -> float: ... diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index e38bcf372a9e..0250866f3eb8 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -55,10 +55,15 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore 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]: ... + if sys.version_info >= (3, 0): + def items(self) -> ItemsView[str, object]: ... + def keys(self) -> KeysView[str]: ... + def values(self) -> ValuesView[object]: ... + else: + 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. @@ -66,6 +71,21 @@ TypedDict: object = ... OrderedDict = _Alias() +if sys.version_info >= (3, 3): + from typing import ChainMap as ChainMap + +if sys.version_info >= (3, 5): + from typing import ( + AsyncContextManager as AsyncContextManager, + AsyncIterable as AsyncIterable, + AsyncIterator as AsyncIterator, + Awaitable as Awaitable, + Coroutine as Coroutine, + ) + +if sys.version_info >= (3, 6): + from typing import AsyncGenerator as AsyncGenerator + def get_type_hints( obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., @@ -73,6 +93,10 @@ def get_type_hints( include_extras: bool = ..., ) -> Dict[str, Any]: ... +if sys.version_info >= (3, 7): + def get_args(tp: Any) -> Tuple[Any, ...]: ... + def get_origin(tp: Any) -> Optional[Any]: ... + Annotated: _SpecialForm = ... _AnnotatedAlias: Any = ... # undocumented @@ -82,24 +106,27 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta): 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__: Optional[Type[Any]] - __covariant__: bool - __contravariant__: bool - def __init__( - self, name: str, *, bound: Union[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 = ... +if sys.version_info >= (3, 10): + from typing import Concatenate as Concatenate, ParamSpec as ParamSpec, TypeAlias as TypeAlias, TypeGuard as TypeGuard +else: + 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__: Optional[Type[Any]] + __covariant__: bool + __contravariant__: bool + def __init__( + self, name: str, *, bound: Union[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/stdlib/@python2/unicodedata.pyi b/stdlib/@python2/unicodedata.pyi index f45ee9a66120..a83d79ff2ed0 100644 --- a/stdlib/@python2/unicodedata.pyi +++ b/stdlib/@python2/unicodedata.pyi @@ -15,6 +15,9 @@ def decomposition(__chr: Text) -> Text: ... def digit(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... def east_asian_width(__chr: Text) -> Text: ... +if sys.version_info >= (3, 8): + def is_normalized(__form: str, __unistr: str) -> bool: ... + def lookup(__name: Union[Text, bytes]) -> Text: ... def mirrored(__chr: Text) -> int: ... def name(__chr: Text, __default: _T = ...) -> Union[Text, _T]: ... diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index d32bf7a4f273..2bb2c2a1c90e 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -5,6 +5,12 @@ _File = Union[Text, BinaryIO] class Error(Exception): ... -def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... +if sys.version_info >= (3, 7): + def encode( + in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ..., *, backtick: bool = ... + ) -> None: ... + +else: + def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... def decode(in_file: _File, out_file: Optional[_File] = ..., mode: Optional[int] = ..., quiet: int = ...) -> None: ... diff --git a/stdlib/@python2/uuid.pyi b/stdlib/@python2/uuid.pyi index 8ce48d1ed988..68b235162210 100644 --- a/stdlib/@python2/uuid.pyi +++ b/stdlib/@python2/uuid.pyi @@ -6,16 +6,38 @@ _Int = int _Bytes = bytes _FieldsType = 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 UUID: - def __init__( - self, - hex: Optional[Text] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., - ) -> None: ... + if sys.version_info >= (3, 7): + def __init__( + self, + hex: Optional[Text] = ..., + bytes: Optional[_Bytes] = ..., + bytes_le: Optional[_Bytes] = ..., + fields: Optional[_FieldsType] = ..., + int: Optional[_Int] = ..., + version: Optional[_Int] = ..., + *, + is_safe: SafeUUID = ..., + ) -> None: ... + @property + def is_safe(self) -> SafeUUID: ... + else: + def __init__( + self, + hex: Optional[Text] = ..., + bytes: Optional[_Bytes] = ..., + bytes_le: Optional[_Bytes] = ..., + fields: Optional[_FieldsType] = ..., + int: Optional[_Int] = ..., + version: Optional[_Int] = ..., + ) -> None: ... @property def bytes(self) -> _Bytes: ... @property @@ -49,22 +71,29 @@ class UUID: @property def version(self) -> Optional[_Int]: ... 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) -> Optional[_Int]: ... - def __cmp__(self, other: Any) -> _Int: ... + if sys.version_info >= (3,): + def __eq__(self, other: Any) -> bool: ... + def __lt__(self, other: Any) -> bool: ... + def __le__(self, other: Any) -> bool: ... + def __gt__(self, other: Any) -> bool: ... + def __ge__(self, other: Any) -> bool: ... + else: + 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) -> Optional[_Int]: ... + def __cmp__(self, other: Any) -> _Int: ... def getnode() -> int: ... def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ... diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index 290700c5ce8f..0e64ec574775 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -31,15 +31,28 @@ class WarningMessage: lineno: int file: Optional[TextIO] line: Optional[str] - def __init__( - self, - message: Union[Warning, str], - category: Type[Warning], - filename: str, - lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., - ) -> None: ... + if sys.version_info >= (3, 6): + source: Optional[Any] + def __init__( + self, + message: Union[Warning, str], + category: Type[Warning], + filename: str, + lineno: int, + file: Optional[TextIO] = ..., + line: Optional[str] = ..., + source: Optional[Any] = ..., + ) -> None: ... + else: + def __init__( + self, + message: Union[Warning, str], + category: Type[Warning], + filename: str, + lineno: int, + file: Optional[TextIO] = ..., + line: Optional[str] = ..., + ) -> None: ... class catch_warnings: @overload diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index 038254666112..d415630427da 100644 --- a/stdlib/@python2/wave.pyi +++ b/stdlib/@python2/wave.pyi @@ -7,10 +7,23 @@ class Error(Exception): ... WAVE_FORMAT_PCM: int -_wave_params = Tuple[int, int, int, int, str, str] +if sys.version_info >= (3, 0): + class _wave_params(NamedTuple): + nchannels: int + sampwidth: int + framerate: int + nframes: int + comptype: str + compname: str + +else: + _wave_params = Tuple[int, int, int, int, str, str] class Wave_read: def __init__(self, f: _File) -> None: ... + if sys.version_info >= (3, 0): + def __enter__(self) -> Wave_read: ... + def __exit__(self, *args: Any) -> None: ... def getfp(self) -> Optional[BinaryIO]: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -29,6 +42,9 @@ class Wave_read: class Wave_write: def __init__(self, f: _File) -> None: ... + if sys.version_info >= (3, 0): + def __enter__(self) -> Wave_write: ... + def __exit__(self, *args: Any) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... @@ -54,4 +70,5 @@ class Wave_write: # Returns a Wave_read if mode is rb and Wave_write if mode is wb def open(f: _File, mode: Optional[str] = ...) -> Any: ... -openfp = open +if sys.version_info < (3, 9): + openfp = open diff --git a/stdlib/@python2/weakref.pyi b/stdlib/@python2/weakref.pyi index a107db5ea323..b43b634d6216 100644 --- a/stdlib/@python2/weakref.pyi +++ b/stdlib/@python2/weakref.pyi @@ -29,7 +29,8 @@ from _weakref import ( ref as ref, ) -from exceptions import ReferenceError as ReferenceError +if sys.version_info < (3, 0): + from exceptions import ReferenceError as ReferenceError _S = TypeVar("_S") _T = TypeVar("_T") @@ -38,6 +39,11 @@ _VT = TypeVar("_VT") ProxyTypes: Tuple[Type[Any], ...] +if sys.version_info >= (3, 4): + class WeakMethod(ref[types.MethodType]): + def __new__(cls, meth: types.MethodType, callback: Optional[Callable[[types.MethodType], Any]] = ...) -> WeakMethod: ... + def __call__(self) -> Optional[types.MethodType]: ... + class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @@ -47,17 +53,24 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): 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: ... + if sys.version_info < (3, 0): + def has_key(self, key: object) -> bool: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... 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]]: ... + if sys.version_info >= (3, 0): + # These are incompatible with Mapping + def keys(self) -> Iterator[_KT]: ... # type: ignore + def values(self) -> Iterator[_VT]: ... # type: ignore + def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore + else: + 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]]: ... @@ -76,17 +89,32 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): 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: ... + if sys.version_info < (3, 0): + def has_key(self, key: object) -> bool: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... 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]]: ... + if sys.version_info >= (3, 0): + # These are incompatible with Mapping + def keys(self) -> Iterator[_KT]: ... # type: ignore + def values(self) -> Iterator[_VT]: ... # type: ignore + def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore + else: + 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]]: ... +if sys.version_info >= (3, 4): + class finalize: + def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... + def __call__(self, _: Any = ...) -> Optional[Any]: ... + def detach(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... + def peek(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... + alive: bool + atexit: bool diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index 1ee0f3c563f2..322ec2764e39 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -3,9 +3,15 @@ from typing import Callable, List, Optional, Sequence, Text, Union class Error(Exception): ... -def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... -) -> None: ... +if sys.version_info >= (3, 7): + def register( + name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., *, preferred: bool = ... + ) -> None: ... + +else: + def register( + name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... + ) -> None: ... def get(using: Optional[Text] = ...) -> BaseBrowser: ... def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... diff --git a/stdlib/@python2/wsgiref/handlers.pyi b/stdlib/@python2/wsgiref/handlers.pyi index ce7ea2d5e961..ff764e434169 100644 --- a/stdlib/@python2/wsgiref/handlers.pyi +++ b/stdlib/@python2/wsgiref/handlers.pyi @@ -11,6 +11,9 @@ _exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Option def format_date_time(timestamp: Optional[float]) -> str: ... # undocumented +if sys.version_info >= (3, 2): + def read_environ() -> Dict[str, str]: ... + class BaseHandler: wsgi_version: Tuple[int, int] # undocumented wsgi_multithread: bool diff --git a/stdlib/@python2/wsgiref/headers.pyi b/stdlib/@python2/wsgiref/headers.pyi index ebdc07053ebf..c3e943200e40 100644 --- a/stdlib/@python2/wsgiref/headers.pyi +++ b/stdlib/@python2/wsgiref/headers.pyi @@ -6,12 +6,16 @@ _HeaderList = List[Tuple[str, str]] tspecials: Pattern[str] # undocumented class Headers: - def __init__(self, headers: _HeaderList) -> None: ... + if sys.version_info < (3, 5): + def __init__(self, headers: _HeaderList) -> None: ... + else: + def __init__(self, headers: Optional[_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) -> Optional[str]: ... - def has_key(self, name: str) -> bool: ... + if sys.version_info < (3,): + def has_key(self, name: str) -> bool: ... def __contains__(self, name: str) -> bool: ... def get_all(self, name: str) -> List[str]: ... @overload @@ -21,5 +25,7 @@ class Headers: def keys(self) -> List[str]: ... def values(self) -> List[str]: ... def items(self) -> _HeaderList: ... + if sys.version_info >= (3,): + def __bytes__(self) -> bytes: ... def setdefault(self, name: str, value: str) -> str: ... def add_header(self, _name: str, _value: Optional[str], **_params: Optional[str]) -> None: ... diff --git a/stdlib/@python2/wsgiref/simple_server.pyi b/stdlib/@python2/wsgiref/simple_server.pyi index c10ac27beaeb..4e0abd7e8e9d 100644 --- a/stdlib/@python2/wsgiref/simple_server.pyi +++ b/stdlib/@python2/wsgiref/simple_server.pyi @@ -4,7 +4,10 @@ from typing import List, Optional, Type, TypeVar, overload from .handlers import SimpleHandler from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment -from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +if sys.version_info >= (3, 0): + from http.server import BaseHTTPRequestHandler, HTTPServer +else: + from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer server_version: str # undocumented sys_version: str # undocumented diff --git a/stdlib/@python2/wsgiref/util.pyi b/stdlib/@python2/wsgiref/util.pyi index b77e9df72f33..1c66bc1fabdf 100644 --- a/stdlib/@python2/wsgiref/util.pyi +++ b/stdlib/@python2/wsgiref/util.pyi @@ -10,7 +10,10 @@ class FileWrapper: def __init__(self, filelike: IO[bytes], blksize: int = ...) -> None: ... def __getitem__(self, key: Any) -> bytes: ... def __iter__(self) -> FileWrapper: ... - def next(self) -> bytes: ... + if sys.version_info >= (3, 0): + def __next__(self) -> bytes: ... + else: + def next(self) -> bytes: ... def guess_scheme(environ: WSGIEnvironment) -> str: ... def application_uri(environ: WSGIEnvironment) -> str: ... diff --git a/stdlib/@python2/wsgiref/validate.pyi b/stdlib/@python2/wsgiref/validate.pyi index cd62d785b701..bc9f0b8c680f 100644 --- a/stdlib/@python2/wsgiref/validate.pyi +++ b/stdlib/@python2/wsgiref/validate.pyi @@ -9,8 +9,12 @@ 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: ... + if sys.version_info >= (3, 0): + def read(self, size: int) -> bytes: ... + def readline(self, size: int = ...) -> bytes: ... + else: + 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: ... @@ -40,6 +44,9 @@ class IteratorWrapper: check_start_response: Optional[bool] def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: Optional[bool]) -> None: ... def __iter__(self) -> IteratorWrapper: ... - def next(self) -> bytes: ... + if sys.version_info >= (3, 0): + def __next__(self) -> bytes: ... + else: + def next(self) -> bytes: ... def close(self) -> None: ... def __del__(self) -> None: ... diff --git a/stdlib/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 47a7227bf621..67e9b1189528 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -17,8 +17,14 @@ class Node(xml.dom.Node): nextSibling: Any previousSibling: Any prefix: Any - def toxml(self, encoding: Optional[Any] = ...): ... - def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ... + if sys.version_info >= (3, 9): + def toxml(self, encoding: Optional[Any] = ..., standalone: Optional[Any] = ...): ... + def toprettyxml( + self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ..., standalone: Optional[Any] = ... + ): ... + else: + def toxml(self, encoding: Optional[Any] = ...): ... + def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ... def hasChildNodes(self) -> bool: ... def insertBefore(self, newChild, refChild): ... def appendChild(self, node): ... @@ -289,7 +295,18 @@ class Document(Node, DocumentLS): 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: Optional[Any] = ... - ) -> None: ... + if sys.version_info >= (3, 9): + def writexml( + self, + writer, + indent: str = ..., + addindent: str = ..., + newl: str = ..., + encoding: Optional[Any] = ..., + standalone: Optional[Any] = ..., + ) -> None: ... + else: + def writexml( + self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ... + ) -> None: ... def renameNode(self, n, namespaceURI: str, name): ... diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 60e006c2601e..4aa0173fa82f 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -13,4 +13,13 @@ def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[ # 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: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... +if sys.version_info >= (3, 9): + def include( + elem: Element, + loader: Optional[Callable[..., Union[str, Element]]] = ..., + base_url: Optional[str] = ..., + max_depth: Optional[int] = ..., + ) -> None: ... + +else: + def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index 1982710f21a7..ca4e3832f37e 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -47,13 +47,47 @@ _parser_input_type = Union[bytes, Text] _str_argument_type = Union[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 +if sys.version_info >= (3,): + # note: in python3, everything comes out as str, yay: + _str_result_type = str +else: + # 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 = Union[AnyPath, FileDescriptor, IO[Any]] +if sys.version_info >= (3, 8): + @overload + def canonicalize( + xml_data: Optional[_parser_input_type] = ..., + *, + out: None = ..., + from_file: Optional[_file_or_filename] = ..., + with_comments: bool = ..., + strip_text: bool = ..., + rewrite_prefixes: bool = ..., + qname_aware_tags: Optional[Iterable[str]] = ..., + qname_aware_attrs: Optional[Iterable[str]] = ..., + exclude_attrs: Optional[Iterable[str]] = ..., + exclude_tags: Optional[Iterable[str]] = ..., + ) -> str: ... + @overload + def canonicalize( + xml_data: Optional[_parser_input_type] = ..., + *, + out: SupportsWrite[str], + from_file: Optional[_file_or_filename] = ..., + with_comments: bool = ..., + strip_text: bool = ..., + rewrite_prefixes: bool = ..., + qname_aware_tags: Optional[Iterable[str]] = ..., + qname_aware_attrs: Optional[Iterable[str]] = ..., + exclude_attrs: Optional[Iterable[str]] = ..., + exclude_tags: Optional[Iterable[str]] = ..., + ) -> None: ... + class Element(MutableSequence[Element]): tag: _str_result_type attrib: Dict[_str_result_type, _str_result_type] @@ -89,7 +123,10 @@ class Element(MutableSequence[Element]): def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ... @overload def get(self, key: _str_argument_type, default: _T) -> Union[_str_result_type, _T]: ... - def insert(self, __index: int, __element: Element) -> None: ... + if sys.version_info >= (3, 2): + def insert(self, __index: int, __subelement: Element) -> None: ... + else: + def insert(self, __index: int, __element: Element) -> None: ... def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... def iterfind( @@ -110,8 +147,9 @@ class Element(MutableSequence[Element]): 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: Optional[_str_argument_type] = ...) -> List[Element]: ... + if sys.version_info < (3, 9): + def getchildren(self) -> List[Element]: ... + def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... def SubElement( parent: Element, @@ -133,7 +171,8 @@ class ElementTree: def getroot(self) -> Element: ... def parse(self, source: _file_or_filename, parser: Optional[XMLParser] = ...) -> Element: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... - def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... + if sys.version_info < (3, 9): + def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... def find( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> Optional[Element]: ... @@ -154,18 +193,92 @@ class ElementTree: def iterfind( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> Generator[Element, None, None]: ... - def write( - self, - file_or_filename: _file_or_filename, - encoding: Optional[str] = ..., - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - method: Optional[str] = ..., - ) -> None: ... + if sys.version_info >= (3, 4): + def write( + self, + file_or_filename: _file_or_filename, + encoding: Optional[str] = ..., + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + method: Optional[str] = ..., + *, + short_empty_elements: bool = ..., + ) -> None: ... + else: + def write( + self, + file_or_filename: _file_or_filename, + encoding: Optional[str] = ..., + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + method: Optional[str] = ..., + ) -> None: ... def write_c14n(self, file: _file_or_filename) -> None: ... def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... +if sys.version_info >= (3, 8): + @overload + def tostring( + element: Element, + encoding: None = ..., + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> bytes: ... + @overload + def tostring( + element: Element, + encoding: Literal["unicode"], + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> str: ... + @overload + def tostring( + element: Element, + encoding: str, + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> Any: ... + @overload + def tostringlist( + element: Element, + encoding: None = ..., + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> List[bytes]: ... + @overload + def tostringlist( + element: Element, + encoding: Literal["unicode"], + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> List[str]: ... + @overload + def tostringlist( + element: Element, + encoding: str, + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> List[Any]: ... + elif sys.version_info >= (3,): @overload def tostring( @@ -196,11 +309,21 @@ else: def dump(elem: Element) -> None: ... +if sys.version_info >= (3, 9): + def indent(tree: Union[Element, ElementTree], space: str = ..., level: int = ...) -> None: ... + def parse(source: _file_or_filename, parser: Optional[XMLParser] = ...) -> ElementTree: ... def iterparse( source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ... ) -> Iterator[Tuple[str, Any]]: ... +if sys.version_info >= (3, 4): + class XMLPullParser: + def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ... + def feed(self, data: bytes) -> None: ... + def close(self) -> None: ... + def read_events(self) -> Iterator[Tuple[str, Element]]: ... + def XML(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Element: ... def XMLID(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ... @@ -227,13 +350,31 @@ class TreeBuilder: def start(self, __tag: _parser_input_type, __attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ... def end(self, __tag: _parser_input_type) -> Element: ... +if sys.version_info >= (3, 8): + class C14NWriterTarget: + def __init__( + self, + write: Callable[[str], Any], + *, + with_comments: bool = ..., + strip_text: bool = ..., + rewrite_prefixes: bool = ..., + qname_aware_tags: Optional[Iterable[str]] = ..., + qname_aware_attrs: Optional[Iterable[str]] = ..., + exclude_attrs: Optional[Iterable[str]] = ..., + exclude_tags: Optional[Iterable[str]] = ..., + ) -> None: ... + class XMLParser: parser: Any target: Any # TODO-what is entity used for??? entity: Any version: str - def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> None: ... - def doctype(self, __name: str, __pubid: str, __system: str) -> None: ... + if sys.version_info >= (3, 8): + def __init__(self, *, target: Any = ..., encoding: Optional[str] = ...) -> None: ... + else: + def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> 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/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index 086f1c8e4580..a95fde106535 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -22,7 +22,11 @@ class SAXReaderNotAvailable(SAXNotSupportedException): ... default_parser_list: List[str] -def make_parser(parser_list: List[str] = ...) -> XMLReader: ... +if sys.version_info >= (3, 8): + def make_parser(parser_list: Iterable[str] = ...) -> XMLReader: ... + +else: + def make_parser(parser_list: List[str] = ...) -> XMLReader: ... def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... def parseString(string: Union[bytes, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... diff --git a/stdlib/@python2/xml/sax/saxutils.pyi b/stdlib/@python2/xml/sax/saxutils.pyi index 17b5d278ae59..8ae2b80d2a26 100644 --- a/stdlib/@python2/xml/sax/saxutils.pyi +++ b/stdlib/@python2/xml/sax/saxutils.pyi @@ -10,11 +10,19 @@ 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: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., - encoding: Text = ..., - ) -> None: ... + if sys.version_info >= (3, 0): + def __init__( + self, + out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., + encoding: str = ..., + short_empty_elements: bool = ..., + ) -> None: ... + else: + def __init__( + self, + out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., + encoding: Text = ..., + ) -> None: ... def startDocument(self): ... def endDocument(self): ... def startPrefixMapping(self, prefix, uri): ... diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index 4bf98e2c500e..91727aa540fb 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -23,7 +23,11 @@ from typing import ( _SZI = Union[Text, ZipInfo] _DT = Tuple[int, int, int, int, int, int] -class BadZipfile(Exception): ... +if sys.version_info >= (3,): + class BadZipFile(Exception): ... + BadZipfile = BadZipFile +else: + class BadZipfile(Exception): ... error = BadZipfile @@ -33,19 +37,28 @@ class ZipExtFile(io.BufferedIOBase): MAX_N: int = ... MIN_READ_SIZE: int = ... - PATTERN: Pattern[str] = ... + if sys.version_info < (3, 6): + PATTERN: Pattern[str] = ... + + if sys.version_info >= (3, 7): + MAX_SEEK_READ: int = ... newlines: Optional[List[bytes]] mode: str name: str - def __init__( - self, - fileobj: IO[bytes], - mode: str, - zipinfo: ZipInfo, - decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., - close_fileobj: bool = ..., - ) -> None: ... + if sys.version_info >= (3, 7): + def __init__( + self, fileobj: IO[bytes], mode: str, zipinfo: ZipInfo, pwd: Optional[bytes] = ..., close_fileobj: bool = ... + ) -> None: ... + else: + def __init__( + self, + fileobj: IO[bytes], + mode: str, + zipinfo: ZipInfo, + decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., + close_fileobj: bool = ..., + ) -> None: ... def read(self, n: Optional[int] = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... # type: ignore def __repr__(self) -> str: ... @@ -63,6 +76,17 @@ class ZipFile: fp: Optional[IO[bytes]] NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented + if sys.version_info >= (3, 8): + def __init__( + self, + file: Union[StrPath, IO[bytes]], + mode: str = ..., + compression: int = ..., + allowZip64: bool = ..., + compresslevel: Optional[int] = ..., + *, + strict_timestamps: bool = ..., + ) -> None: ... elif sys.version_info >= (3, 7): def __init__( self, @@ -89,18 +113,49 @@ class ZipFile: def extractall( self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ... ) -> None: ... - def printdir(self) -> None: ... + if sys.version_info >= (3,): + def printdir(self, file: Optional[_Writer] = ...) -> None: ... + else: + def printdir(self) -> None: ... def setpassword(self, pwd: bytes) -> None: ... def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ... def testzip(self) -> Optional[str]: ... - def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... + if sys.version_info >= (3, 7): + def write( + self, + filename: StrPath, + arcname: Optional[StrPath] = ..., + compress_type: Optional[int] = ..., + compresslevel: Optional[int] = ..., + ) -> None: ... + else: + def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... + if sys.version_info >= (3, 7): + def writestr( + self, + zinfo_or_arcname: _SZI, + data: Union[bytes, str], + compress_type: Optional[int] = ..., + compresslevel: Optional[int] = ..., + ) -> None: ... elif sys.version_info >= (3,): def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ... else: def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ... class PyZipFile(ZipFile): - def writepy(self, pathname: Text, basename: Text = ...) -> None: ... + if sys.version_info >= (3,): + def __init__( + self, + file: Union[str, IO[bytes]], + mode: str = ..., + compression: int = ..., + allowZip64: bool = ..., + optimize: int = ..., + ) -> None: ... + def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ... + else: + def writepy(self, pathname: Text, basename: Text = ...) -> None: ... class ZipInfo: filename: Text @@ -121,14 +176,47 @@ class ZipInfo: compress_size: int file_size: int def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ... + if sys.version_info >= (3, 8): + @classmethod + def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ... elif sys.version_info >= (3, 6): @classmethod def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ...) -> ZipInfo: ... + if sys.version_info >= (3, 6): + def is_dir(self) -> bool: ... def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ... class _PathOpenProtocol(Protocol): def __call__(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... +if sys.version_info >= (3, 8): + class Path: + @property + def name(self) -> str: ... + @property + def parent(self) -> Path: ... # undocumented + def __init__(self, root: Union[ZipFile, StrPath, IO[bytes]], at: str = ...) -> None: ... + if sys.version_info >= (3, 9): + def open(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... + else: + @property + def open(self) -> _PathOpenProtocol: ... + def iterdir(self) -> Iterator[Path]: ... + def is_dir(self) -> bool: ... + def is_file(self) -> bool: ... + def exists(self) -> bool: ... + def read_text( + self, + encoding: Optional[str] = ..., + errors: Optional[str] = ..., + newline: Optional[str] = ..., + line_buffering: bool = ..., + write_through: bool = ..., + ) -> str: ... + def read_bytes(self) -> bytes: ... + def joinpath(self, add: StrPath) -> Path: ... # undocumented + def __truediv__(self, add: StrPath) -> Path: ... + def is_zipfile(filename: Union[StrPath, IO[bytes]]) -> bool: ... ZIP_STORED: int @@ -136,3 +224,6 @@ ZIP_DEFLATED: int ZIP64_LIMIT: int ZIP_FILECOUNT_LIMIT: int ZIP_MAX_COMMENT: int +if sys.version_info >= (3, 3): + ZIP_BZIP2: int + ZIP_LZMA: int diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index cf348c6554b1..0d1a330942d4 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -3,16 +3,28 @@ import sys from types import CodeType, ModuleType from typing import Any, List, Optional, Tuple, Union +if sys.version_info >= (3, 7): + from importlib.abc import ResourceReader + class ZipImportError(ImportError): ... class zipimporter(object): archive: str prefix: str - def __init__(self, path: Union[str, bytes]) -> None: ... + if sys.version_info >= (3, 6): + def __init__(self, path: Union[str, bytes, os.PathLike[Any]]) -> None: ... + else: + def __init__(self, path: Union[str, bytes]) -> None: ... + if sys.version_info >= (3,): + def find_loader( + self, fullname: str, path: Optional[str] = ... + ) -> Tuple[Optional[zipimporter], List[str]]: ... # undocumented def find_module(self, fullname: str, path: Optional[str] = ...) -> Optional[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) -> Optional[ResourceReader]: ... # undocumented def get_source(self, fullname: str) -> Optional[str]: ... def is_package(self, fullname: str) -> bool: ... def load_module(self, fullname: str) -> ModuleType: ... diff --git a/stdlib/@python2/zlib.pyi b/stdlib/@python2/zlib.pyi index 2eaa418909ec..81a9f87ce42e 100644 --- a/stdlib/@python2/zlib.pyi +++ b/stdlib/@python2/zlib.pyi @@ -18,6 +18,10 @@ Z_HUFFMAN_ONLY: int Z_NO_FLUSH: int Z_RLE: int Z_SYNC_FLUSH: int +if sys.version_info >= (3,): + DEF_BUF_SIZE: int + ZLIB_RUNTIME_VERSION: str + class error(Exception): ... class _Compress: @@ -28,6 +32,8 @@ class _Compress: class _Decompress: unused_data: bytes unconsumed_tail: bytes + if sys.version_info >= (3,): + eof: bool def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... def flush(self, length: int = ...) -> bytes: ... def copy(self) -> _Decompress: ... @@ -35,11 +41,26 @@ class _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: ... +if sys.version_info >= (3,): + def compressobj( + level: int = ..., + method: int = ..., + wbits: int = ..., + memLevel: int = ..., + strategy: int = ..., + zdict: Optional[bytes] = ..., + ) -> _Compress: ... + +else: + def compressobj( + level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ... + ) -> _Compress: ... def crc32(__data: Union[array[Any], bytes], __value: int = ...) -> int: ... def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... -def decompressobj(wbits: int = ...) -> _Decompress: ... +if sys.version_info >= (3,): + def decompressobj(wbits: int = ..., zdict: bytes = ...) -> _Decompress: ... + +else: + def decompressobj(wbits: int = ...) -> _Decompress: ... From afb92e187917e57c4dfafc3711392d61b224c7af Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 15 May 2021 00:27:59 +0300 Subject: [PATCH 3/6] run script (attempt 2) --- stdlib/@python2/__future__.pyi | 9 - stdlib/@python2/_bisect.pyi | 33 +- stdlib/@python2/_codecs.pyi | 22 +- stdlib/@python2/_csv.pyi | 13 +- stdlib/@python2/_curses.pyi | 28 +- stdlib/@python2/_dummy_threading.pyi | 113 ++----- stdlib/@python2/_heapq.pyi | 5 +- stdlib/@python2/_random.pyi | 3 +- stdlib/@python2/_thread.pyi | 12 - stdlib/@python2/_typeshed/__init__.pyi | 41 +-- stdlib/@python2/_typeshed/tkinter.pyi | 4 - stdlib/@python2/_warnings.pyi | 87 ++--- stdlib/@python2/_weakref.pyi | 8 - stdlib/@python2/_weakrefset.pyi | 5 - stdlib/@python2/aifc.pyi | 23 +- stdlib/@python2/antigravity.pyi | 2 - stdlib/@python2/argparse.pyi | 183 +++------- stdlib/@python2/array.pyi | 30 +- stdlib/@python2/asynchat.pyi | 15 +- stdlib/@python2/asyncore.pyi | 59 ++-- stdlib/@python2/base64.pyi | 27 +- stdlib/@python2/binascii.pyi | 30 +- stdlib/@python2/bz2.pyi | 51 +-- stdlib/@python2/cProfile.pyi | 4 - stdlib/@python2/calendar.pyi | 28 +- stdlib/@python2/cmath.pyi | 12 - stdlib/@python2/code.pyi | 20 +- stdlib/@python2/codecs.pyi | 10 +- stdlib/@python2/contextlib.pyi | 96 +----- stdlib/@python2/crypt.pyi | 20 +- stdlib/@python2/csv.pyi | 25 +- stdlib/@python2/ctypes/__init__.pyi | 38 +-- stdlib/@python2/datetime.pyi | 281 ++++------------ stdlib/@python2/decimal.pyi | 195 +++-------- stdlib/@python2/difflib.pyi | 63 +--- stdlib/@python2/dis.pyi | 60 +--- stdlib/@python2/doctest.pyi | 9 +- stdlib/@python2/ensurepip/__init__.pyi | 28 +- stdlib/@python2/filecmp.pyi | 46 +-- stdlib/@python2/fileinput.pyi | 65 +--- stdlib/@python2/fractions.pyi | 56 ++-- stdlib/@python2/ftplib.pyi | 54 +-- stdlib/@python2/genericpath.pyi | 4 - stdlib/@python2/hmac.pyi | 21 +- stdlib/@python2/imaplib.pyi | 52 +-- stdlib/@python2/imghdr.pyi | 5 +- stdlib/@python2/ipaddress.pyi | 3 - stdlib/@python2/keyword.pyi | 3 - stdlib/@python2/lib2to3/pgen2/token.pyi | 7 - stdlib/@python2/lib2to3/pytree.pyi | 5 +- stdlib/@python2/linecache.pyi | 2 - stdlib/@python2/locale.pyi | 14 +- stdlib/@python2/macpath.pyi | 87 ++--- stdlib/@python2/mailbox.pyi | 9 - stdlib/@python2/math.pyi | 68 +--- stdlib/@python2/mimetypes.pyi | 7 +- stdlib/@python2/mmap.pyi | 83 +---- stdlib/@python2/modulefinder.pyi | 25 +- stdlib/@python2/msilib/__init__.pyi | 3 +- stdlib/@python2/nntplib.pyi | 5 +- stdlib/@python2/numbers.pyi | 36 +- stdlib/@python2/opcode.pyi | 8 - stdlib/@python2/operator.pyi | 58 ++-- stdlib/@python2/optparse.pyi | 8 +- stdlib/@python2/os/__init__.pyi | 63 +--- stdlib/@python2/pdb.pyi | 187 ++++------- stdlib/@python2/pickle.pyi | 103 +----- stdlib/@python2/pickletools.pyi | 63 +--- stdlib/@python2/pkgutil.pyi | 20 +- stdlib/@python2/plistlib.pyi | 76 +---- stdlib/@python2/poplib.pyi | 34 +- stdlib/@python2/pprint.pyi | 139 +------- stdlib/@python2/pstats.pyi | 13 - stdlib/@python2/pty.pyi | 6 +- stdlib/@python2/py_compile.pyi | 41 +-- stdlib/@python2/pyclbr.pyi | 18 +- stdlib/@python2/pydoc.pyi | 14 +- stdlib/@python2/pyexpat/errors.pyi | 4 - stdlib/@python2/queue.pyi | 17 - stdlib/@python2/readline.pyi | 6 - stdlib/@python2/rlcompleter.pyi | 5 +- stdlib/@python2/sched.pyi | 28 +- stdlib/@python2/select.pyi | 29 +- stdlib/@python2/shutil.pyi | 139 ++------ stdlib/@python2/smtpd.pyi | 53 +-- stdlib/@python2/sndhdr.pyi | 11 +- stdlib/@python2/socket.pyi | 218 +----------- stdlib/@python2/socketserver.pyi | 4 - stdlib/@python2/sqlite3/dbapi2.pyi | 213 +++++------- stdlib/@python2/sre_compile.pyi | 13 +- stdlib/@python2/ssl.pyi | 333 ++++--------------- stdlib/@python2/struct.pyi | 18 +- stdlib/@python2/sunau.pyi | 21 +- stdlib/@python2/symtable.pyi | 12 +- stdlib/@python2/tarfile.pyi | 93 ++---- stdlib/@python2/telnetlib.pyi | 3 - stdlib/@python2/threading.pyi | 113 ++----- stdlib/@python2/time.pyi | 84 +---- stdlib/@python2/timeit.pyi | 32 +- stdlib/@python2/token.pyi | 25 +- stdlib/@python2/traceback.pyi | 197 ++--------- stdlib/@python2/turtle.pyi | 62 +--- stdlib/@python2/typing_extensions.pyi | 77 ++--- stdlib/@python2/unicodedata.pyi | 3 - stdlib/@python2/uu.pyi | 8 +- stdlib/@python2/uuid.pyi | 79 ++--- stdlib/@python2/warnings.pyi | 31 +- stdlib/@python2/wave.pyi | 21 +- stdlib/@python2/weakref.pyi | 60 +--- stdlib/@python2/webbrowser.pyi | 12 +- stdlib/@python2/wsgiref/handlers.pyi | 3 - stdlib/@python2/wsgiref/headers.pyi | 10 +- stdlib/@python2/wsgiref/simple_server.pyi | 5 +- stdlib/@python2/wsgiref/util.pyi | 5 +- stdlib/@python2/wsgiref/validate.pyi | 13 +- stdlib/@python2/xml/dom/minidom.pyi | 27 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 11 +- stdlib/@python2/xml/etree/ElementTree.pyi | 204 ++---------- stdlib/@python2/xml/sax/__init__.pyi | 6 +- stdlib/@python2/xml/sax/saxutils.pyi | 18 +- stdlib/@python2/zipfile.pyi | 141 +------- stdlib/@python2/zipimport.pyi | 14 +- stdlib/@python2/zlib.pyi | 29 +- 123 files changed, 1028 insertions(+), 4685 deletions(-) diff --git a/stdlib/@python2/__future__.pyi b/stdlib/@python2/__future__.pyi index 8a5035271eec..8f5ff06ac080 100644 --- a/stdlib/@python2/__future__.pyi +++ b/stdlib/@python2/__future__.pyi @@ -14,13 +14,4 @@ nested_scopes: _Feature print_function: _Feature unicode_literals: _Feature with_statement: _Feature -if sys.version_info >= (3, 0): - barry_as_FLUFL: _Feature - -if sys.version_info >= (3, 5): - generator_stop: _Feature - -if sys.version_info >= (3, 7): - annotations: _Feature - all_feature_names: List[str] # undocumented diff --git a/stdlib/@python2/_bisect.pyi b/stdlib/@python2/_bisect.pyi index 3ca863a2e939..80a0bea735a3 100644 --- a/stdlib/@python2/_bisect.pyi +++ b/stdlib/@python2/_bisect.pyi @@ -4,32 +4,7 @@ from typing import Callable, MutableSequence, Optional, Sequence, TypeVar _T = TypeVar("_T") -if sys.version_info >= (3, 10): - def bisect_left( - a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... - ) -> int: ... - def bisect_right( - a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... - ) -> int: ... - def insort_left( - a: MutableSequence[_T], - x: _T, - lo: int = ..., - hi: Optional[int] = ..., - *, - key: Optional[Callable[[_T], SupportsLessThan]] = ..., - ) -> None: ... - def insort_right( - a: MutableSequence[_T], - x: _T, - lo: int = ..., - hi: Optional[int] = ..., - *, - key: Optional[Callable[[_T], SupportsLessThan]] = ..., - ) -> None: ... - -else: - def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... - def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... - def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... - def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... +def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... +def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... +def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... +def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index fbb014aadbfb..27fad0fdcef7 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -6,12 +6,8 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union _Handler = Callable[[Exception], Tuple[Text, int]] _String = Union[bytes, str] _Errors = Union[str, Text, None] -if sys.version_info >= (3, 0): - _Decodable = bytes - _Encodable = str -else: - _Decodable = Union[bytes, Text] - _Encodable = Union[bytes, Text] +_Decodable = Union[bytes, Text] +_Encodable = Union[bytes, Text] # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap(object): @@ -29,8 +25,7 @@ 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]: ... -if sys.version_info < (3, 2): - def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... +def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ... def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... @@ -44,9 +39,8 @@ def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> Tuple[bytes, def unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ... def unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... -if sys.version_info < (3, 8): - def unicode_internal_decode(__obj: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ... - def unicode_internal_encode(__obj: _String, __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]: ... @@ -74,9 +68,3 @@ 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]: ... - if sys.version_info >= (3, 0): - def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... - def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... - if sys.version_info >= (3, 6): - def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... - def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index 2b4b1a743865..9544ba91958c 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_csv.pyi @@ -24,20 +24,13 @@ _DialectLike = Union[str, Dialect, Type[Dialect]] class _reader(Iterator[List[str]]): dialect: Dialect line_num: int - if sys.version_info >= (3, 0): - def __next__(self) -> List[str]: ... - else: - def next(self) -> List[str]: ... + def next(self) -> List[str]: ... class _writer: dialect: Dialect - if sys.version_info >= (3, 5): - def writerow(self, row: Iterable[Any]) -> Any: ... - def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... - else: - def writerow(self, row: Sequence[Any]) -> Any: ... - def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... + def writerow(self, row: Sequence[Any]) -> Any: ... + def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... class _Writer(Protocol): def write(self, s: str) -> Any: ... diff --git a/stdlib/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index 1ccd54e35edd..e5591d596104 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -57,8 +57,6 @@ A_COLOR: int A_DIM: int A_HORIZONTAL: int A_INVIS: int -if sys.version_info >= (3, 7): - A_ITALIC: int A_LEFT: int A_LOW: int A_NORMAL: int @@ -269,11 +267,7 @@ 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 -if sys.version_info >= (3, 8): - def color_pair(pair_number: int) -> int: ... - -else: - def color_pair(__color_number: int) -> int: ... +def color_pair(__color_number: int) -> int: ... def curs_set(__visibility: int) -> int: ... def def_prog_mode() -> None: ... @@ -349,23 +343,15 @@ def tparm( def typeahead(__fd: int) -> None: ... def unctrl(__ch: _chtype) -> bytes: ... -if sys.version_info >= (3, 3): - def unget_wch(__ch: Union[int, str]) -> None: ... - def ungetch(__ch: _chtype) -> None: ... def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ... -if sys.version_info >= (3, 5): - def update_lines_cols() -> int: ... - def use_default_colors() -> None: ... def use_env(__flag: bool) -> None: ... class error(Exception): ... class _CursesWindow: - if sys.version_info >= (3, 3): - encoding: str @overload def addch(self, ch: _chtype, attr: int = ...) -> None: ... @overload @@ -429,11 +415,6 @@ class _CursesWindow: def getch(self) -> int: ... @overload def getch(self, y: int, x: int) -> int: ... - if sys.version_info >= (3, 3): - @overload - def get_wch(self) -> Union[int, str]: ... - @overload - def get_wch(self, y: int, x: int) -> Union[int, str]: ... @overload def getkey(self) -> str: ... @overload @@ -533,10 +514,3 @@ class _CursesWindow: @overload def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... -if sys.version_info >= (3, 8): - class _ncurses_version(NamedTuple): - major: int - minor: int - patch: int - ncurses_version: _ncurses_version - window = _CursesWindow # undocumented diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index af0b0af89d9b..f8e1fc46b10a 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -12,30 +12,17 @@ __all__: List[str] def active_count() -> int: ... -if sys.version_info < (3,): - def activeCount() -> int: ... +def activeCount() -> int: ... def current_thread() -> Thread: ... def currentThread() -> Thread: ... -if sys.version_info >= (3,): - def get_ident() -> int: ... - def enumerate() -> List[Thread]: ... -if sys.version_info >= (3, 4): - def main_thread() -> Thread: ... - -if sys.version_info >= (3, 8): - from _thread import get_native_id as get_native_id - def settrace(func: _TF) -> None: ... def setprofile(func: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... -if sys.version_info >= (3,): - TIMEOUT_MAX: float - class ThreadError(Exception): ... class local(object): @@ -47,37 +34,21 @@ class Thread: name: str ident: Optional[int] daemon: bool - if sys.version_info >= (3,): - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - *, - daemon: Optional[bool] = ..., - ) -> None: ... - else: - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[Text] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., - ) -> None: ... + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[Text] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[Text, Any]] = ..., + ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: Text) -> None: ... - if sys.version_info >= (3, 8): - @property - def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - if sys.version_info < (3, 9): - def isAlive(self) -> bool: ... + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -89,10 +60,7 @@ class Lock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -102,10 +70,7 @@ class _RLock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock @@ -116,14 +81,9 @@ class Condition: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... - if sys.version_info >= (3,): - def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -133,56 +93,23 @@ class Semaphore: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - if sys.version_info >= (3, 9): - def release(self, n: int = ...) -> None: ... - else: - def release(self) -> 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: ... - if sys.version_info < (3,): - def isSet(self) -> bool: ... + def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... -if sys.version_info >= (3, 8): - from _thread import _excepthook, _ExceptHookArgs - - excepthook = _excepthook - ExceptHookArgs = _ExceptHookArgs - class Timer(Thread): - if sys.version_info >= (3,): - def __init__( - self, - interval: float, - function: Callable[..., Any], - args: Optional[Iterable[Any]] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - ) -> None: ... - else: - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... + def __init__( + self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... + ) -> None: ... def cancel(self) -> None: ... -if sys.version_info >= (3,): - class Barrier: - parties: int - n_waiting: int - broken: bool - def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> int: ... - def reset(self) -> None: ... - def abort(self) -> None: ... - class BrokenBarrierError(RuntimeError): ... diff --git a/stdlib/@python2/_heapq.pyi b/stdlib/@python2/_heapq.pyi index 5b14a9de773d..2928f39c2c17 100644 --- a/stdlib/@python2/_heapq.pyi +++ b/stdlib/@python2/_heapq.pyi @@ -9,6 +9,5 @@ def heappush(__heap: List[_T], __item: _T) -> None: ... def heappushpop(__heap: List[_T], __item: _T) -> _T: ... def heapreplace(__heap: List[_T], __item: _T) -> _T: ... -if sys.version_info < (3,): - def nlargest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... - def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... +def nlargest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... +def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... diff --git a/stdlib/@python2/_random.pyi b/stdlib/@python2/_random.pyi index aa09693420ca..3d1d6476953f 100644 --- a/stdlib/@python2/_random.pyi +++ b/stdlib/@python2/_random.pyi @@ -11,5 +11,4 @@ class Random(object): def setstate(self, __state: _State) -> None: ... def random(self) -> float: ... def getrandbits(self, __k: int) -> int: ... - if sys.version_info < (3,): - def jumpahead(self, i: int) -> None: ... + def jumpahead(self, i: int) -> None: ... diff --git a/stdlib/@python2/_thread.pyi b/stdlib/@python2/_thread.pyi index 513678499223..6cf7f5f59206 100644 --- a/stdlib/@python2/_thread.pyi +++ b/stdlib/@python2/_thread.pyi @@ -27,15 +27,3 @@ def stack_size(size: int = ...) -> int: ... TIMEOUT_MAX: float -if sys.version_info >= (3, 8): - def get_native_id() -> int: ... # only available on some platforms - class _ExceptHookArgs(Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]): - @property - def exc_type(self) -> Type[BaseException]: ... - @property - def exc_value(self) -> Optional[BaseException]: ... - @property - def exc_traceback(self) -> Optional[TracebackType]: ... - @property - def thread(self) -> Optional[Thread]: ... - _excepthook: Callable[[_ExceptHookArgs], Any] diff --git a/stdlib/@python2/_typeshed/__init__.pyi b/stdlib/@python2/_typeshed/__init__.pyi index 948d4269f575..e041aa02c2af 100644 --- a/stdlib/@python2/_typeshed/__init__.pyi +++ b/stdlib/@python2/_typeshed/__init__.pyi @@ -40,11 +40,8 @@ class SupportsRDivMod(Protocol[_T_contra, _T_co]): # Mapping-like protocols class SupportsItems(Protocol[_KT_co, _VT_co]): - if sys.version_info >= (3,): - def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ... - else: - # We want dictionaries to support this on Python 2. - def items(self) -> Iterable[Tuple[_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]: ... @@ -59,16 +56,9 @@ class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, # StrPath and AnyPath can be used in places where a # path can be used instead of a string, starting with Python 3.6. -if sys.version_info >= (3, 6): - from os import PathLike - - StrPath = Union[str, PathLike[str]] - BytesPath = Union[bytes, PathLike[bytes]] - AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]] -else: - StrPath = Text - BytesPath = bytes - AnyPath = Union[Text, bytes] +StrPath = Text +BytesPath = bytes +AnyPath = Union[Text, bytes] OpenTextModeUpdating = Literal[ "r+", @@ -155,17 +145,10 @@ class SupportsNoArgReadline(Protocol[_T_co]): class SupportsWrite(Protocol[_T_contra]): def write(self, __s: _T_contra) -> Any: ... -if sys.version_info >= (3,): - ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap] - WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap] -else: - ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer] - WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, buffer] - -if sys.version_info >= (3, 10): - from types import NoneType as NoneType -else: - # Used by type checkers for checks involving None (does not exist at runtime) - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... +ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer] +WriteableBuffer = Union[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/stdlib/@python2/_typeshed/tkinter.pyi b/stdlib/@python2/_typeshed/tkinter.pyi index 565635adbb74..a4b00506a0e3 100644 --- a/stdlib/@python2/_typeshed/tkinter.pyi +++ b/stdlib/@python2/_typeshed/tkinter.pyi @@ -1,7 +1,3 @@ import sys from typing import Optional, Protocol -if sys.version_info >= (3,): - from tkinter import Event, Misc, Widget - class DndSource(Protocol): - def dnd_end(self, target: Optional[Widget], event: Optional[Event[Misc]]) -> None: ... diff --git a/stdlib/@python2/_warnings.pyi b/stdlib/@python2/_warnings.pyi index b4ec4e6ee794..2844b0b690fa 100644 --- a/stdlib/@python2/_warnings.pyi +++ b/stdlib/@python2/_warnings.pyi @@ -1,67 +1,32 @@ import sys from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload -if sys.version_info >= (3, 0): - _defaultaction: str - _onceregistry: Dict[Any, Any] -else: - default_action: str - once_registry: Dict[Any, Any] +default_action: str +once_registry: Dict[Any, Any] filters: List[Tuple[Any, ...]] -if sys.version_info >= (3, 6): - @overload - def warn( - message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ... - ) -> None: ... - @overload - def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Optional[Any] = ...) -> None: ... - @overload - def warn_explicit( - message: str, - category: Type[Warning], - filename: str, - lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., - ) -> None: ... - @overload - def warn_explicit( - message: Warning, - category: Any, - filename: str, - lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., - ) -> None: ... - -else: - @overload - def warn(message: str, category: Optional[Type[Warning]] = ..., 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: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - ) -> None: ... - @overload - def warn_explicit( - message: Warning, - category: Any, - filename: str, - lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., - ) -> None: ... +@overload +def warn(message: str, category: Optional[Type[Warning]] = ..., 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: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., +) -> None: ... +@overload +def warn_explicit( + message: Warning, + category: Any, + filename: str, + lineno: int, + module: Optional[str] = ..., + registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., + module_globals: Optional[Dict[str, Any]] = ..., +) -> None: ... diff --git a/stdlib/@python2/_weakref.pyi b/stdlib/@python2/_weakref.pyi index 115a591ce4c8..3c395dc7206e 100644 --- a/stdlib/@python2/_weakref.pyi +++ b/stdlib/@python2/_weakref.pyi @@ -1,9 +1,6 @@ import sys from typing import Any, Callable, Generic, List, Optional, TypeVar, overload -if sys.version_info >= (3, 9): - from types import GenericAlias - _C = TypeVar("_C", bound=Callable[..., Any]) _T = TypeVar("_T") @@ -14,14 +11,9 @@ class ProxyType(Generic[_T]): # "weakproxy" def __getattr__(self, attr: str) -> Any: ... class ReferenceType(Generic[_T]): - if sys.version_info >= (3, 4): - __callback__: Callable[[ReferenceType[_T]], Any] def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ... def __call__(self) -> Optional[_T]: ... def __hash__(self) -> int: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - ref = ReferenceType def getweakrefcount(__object: Any) -> int: ... diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index c369584aa243..f5f4fc5241c9 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -1,9 +1,6 @@ import sys from typing import Any, Generic, Iterable, Iterator, MutableSet, Optional, TypeVar, Union -if sys.version_info >= (3, 9): - from types import GenericAlias - _S = TypeVar("_S") _T = TypeVar("_T") _SelfT = TypeVar("_SelfT", bound=WeakSet[Any]) @@ -43,5 +40,3 @@ class WeakSet(MutableSet[_T], Generic[_T]): def union(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... def __or__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... def isdisjoint(self, other: Iterable[_T]) -> bool: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index f812ac593e97..68c4286cc150 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -18,11 +18,6 @@ _Marker = Tuple[int, int, bytes] class Aifc_read: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 4): - def __enter__(self) -> Aifc_read: ... - def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def getfp(self) -> IO[bytes]: ... def rewind(self) -> None: ... @@ -43,11 +38,6 @@ class Aifc_read: class Aifc_write: def __init__(self, f: _File) -> None: ... def __del__(self) -> None: ... - if sys.version_info >= (3, 4): - def __enter__(self) -> Aifc_write: ... - def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def aiff(self) -> None: ... def aifc(self) -> None: ... @@ -79,10 +69,9 @@ def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... @overload def open(f: _File, mode: Optional[str] = ...) -> Any: ... -if sys.version_info < (3, 9): - @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: Optional[str] = ...) -> 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: Optional[str] = ...) -> Any: ... diff --git a/stdlib/@python2/antigravity.pyi b/stdlib/@python2/antigravity.pyi index 52e2c5d96bef..44bd5c72b94b 100644 --- a/stdlib/@python2/antigravity.pyi +++ b/stdlib/@python2/antigravity.pyi @@ -1,4 +1,2 @@ import sys -if sys.version_info >= (3, 0): - def geohash(latitude: float, longitude: float, datedow: bytes) -> None: ... diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 9dceaabd4631..5b0c2546ada0 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -24,10 +24,7 @@ _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) _N = TypeVar("_N") -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] ONE_OR_MORE: str OPTIONAL: str @@ -109,62 +106,25 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): fromfile_prefix_chars: Optional[_Text] add_help: bool - if sys.version_info >= (3, 5): - allow_abbrev: bool - # undocumented _positionals: _ArgumentGroup _optionals: _ArgumentGroup _subparsers: Optional[_ArgumentGroup] - if sys.version_info >= (3, 9): - def __init__( - self, - prog: Optional[str] = ..., - usage: Optional[str] = ..., - description: Optional[str] = ..., - epilog: Optional[str] = ..., - parents: Sequence[ArgumentParser] = ..., - formatter_class: _FormatterClass = ..., - prefix_chars: str = ..., - fromfile_prefix_chars: Optional[str] = ..., - argument_default: Any = ..., - conflict_handler: str = ..., - add_help: bool = ..., - allow_abbrev: bool = ..., - exit_on_error: bool = ..., - ) -> None: ... - elif sys.version_info >= (3, 5): - def __init__( - self, - prog: Optional[str] = ..., - usage: Optional[str] = ..., - description: Optional[str] = ..., - epilog: Optional[str] = ..., - parents: Sequence[ArgumentParser] = ..., - formatter_class: _FormatterClass = ..., - prefix_chars: str = ..., - fromfile_prefix_chars: Optional[str] = ..., - argument_default: Any = ..., - conflict_handler: str = ..., - add_help: bool = ..., - allow_abbrev: bool = ..., - ) -> None: ... - else: - def __init__( - self, - prog: Optional[Text] = ..., - usage: Optional[Text] = ..., - description: Optional[Text] = ..., - epilog: Optional[Text] = ..., - parents: Sequence[ArgumentParser] = ..., - formatter_class: _FormatterClass = ..., - prefix_chars: Text = ..., - fromfile_prefix_chars: Optional[Text] = ..., - argument_default: Any = ..., - conflict_handler: Text = ..., - add_help: bool = ..., - ) -> None: ... + def __init__( + self, + prog: Optional[Text] = ..., + usage: Optional[Text] = ..., + description: Optional[Text] = ..., + epilog: Optional[Text] = ..., + parents: Sequence[ArgumentParser] = ..., + formatter_class: _FormatterClass = ..., + prefix_chars: Text = ..., + fromfile_prefix_chars: Optional[Text] = ..., + 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 @@ -177,35 +137,19 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore @overload def parse_args(self, *, namespace: _N) -> _N: ... - if sys.version_info >= (3, 7): - def add_subparsers( - self, - *, - title: str = ..., - description: Optional[str] = ..., - prog: str = ..., - parser_class: Type[ArgumentParser] = ..., - action: Type[Action] = ..., - option_string: str = ..., - dest: Optional[str] = ..., - required: bool = ..., - help: Optional[str] = ..., - metavar: Optional[str] = ..., - ) -> _SubParsersAction: ... - else: - def add_subparsers( - self, - *, - title: Text = ..., - description: Optional[Text] = ..., - prog: Text = ..., - parser_class: Type[ArgumentParser] = ..., - action: Type[Action] = ..., - option_string: Text = ..., - dest: Optional[Text] = ..., - help: Optional[Text] = ..., - metavar: Optional[Text] = ..., - ) -> _SubParsersAction: ... + def add_subparsers( + self, + *, + title: Text = ..., + description: Optional[Text] = ..., + prog: Text = ..., + parser_class: Type[ArgumentParser] = ..., + action: Type[Action] = ..., + option_string: Text = ..., + dest: Optional[Text] = ..., + help: Optional[Text] = ..., + metavar: Optional[Text] = ..., + ) -> _SubParsersAction: ... def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... def print_help(self, file: Optional[IO[str]] = ...) -> None: ... def format_usage(self) -> str: ... @@ -216,13 +160,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def convert_arg_line_to_args(self, arg_line: Text) -> List[str]: ... def exit(self, status: int = ..., message: Optional[Text] = ...) -> NoReturn: ... def error(self, message: Text) -> NoReturn: ... - if sys.version_info >= (3, 7): - def parse_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... - ) -> Namespace: ... - def parse_known_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... - ) -> Tuple[Namespace, List[str]]: ... # undocumented def _get_optional_actions(self) -> List[Action]: ... def _get_positional_actions(self) -> List[Action]: ... @@ -290,9 +227,6 @@ class RawDescriptionHelpFormatter(HelpFormatter): ... class RawTextHelpFormatter(RawDescriptionHelpFormatter): ... class ArgumentDefaultsHelpFormatter(HelpFormatter): ... -if sys.version_info >= (3,): - class MetavarTypeHelpFormatter(HelpFormatter): ... - class Action(_AttributeHolder): option_strings: Sequence[_Text] dest: _Text @@ -324,23 +258,6 @@ class Action(_AttributeHolder): values: Union[Text, Sequence[Any], None], option_string: Optional[Text] = ..., ) -> None: ... - if sys.version_info >= (3, 9): - def format_usage(self) -> str: ... - -if sys.version_info >= (3, 9): - class BooleanOptionalAction(Action): - def __init__( - self, - option_strings: Sequence[str], - dest: str, - default: Union[_T, str, None] = ..., - type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., - required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - ) -> None: ... - class Namespace(_AttributeHolder): def __init__(self, **kwargs: Any) -> None: ... def __getattr__(self, name: Text) -> Any: ... @@ -351,14 +268,7 @@ class FileType: # undocumented _mode: _Text _bufsize: int - if sys.version_info >= (3,): - _encoding: Optional[str] - _errors: Optional[str] - def __init__( - self, mode: str = ..., bufsize: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ... - ) -> None: ... - else: - def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ... + def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ... def __call__(self, string: Text) -> IO[Any]: ... # undocumented @@ -451,27 +361,15 @@ class _SubParsersAction(Action): _name_parser_map: Dict[_Text, ArgumentParser] choices: Dict[_Text, ArgumentParser] _choices_actions: List[Action] - if sys.version_info >= (3, 7): - def __init__( - self, - option_strings: Sequence[Text], - prog: Text, - parser_class: Type[ArgumentParser], - dest: Text = ..., - required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - ) -> None: ... - else: - def __init__( - self, - option_strings: Sequence[Text], - prog: Text, - parser_class: Type[ArgumentParser], - dest: Text = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - ) -> None: ... + def __init__( + self, + option_strings: Sequence[Text], + prog: Text, + parser_class: Type[ArgumentParser], + dest: Text = ..., + help: Optional[Text] = ..., + metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... def _get_subactions(self) -> List[Action]: ... @@ -479,9 +377,8 @@ class _SubParsersAction(Action): # undocumented class ArgumentTypeError(Exception): ... -if sys.version_info < (3, 7): - # undocumented - def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ... +# undocumented +def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ... # undocumented def _get_action_name(argument: Optional[Action]) -> Optional[str]: ... diff --git a/stdlib/@python2/array.pyi b/stdlib/@python2/array.pyi index 498bf92919f1..af694ad2d23f 100644 --- a/stdlib/@python2/array.pyi +++ b/stdlib/@python2/array.pyi @@ -9,9 +9,6 @@ _TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] _T = TypeVar("_T", int, float, Text) -if sys.version_info >= (3,): - typecodes: str - class array(MutableSequence[_T], Generic[_T]): typecode: _TypeCode itemsize: int @@ -28,31 +25,21 @@ class array(MutableSequence[_T], Generic[_T]): def byteswap(self) -> None: ... def count(self, __v: Any) -> int: ... def extend(self, __bb: Iterable[_T]) -> None: ... - if sys.version_info >= (3, 2): - def frombytes(self, __buffer: bytes) -> None: ... def fromfile(self, __f: BinaryIO, __n: int) -> None: ... def fromlist(self, __list: List[_T]) -> None: ... def fromunicode(self, __ustr: str) -> None: ... - if sys.version_info >= (3, 10): - def index(self, __v: _T, __start: int = ..., __stop: int = ...) -> int: ... - else: - def index(self, __v: _T) -> int: ... # type: ignore # Overrides Sequence + def index(self, __v: _T) -> int: ... # type: ignore # Overrides Sequence def insert(self, __i: int, __v: _T) -> None: ... def pop(self, __i: int = ...) -> _T: ... - if sys.version_info < (3,): - def read(self, f: BinaryIO, n: int) -> None: ... + def read(self, f: BinaryIO, n: int) -> None: ... def remove(self, __v: Any) -> None: ... def reverse(self) -> None: ... - if sys.version_info >= (3, 2): - def tobytes(self) -> bytes: ... def tofile(self, __f: BinaryIO) -> None: ... def tolist(self) -> List[_T]: ... def tounicode(self) -> str: ... - if sys.version_info < (3,): - def write(self, f: BinaryIO) -> None: ... - if sys.version_info < (3, 9): - def fromstring(self, __buffer: bytes) -> None: ... - def tostring(self) -> bytes: ... + 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: ... @@ -72,9 +59,8 @@ class array(MutableSequence[_T], Generic[_T]): def __lt__(self, other: array[_T]) -> bool: ... def __mul__(self, n: int) -> array[_T]: ... def __rmul__(self, n: int) -> array[_T]: ... - if sys.version_info < (3,): - 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: ... + 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/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index 34039b993400..2fc5bbf07d0f 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -29,11 +29,10 @@ class async_chat(asyncore.dispatcher): def initiate_send(self) -> None: ... def discard_buffers(self) -> None: ... -if sys.version_info < (3, 0): - class fifo: - def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... - def __len__(self) -> int: ... - def is_empty(self) -> bool: ... - def first(self) -> bytes: ... - def push(self, data: Union[bytes, simple_producer]) -> None: ... - def pop(self) -> Tuple[int, bytes]: ... +class fifo: + def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... + def __len__(self) -> int: ... + def is_empty(self) -> bool: ... + def first(self) -> bytes: ... + def push(self, data: Union[bytes, simple_producer]) -> None: ... + def pop(self) -> Tuple[int, bytes]: ... diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index a05a205115f3..be551a040cc1 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -59,36 +59,35 @@ class dispatcher: def handle_connect(self) -> None: ... def handle_accept(self) -> None: ... def handle_close(self) -> None: ... - if sys.version_info < (3, 5): - # 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: Union[Tuple[str, int], str], flags: int = ...) -> int: ... - def setblocking(self, flag: bool) -> None: ... - def settimeout(self, value: Union[float, None]) -> None: ... - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... - def shutdown(self, how: int) -> 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: Union[Tuple[str, int], str], flags: int = ...) -> int: ... + def setblocking(self, flag: bool) -> None: ... + def settimeout(self, value: Union[float, None]) -> None: ... + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + def shutdown(self, how: int) -> None: ... class dispatcher_with_send(dispatcher): def __init__(self, sock: SocketType = ..., map: Optional[_maptype] = ...) -> None: ... diff --git a/stdlib/@python2/base64.pyi b/stdlib/@python2/base64.pyi index e217d6d3dbf2..999b2713a456 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -1,12 +1,8 @@ import sys from typing import IO, Optional, Union -if sys.version_info >= (3, 0): - _encodable = bytes - _decodable = Union[bytes, str] -else: - _encodable = Union[bytes, unicode] - _decodable = Union[bytes, unicode] +_encodable = Union[bytes, unicode] +_decodable = Union[bytes, unicode] def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ... def b64decode(s: _decodable, altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ... @@ -19,23 +15,8 @@ def b32decode(s: _decodable, casefold: bool = ..., map01: Optional[bytes] = ...) def b16encode(s: _encodable) -> bytes: ... def b16decode(s: _decodable, casefold: bool = ...) -> bytes: ... -if sys.version_info >= (3, 10): - def b32hexencode(s: _encodable) -> bytes: ... - def b32hexdecode(s: _decodable, casefold: bool = ...) -> bytes: ... - -if sys.version_info >= (3, 4): - def a85encode(b: _encodable, *, foldspaces: bool = ..., wrapcol: int = ..., pad: bool = ..., adobe: bool = ...) -> bytes: ... - def a85decode(b: _decodable, *, foldspaces: bool = ..., adobe: bool = ..., ignorechars: Union[str, bytes] = ...) -> bytes: ... - def b85encode(b: _encodable, pad: bool = ...) -> bytes: ... - def b85decode(b: _decodable) -> bytes: ... - def decode(input: IO[bytes], output: IO[bytes]) -> None: ... def encode(input: IO[bytes], output: IO[bytes]) -> None: ... -if sys.version_info >= (3,): - def encodebytes(s: bytes) -> bytes: ... - def decodebytes(s: bytes) -> bytes: ... - -if sys.version_info < (3, 9): - def encodestring(s: bytes) -> bytes: ... - def decodestring(s: bytes) -> bytes: ... +def encodestring(s: bytes) -> bytes: ... +def decodestring(s: bytes) -> bytes: ... diff --git a/stdlib/@python2/binascii.pyi b/stdlib/@python2/binascii.pyi index db843ad6ca31..69233a05a8fc 100644 --- a/stdlib/@python2/binascii.pyi +++ b/stdlib/@python2/binascii.pyi @@ -1,31 +1,17 @@ import sys from typing import Text, Union -if sys.version_info >= (3, 0): - # But since Python 3.3 ASCII-only unicode strings are accepted by the - # a2b_* functions. - _Bytes = bytes - _Ascii = Union[bytes, str] -else: - # Python 2 accepts unicode ascii pretty much everywhere. - _Bytes = Text - _Ascii = Text +# Python 2 accepts unicode ascii pretty much everywhere. +_Bytes = Text +_Ascii = Text def a2b_uu(__data: _Ascii) -> bytes: ... -if sys.version_info >= (3, 7): - def b2a_uu(__data: _Bytes, *, backtick: bool = ...) -> bytes: ... - -else: - def b2a_uu(__data: _Bytes) -> bytes: ... +def b2a_uu(__data: _Bytes) -> bytes: ... def a2b_base64(__data: _Ascii) -> bytes: ... -if sys.version_info >= (3, 6): - def b2a_base64(__data: _Bytes, *, newline: bool = ...) -> bytes: ... - -else: - def b2a_base64(__data: _Bytes) -> 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: ... @@ -37,11 +23,7 @@ def crc_hqx(__data: _Bytes, __crc: int) -> int: ... def crc32(__data: _Bytes, __crc: int = ...) -> int: ... def b2a_hex(__data: _Bytes) -> bytes: ... -if sys.version_info >= (3, 8): - def hexlify(data: bytes, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> bytes: ... - -else: - def hexlify(__data: _Bytes) -> bytes: ... +def hexlify(__data: _Bytes) -> bytes: ... def a2b_hex(__hexstr: _Ascii) -> bytes: ... def unhexlify(__hexstr: _Ascii) -> bytes: ... diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index dfc1876bf43e..77d0f8e21c20 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -10,45 +10,11 @@ _T = TypeVar("_T") def compress(data: bytes, compresslevel: int = ...) -> bytes: ... def decompress(data: bytes) -> bytes: ... -if sys.version_info >= (3, 3): - _OpenBinaryMode = Literal["r", "rb", "w", "wb", "x", "xb", "a", "ab"] - _OpenTextMode = Literal["rt", "wt", "xt", "at"] - @overload - def open( - filename: _PathOrFile, - mode: _OpenBinaryMode = ..., - compresslevel: int = ..., - encoding: None = ..., - errors: None = ..., - newline: None = ..., - ) -> BZ2File: ... - @overload - def open( - filename: AnyPath, - mode: _OpenTextMode, - compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> TextIO: ... - @overload - def open( - filename: _PathOrFile, - mode: str, - compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> Union[BZ2File, TextIO]: ... - class BZ2File(io.BufferedIOBase, IO[bytes]): def __enter__(self: _T) -> _T: ... - if sys.version_info >= (3, 9): - def __init__(self, filename: _PathOrFile, mode: str = ..., *, compresslevel: int = ...) -> None: ... - else: - def __init__( - self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... - ) -> None: ... + def __init__( + self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... + ) -> None: ... def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore @@ -64,15 +30,6 @@ class BZ2Compressor(object): def flush(self) -> bytes: ... class BZ2Decompressor(object): - if sys.version_info >= (3, 5): - def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... - else: - def decompress(self, data: bytes) -> bytes: ... - if sys.version_info >= (3, 3): - @property - def eof(self) -> bool: ... - if sys.version_info >= (3, 5): - @property - def needs_input(self) -> bool: ... + def decompress(self, data: bytes) -> bytes: ... @property def unused_data(self) -> bytes: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 638a2a79f2e5..cc26f9836cc1 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -26,8 +26,4 @@ class Profile: def run(self: _SelfT, cmd: str) -> _SelfT: ... def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... - if sys.version_info >= (3, 8): - def __enter__(self: _SelfT) -> _SelfT: ... - def __exit__(self, *exc_info: Any) -> None: ... - def label(code: Union[str, CodeType]) -> _Label: ... # undocumented diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index ad73132b4595..752bd9a591cd 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -33,10 +33,6 @@ 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]]: ... - class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... def formatday(self, day: int, weekday: int, width: int) -> str: ... @@ -68,26 +64,10 @@ 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: Optional[str] = ..., encoding: Optional[str] = ...) -> 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 - -if sys.version_info >= (3, 0): - class different_locale: - def __init__(self, locale: _LocaleType) -> None: ... - def __enter__(self) -> _LocaleType: ... - def __exit__(self, *args: Any) -> None: ... - -else: - class TimeEncoding: - def __init__(self, locale: _LocaleType) -> None: ... - def __enter__(self) -> _LocaleType: ... - def __exit__(self, *args: Any) -> None: ... +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: Optional[_LocaleType] = ...) -> None: ... diff --git a/stdlib/@python2/cmath.pyi b/stdlib/@python2/cmath.pyi index eaa62eafcb33..3c38ab9d04db 100644 --- a/stdlib/@python2/cmath.pyi +++ b/stdlib/@python2/cmath.pyi @@ -3,13 +3,6 @@ from typing import SupportsComplex, SupportsFloat, Tuple, Union e: float pi: float -if sys.version_info >= (3, 6): - inf: float - infj: complex - nan: float - nanj: complex - tau: float - _C = Union[SupportsFloat, SupportsComplex, complex] def acos(__z: _C) -> complex: ... @@ -22,9 +15,6 @@ def cos(__z: _C) -> complex: ... def cosh(__z: _C) -> complex: ... def exp(__z: _C) -> complex: ... -if sys.version_info >= (3, 5): - def isclose(a: _C, b: _C, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... - def isinf(__z: _C) -> bool: ... def isnan(__z: _C) -> bool: ... def log(__x: _C, __y_obj: _C = ...) -> complex: ... @@ -38,5 +28,3 @@ def sqrt(__z: _C) -> complex: ... def tan(__z: _C) -> complex: ... def tanh(__z: _C) -> complex: ... -if sys.version_info >= (3,): - def isfinite(__z: _C) -> bool: ... diff --git a/stdlib/@python2/code.pyi b/stdlib/@python2/code.pyi index 16c2b129dd1e..aee7f518d655 100644 --- a/stdlib/@python2/code.pyi +++ b/stdlib/@python2/code.pyi @@ -12,25 +12,13 @@ class InteractiveInterpreter: class InteractiveConsole(InteractiveInterpreter): def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... - if sys.version_info >= (3, 6): - def interact(self, banner: Optional[str] = ..., exitmsg: Optional[str] = ...) -> None: ... - else: - def interact(self, banner: Optional[str] = ...) -> None: ... + def interact(self, banner: Optional[str] = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... def raw_input(self, prompt: str = ...) -> str: ... -if sys.version_info >= (3, 6): - def interact( - banner: Optional[str] = ..., - readfunc: Optional[Callable[[str], str]] = ..., - local: Optional[Mapping[str, Any]] = ..., - exitmsg: Optional[str] = ..., - ) -> None: ... - -else: - def interact( - banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... - ) -> None: ... +def interact( + banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... +) -> None: ... def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index 79be8e254c4c..1132cdd18fb5 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -234,10 +234,7 @@ class StreamReaderWriter(TextIO): def read(self, size: int = ...) -> _Decoded: ... def readline(self, size: Optional[int] = ...) -> _Decoded: ... def readlines(self, sizehint: Optional[int] = ...) -> List[_Decoded]: ... - if sys.version_info >= (3,): - def __next__(self) -> Text: ... - else: - def next(self) -> Text: ... + def next(self) -> Text: ... def __iter__(self: _T) -> _T: ... # This actually returns None, but that's incompatible with the supertype def write(self, data: _Decoded) -> int: ... @@ -277,10 +274,7 @@ class StreamRecoder(BinaryIO): def read(self, size: int = ...) -> bytes: ... def readline(self, size: Optional[int] = ...) -> bytes: ... def readlines(self, sizehint: Optional[int] = ...) -> List[bytes]: ... - if sys.version_info >= (3,): - def __next__(self) -> bytes: ... - else: - def next(self) -> bytes: ... + def next(self) -> bytes: ... def __iter__(self: _SRT) -> _SRT: ... def write(self, data: bytes) -> int: ... def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index 19ef45bed241..c38d3eadb4d7 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -3,14 +3,6 @@ from types import TracebackType from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Type, TypeVar, overload from typing_extensions import Protocol -if sys.version_info >= (3, 5): - from typing import AsyncContextManager, AsyncIterator - -if sys.version_info >= (3, 6): - AbstractContextManager = ContextManager -if sys.version_info >= (3, 7): - AbstractAsyncContextManager = AsyncContextManager - _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=Optional[IO[str]]) @@ -19,21 +11,11 @@ _F = TypeVar("_F", bound=Callable[..., Any]) _ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) -if sys.version_info >= (3, 2): - class _GeneratorContextManager(ContextManager[_T_co]): - def __call__(self, func: _F) -> _F: ... - def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]: ... - -else: - class GeneratorContextManager(ContextManager[_T_co]): - def __call__(self, func: _F) -> _F: ... - def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +class GeneratorContextManager(ContextManager[_T_co]): + def __call__(self, func: _F) -> _F: ... +def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... -if sys.version_info >= (3, 7): - def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ... - -if sys.version_info < (3,): - def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... +def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... class _SupportsClose(Protocol): def close(self) -> None: ... @@ -43,73 +25,3 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) class closing(ContextManager[_SupportsCloseT]): def __init__(self, thing: _SupportsCloseT) -> None: ... -if sys.version_info >= (3, 10): - class _SupportsAclose(Protocol): - async def aclose(self) -> None: ... - _SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose) - class aclosing(AsyncContextManager[_SupportsAcloseT]): - def __init__(self, thing: _SupportsAcloseT) -> None: ... - -if sys.version_info >= (3, 4): - class suppress(ContextManager[None]): - def __init__(self, *exceptions: Type[BaseException]) -> None: ... - def __exit__( - self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType] - ) -> bool: ... - class redirect_stdout(ContextManager[_T_io]): - def __init__(self, new_target: _T_io) -> None: ... - -if sys.version_info >= (3, 5): - class redirect_stderr(ContextManager[_T_io]): - def __init__(self, new_target: _T_io) -> None: ... - -if sys.version_info >= (3,): - class ContextDecorator: - def __call__(self, func: _F) -> _F: ... - _U = TypeVar("_U", bound=ExitStack) - class ExitStack(ContextManager[ExitStack]): - def __init__(self) -> None: ... - def enter_context(self, cm: ContextManager[_T]) -> _T: ... - def push(self, exit: _CM_EF) -> _CM_EF: ... - def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ... - def pop_all(self: _U) -> _U: ... - def close(self) -> None: ... - def __enter__(self: _U) -> _U: ... - def __exit__( - self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> bool: ... - -if sys.version_info >= (3, 7): - from typing import Awaitable - - _S = TypeVar("_S", bound=AsyncExitStack) - - _ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] - _CallbackCoroFunc = Callable[..., Awaitable[Any]] - _ACM_EF = TypeVar("_ACM_EF", AsyncContextManager[Any], _ExitCoroFunc) - class AsyncExitStack(AsyncContextManager[AsyncExitStack]): - def __init__(self) -> None: ... - def enter_context(self, cm: ContextManager[_T]) -> _T: ... - def enter_async_context(self, cm: AsyncContextManager[_T]) -> Awaitable[_T]: ... - def push(self, exit: _CM_EF) -> _CM_EF: ... - def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ... - def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ... - def push_async_callback(self, callback: _CallbackCoroFunc, *args: Any, **kwds: Any) -> _CallbackCoroFunc: ... - def pop_all(self: _S) -> _S: ... - def aclose(self) -> Awaitable[None]: ... - def __aenter__(self: _S) -> Awaitable[_S]: ... - def __aexit__( - self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> Awaitable[bool]: ... - -if sys.version_info >= (3, 7): - @overload - def nullcontext(enter_result: _T) -> ContextManager[_T]: ... - @overload - def nullcontext() -> ContextManager[None]: ... diff --git a/stdlib/@python2/crypt.pyi b/stdlib/@python2/crypt.pyi index 18893721a11f..bab839794f02 100644 --- a/stdlib/@python2/crypt.pyi +++ b/stdlib/@python2/crypt.pyi @@ -1,22 +1,4 @@ import sys from typing import List, Optional, Union -if sys.version_info >= (3, 3): - class _Method: ... - METHOD_CRYPT: _Method - METHOD_MD5: _Method - METHOD_SHA256: _Method - METHOD_SHA512: _Method - if sys.version_info >= (3, 7): - METHOD_BLOWFISH: _Method - - methods: List[_Method] - - if sys.version_info >= (3, 7): - def mksalt(method: Optional[_Method] = ..., *, rounds: Optional[int] = ...) -> str: ... - else: - def mksalt(method: Optional[_Method] = ...) -> str: ... - def crypt(word: str, salt: Optional[Union[str, _Method]] = ...) -> str: ... - -else: - def crypt(word: str, salt: str) -> str: ... +def crypt(word: str, salt: str) -> str: ... diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index db48e9e6c78a..11d78de1fc9c 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -19,11 +19,7 @@ from _csv import ( ) from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, TypeVar, overload -if sys.version_info >= (3, 8) or sys.version_info < (3, 6): - from typing import Dict as _DictReadMapping -else: - from collections import OrderedDict as _DictReadMapping - +from typing import Dict as _DictReadMapping _T = TypeVar("_T") class excel(Dialect): @@ -37,15 +33,6 @@ class excel(Dialect): class excel_tab(excel): delimiter: str -if sys.version_info >= (3,): - class unix_dialect(Dialect): - delimiter: str - quotechar: str - doublequote: bool - skipinitialspace: bool - lineterminator: str - quoting: int - class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): fieldnames: Optional[Sequence[_T]] restkey: Optional[str] @@ -76,10 +63,7 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): **kwds: Any, ) -> None: ... def __iter__(self) -> DictReader[_T]: ... - if sys.version_info >= (3,): - def __next__(self) -> _DictReadMapping[_T, str]: ... - else: - def next(self) -> _DictReadMapping[_T, str]: ... + def next(self) -> _DictReadMapping[_T, str]: ... class DictWriter(Generic[_T]): fieldnames: Sequence[_T] @@ -96,10 +80,7 @@ class DictWriter(Generic[_T]): *args: Any, **kwds: Any, ) -> None: ... - if sys.version_info >= (3, 8): - def writeheader(self) -> Any: ... - else: - def writeheader(self) -> None: ... + def writeheader(self) -> None: ... def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ... def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ... diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 299672ad0629..64c447d893f6 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -19,9 +19,6 @@ from typing import ( overload, ) -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") _DLLT = TypeVar("_DLLT", bound=CDLL) _CT = TypeVar("_CT", bound=_CData) @@ -36,25 +33,14 @@ class CDLL(object): _name: str = ... _handle: int = ... _FuncPtr: Type[_FuncPointer] = ... - if sys.version_info >= (3, 8): - def __init__( - self, - name: Optional[str], - mode: int = ..., - handle: Optional[int] = ..., - use_errno: bool = ..., - use_last_error: bool = ..., - winmode: Optional[int] = ..., - ) -> None: ... - else: - def __init__( - self, - name: Optional[str], - mode: int = ..., - handle: Optional[int] = ..., - use_errno: bool = ..., - use_last_error: bool = ..., - ) -> None: ... + def __init__( + self, + name: Optional[str], + mode: int = ..., + handle: Optional[int] = ..., + use_errno: bool = ..., + use_last_error: bool = ..., + ) -> None: ... def __getattr__(self, name: str) -> _NamedFuncPointer: ... def __getitem__(self, name: str) -> _NamedFuncPointer: ... @@ -69,9 +55,6 @@ class LibraryLoader(Generic[_DLLT]): def __getattr__(self, name: str) -> _DLLT: ... def __getitem__(self, name: str) -> _DLLT: ... def LoadLibrary(self, name: str) -> _DLLT: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - cdll: LibraryLoader[CDLL] = ... if sys.platform == "win32": windll: LibraryLoader[WinDLL] = ... @@ -201,8 +184,7 @@ class pointer(Generic[_CT], _PointerLike, _CData): def resize(obj: _CData, size: int) -> None: ... -if sys.version_info < (3,): - def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ... +def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ... def set_errno(value: int) -> int: ... @@ -315,5 +297,3 @@ class Array(Generic[_CT], _CData): # Can't inherit from Sized because the metaclass conflict between # Sized and _CData prevents using _CDataMeta. def __len__(self) -> int: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index 4692f590b5b3..18bd6a5dc917 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -4,10 +4,7 @@ from typing import AnyStr, ClassVar, NamedTuple, Optional, SupportsAbs, Tuple, T _S = TypeVar("_S") -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] MINYEAR: int MAXYEAR: int @@ -18,20 +15,6 @@ class tzinfo: def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def fromutc(self, dt: datetime) -> datetime: ... -if sys.version_info >= (3, 2): - class timezone(tzinfo): - utc: ClassVar[timezone] - min: ClassVar[timezone] - max: ClassVar[timezone] - def __init__(self, offset: timedelta, name: str = ...) -> None: ... - def __hash__(self) -> int: ... - -if sys.version_info >= (3, 9): - class _IsoCalendarDate(NamedTuple): - year: int - week: int - weekday: int - _tzinfo = tzinfo class date: @@ -45,12 +28,6 @@ class date: def today(cls: Type[_S]) -> _S: ... @classmethod def fromordinal(cls: Type[_S], n: int) -> _S: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... - if sys.version_info >= (3, 8): - @classmethod - def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ... @property def year(self) -> int: ... @property @@ -59,10 +36,7 @@ class date: def day(self) -> int: ... def ctime(self) -> str: ... def strftime(self, fmt: _Text) -> str: ... - if sys.version_info >= (3,): - def __format__(self, fmt: str) -> str: ... - else: - def __format__(self, fmt: AnyStr) -> AnyStr: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... def toordinal(self) -> int: ... @@ -71,12 +45,8 @@ class date: def __lt__(self, other: date) -> bool: ... def __ge__(self, other: date) -> bool: ... def __gt__(self, other: date) -> bool: ... - if sys.version_info >= (3, 8): - def __add__(self: _S, other: timedelta) -> _S: ... - def __radd__(self: _S, other: timedelta) -> _S: ... - else: - def __add__(self, other: timedelta) -> date: ... - def __radd__(self, other: timedelta) -> date: ... + def __add__(self, other: timedelta) -> date: ... + def __radd__(self, other: timedelta) -> date: ... @overload def __sub__(self, other: timedelta) -> date: ... @overload @@ -84,31 +54,16 @@ class date: def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... - if sys.version_info >= (3, 9): - def isocalendar(self) -> _IsoCalendarDate: ... - else: - def isocalendar(self) -> Tuple[int, int, int]: ... + def isocalendar(self) -> Tuple[int, int, int]: ... class time: min: ClassVar[time] max: ClassVar[time] resolution: ClassVar[timedelta] - if sys.version_info >= (3, 6): - def __init__( - self, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> None: ... - else: - def __init__( - self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... - ) -> None: ... + def __init__( + self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... + ) -> None: ... @property def hour(self) -> int: ... @property @@ -119,44 +74,20 @@ class time: def microsecond(self) -> int: ... @property def tzinfo(self) -> Optional[_tzinfo]: ... - if sys.version_info >= (3, 6): - @property - def fold(self) -> int: ... 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: ... - if sys.version_info >= (3, 6): - def isoformat(self, timespec: str = ...) -> str: ... - else: - def isoformat(self) -> str: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: Type[_S], time_string: str) -> _S: ... + def isoformat(self) -> str: ... def strftime(self, fmt: _Text) -> str: ... - if sys.version_info >= (3,): - def __format__(self, fmt: str) -> str: ... - else: - def __format__(self, fmt: AnyStr) -> AnyStr: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def utcoffset(self) -> Optional[timedelta]: ... def tzname(self) -> Optional[str]: ... def dst(self) -> Optional[timedelta]: ... - if sys.version_info >= (3, 6): - def replace( - self, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> time: ... - else: - def replace( - self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... - ) -> time: ... + def replace( + self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... + ) -> time: ... _date = date _time = time @@ -166,30 +97,16 @@ class timedelta(SupportsAbs[timedelta]): max: ClassVar[timedelta] resolution: ClassVar[timedelta] - if sys.version_info >= (3, 6): - def __init__( - self, - days: float = ..., - seconds: float = ..., - microseconds: float = ..., - milliseconds: float = ..., - minutes: float = ..., - hours: float = ..., - weeks: float = ..., - *, - fold: int = ..., - ) -> None: ... - else: - def __init__( - self, - days: float = ..., - seconds: float = ..., - microseconds: float = ..., - milliseconds: float = ..., - minutes: float = ..., - hours: float = ..., - weeks: float = ..., - ) -> None: ... + def __init__( + self, + days: float = ..., + seconds: float = ..., + microseconds: float = ..., + milliseconds: float = ..., + minutes: float = ..., + hours: float = ..., + weeks: float = ..., + ) -> None: ... @property def days(self) -> int: ... @property @@ -210,18 +127,10 @@ class timedelta(SupportsAbs[timedelta]): def __floordiv__(self, other: timedelta) -> int: ... @overload def __floordiv__(self, other: int) -> timedelta: ... - if sys.version_info >= (3,): - @overload - def __truediv__(self, other: timedelta) -> float: ... - @overload - def __truediv__(self, other: float) -> timedelta: ... - def __mod__(self, other: timedelta) -> timedelta: ... - def __divmod__(self, other: timedelta) -> Tuple[int, timedelta]: ... - else: - @overload - def __div__(self, other: timedelta) -> float: ... - @overload - def __div__(self, other: float) -> 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: ... @@ -233,32 +142,17 @@ class datetime(date): max: ClassVar[datetime] resolution: ClassVar[timedelta] - if sys.version_info >= (3, 6): - def __new__( - cls: Type[_S], - year: int, - month: int, - day: int, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> _S: ... - else: - def __new__( - cls: Type[_S], - year: int, - month: int, - day: int, - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - ) -> _S: ... + def __new__( + cls: Type[_S], + year: int, + month: int, + day: int, + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + ) -> _S: ... @property def year(self) -> int: ... @property @@ -275,9 +169,6 @@ class datetime(date): def microsecond(self) -> int: ... @property def tzinfo(self) -> Optional[_tzinfo]: ... - if sys.version_info >= (3, 6): - @property - def fold(self) -> int: ... @classmethod def fromtimestamp(cls: Type[_S], t: float, tz: Optional[_tzinfo] = ...) -> _S: ... @classmethod @@ -286,77 +177,38 @@ class datetime(date): def today(cls: Type[_S]) -> _S: ... @classmethod def fromordinal(cls: Type[_S], n: int) -> _S: ... - if sys.version_info >= (3, 8): - @classmethod - def now(cls: Type[_S], tz: Optional[_tzinfo] = ...) -> _S: ... - else: - @overload - @classmethod - def now(cls: Type[_S], tz: None = ...) -> _S: ... - @overload - @classmethod - def now(cls, tz: _tzinfo) -> datetime: ... + @overload + @classmethod + def now(cls: Type[_S], tz: None = ...) -> _S: ... + @overload + @classmethod + def now(cls, tz: _tzinfo) -> datetime: ... @classmethod def utcnow(cls: Type[_S]) -> _S: ... - if sys.version_info >= (3, 6): - @classmethod - def combine(cls, date: _date, time: _time, tzinfo: Optional[_tzinfo] = ...) -> datetime: ... - else: - @classmethod - def combine(cls, date: _date, time: _time) -> datetime: ... - if sys.version_info >= (3, 7): - @classmethod - def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... + @classmethod + def combine(cls, date: _date, time: _time) -> datetime: ... def strftime(self, fmt: _Text) -> str: ... - if sys.version_info >= (3,): - def __format__(self, fmt: str) -> str: ... - else: - def __format__(self, fmt: AnyStr) -> AnyStr: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def toordinal(self) -> int: ... def timetuple(self) -> struct_time: ... - if sys.version_info >= (3, 3): - def timestamp(self) -> float: ... def utctimetuple(self) -> struct_time: ... def date(self) -> _date: ... def time(self) -> _time: ... def timetz(self) -> _time: ... - if sys.version_info >= (3, 6): - def replace( - self, - year: int = ..., - month: int = ..., - day: int = ..., - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - *, - fold: int = ..., - ) -> datetime: ... - else: - def replace( - self, - year: int = ..., - month: int = ..., - day: int = ..., - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., - ) -> datetime: ... - if sys.version_info >= (3, 8): - def astimezone(self: _S, tz: Optional[_tzinfo] = ...) -> _S: ... - elif sys.version_info >= (3, 3): - def astimezone(self, tz: Optional[_tzinfo] = ...) -> datetime: ... - else: - def astimezone(self, tz: _tzinfo) -> datetime: ... + def replace( + self, + year: int = ..., + month: int = ..., + day: int = ..., + hour: int = ..., + minute: int = ..., + second: int = ..., + microsecond: int = ..., + tzinfo: Optional[_tzinfo] = ..., + ) -> datetime: ... + def astimezone(self, tz: _tzinfo) -> datetime: ... def ctime(self) -> str: ... - if sys.version_info >= (3, 6): - def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... - else: - def isoformat(self, sep: str = ...) -> str: ... + def isoformat(self, sep: str = ...) -> str: ... @classmethod def strptime(cls, date_string: _Text, format: _Text) -> datetime: ... def utcoffset(self) -> Optional[timedelta]: ... @@ -366,12 +218,8 @@ class datetime(date): def __lt__(self, other: datetime) -> bool: ... # type: ignore def __ge__(self, other: datetime) -> bool: ... # type: ignore def __gt__(self, other: datetime) -> bool: ... # type: ignore - if sys.version_info >= (3, 8): - def __add__(self: _S, other: timedelta) -> _S: ... - def __radd__(self: _S, other: timedelta) -> _S: ... - else: - def __add__(self, other: timedelta) -> datetime: ... - def __radd__(self, other: timedelta) -> datetime: ... + def __add__(self, other: timedelta) -> datetime: ... + def __radd__(self, other: timedelta) -> datetime: ... @overload # type: ignore def __sub__(self, other: datetime) -> timedelta: ... @overload @@ -379,7 +227,4 @@ class datetime(date): def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... - if sys.version_info >= (3, 9): - def isocalendar(self) -> _IsoCalendarDate: ... - else: - def isocalendar(self) -> Tuple[int, int, int]: ... + def isocalendar(self) -> Tuple[int, int, int]: ... diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index c3a671d4ba5f..ef5744a49cba 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -5,10 +5,7 @@ from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, T _Decimal = Union[Decimal, int] _DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] -if sys.version_info >= (3,): - _ComparableNum = Union[Decimal, float, numbers.Rational] -else: - _ComparableNum = Union[Decimal, float] +_ComparableNum = Union[Decimal, float] _DecimalT = TypeVar("_DecimalT", bound=Decimal) class DecimalTuple(NamedTuple): @@ -25,16 +22,8 @@ ROUND_UP: str ROUND_HALF_DOWN: str ROUND_05UP: str -if sys.version_info >= (3,): - HAVE_THREADS: bool - MAX_EMAX: int - MAX_PREC: int - MIN_EMIN: int - MIN_ETINY: int - class DecimalException(ArithmeticError): - if sys.version_info < (3,): - def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... + def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... class Clamped(DecimalException): ... class InvalidOperation(DecimalException): ... @@ -49,9 +38,6 @@ class Subnormal(DecimalException): ... class Overflow(Inexact, Rounded): ... class Underflow(Inexact, Rounded, Subnormal): ... -if sys.version_info >= (3,): - class FloatOperation(DecimalException, TypeError): ... - def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... @@ -60,69 +46,38 @@ class Decimal(object): def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... @classmethod def from_float(cls, __f: float) -> Decimal: ... - if sys.version_info >= (3,): - def __bool__(self) -> bool: ... - else: - def __nonzero__(self) -> bool: ... - def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... + def __nonzero__(self) -> bool: ... + def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... - if sys.version_info >= (3, 6): - def as_integer_ratio(self) -> Tuple[int, int]: ... def to_eng_string(self, context: Optional[Context] = ...) -> str: ... - if sys.version_info >= (3,): - def __abs__(self) -> Decimal: ... - def __add__(self, other: _Decimal) -> Decimal: ... - def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... - def __eq__(self, other: object) -> bool: ... - def __floordiv__(self, other: _Decimal) -> Decimal: ... - def __ge__(self, other: _ComparableNum) -> bool: ... - def __gt__(self, other: _ComparableNum) -> bool: ... - def __le__(self, other: _ComparableNum) -> bool: ... - def __lt__(self, other: _ComparableNum) -> bool: ... - def __mod__(self, other: _Decimal) -> Decimal: ... - def __mul__(self, other: _Decimal) -> Decimal: ... - def __neg__(self) -> Decimal: ... - def __pos__(self) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ... - def __radd__(self, other: _Decimal) -> Decimal: ... - def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ... - def __rfloordiv__(self, other: _Decimal) -> Decimal: ... - def __rmod__(self, other: _Decimal) -> Decimal: ... - def __rmul__(self, other: _Decimal) -> Decimal: ... - def __rsub__(self, other: _Decimal) -> Decimal: ... - def __rtruediv__(self, other: _Decimal) -> Decimal: ... - def __str__(self) -> str: ... - def __sub__(self, other: _Decimal) -> Decimal: ... - def __truediv__(self, other: _Decimal) -> Decimal: ... - else: - def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... - def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... - def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... - def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... - def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... + def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... + def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... + def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... + def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... + def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... + def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... + def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... + def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... + def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __float__(self) -> float: ... def __int__(self) -> int: ... @@ -133,26 +88,14 @@ class Decimal(object): def imag(self) -> Decimal: ... def conjugate(self) -> Decimal: ... def __complex__(self) -> complex: ... - if sys.version_info >= (3,): - @overload - def __round__(self) -> int: ... - @overload - def __round__(self, ndigits: int) -> Decimal: ... - def __floor__(self) -> int: ... - def __ceil__(self) -> int: ... - else: - def __long__(self) -> long: ... + def __long__(self) -> long: ... def fma(self, other: _Decimal, third: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __rpow__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def normalize(self, context: Optional[Context] = ...) -> Decimal: ... - if sys.version_info >= (3,): - def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... - def same_quantum(self, other: _Decimal, context: Optional[Context] = ...) -> bool: ... - else: - def quantize( - self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ... - ) -> Decimal: ... - def same_quantum(self, other: _Decimal) -> bool: ... + def quantize( + self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ... + ) -> Decimal: ... + def same_quantum(self, other: _Decimal) -> bool: ... def to_integral_exact(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... def to_integral_value(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... def to_integral(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ... @@ -160,23 +103,13 @@ class Decimal(object): def max(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def min(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def adjusted(self) -> int: ... - if sys.version_info >= (3,): - def canonical(self) -> Decimal: ... - else: - def canonical(self, context: Optional[Context] = ...) -> Decimal: ... + def canonical(self, context: Optional[Context] = ...) -> Decimal: ... def compare_signal(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - if sys.version_info >= (3,): - def compare_total(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def compare_total_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - else: - def compare_total(self, other: _Decimal) -> Decimal: ... - def compare_total_mag(self, other: _Decimal) -> 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: ... - if sys.version_info >= (3,): - def copy_sign(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - else: - def copy_sign(self, other: _Decimal) -> Decimal: ... + def copy_sign(self, other: _Decimal) -> Decimal: ... def exp(self, context: Optional[Context] = ...) -> Decimal: ... def is_canonical(self) -> bool: ... def is_finite(self) -> bool: ... @@ -225,46 +158,22 @@ class Context(object): Emin: int Emax: int capitals: int - if sys.version_info >= (3,): - clamp: int - else: - _clamp: int + _clamp: int traps: Dict[_TrapType, bool] flags: Dict[_TrapType, bool] - if sys.version_info >= (3,): - def __init__( - self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - clamp: Optional[int] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., - ) -> None: ... - else: - def __init__( - self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - _clamp: Optional[int] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., - ) -> None: ... - if sys.version_info >= (3,): - # __setattr__() only allows to set a specific set of attributes, - # already defined above. - def __delattr__(self, name: str) -> None: ... - def __reduce__(self) -> Tuple[Type[Context], Tuple[Any, ...]]: ... + def __init__( + self, + prec: Optional[int] = ..., + rounding: Optional[str] = ..., + traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + Emin: Optional[int] = ..., + Emax: Optional[int] = ..., + capitals: Optional[int] = ..., + _clamp: Optional[int] = ..., + _ignored_flags: Optional[List[_TrapType]] = ..., + ) -> None: ... def clear_flags(self) -> None: ... - if sys.version_info >= (3,): - def clear_traps(self) -> None: ... def copy(self) -> Context: ... def __copy__(self) -> Context: ... __hash__: Any = ... diff --git a/stdlib/@python2/difflib.pyi b/stdlib/@python2/difflib.pyi index 572972ccda9e..d615f3c873da 100644 --- a/stdlib/@python2/difflib.pyi +++ b/stdlib/@python2/difflib.pyi @@ -17,16 +17,10 @@ from typing import ( overload, ) -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") -if sys.version_info >= (3,): - _StrType = Text -else: - # Aliases can't point to type vars, so we need to redeclare AnyStr - _StrType = TypeVar("_StrType", Text, bytes) +# Aliases can't point to type vars, so we need to redeclare AnyStr +_StrType = TypeVar("_StrType", Text, bytes) _JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]] @@ -42,21 +36,13 @@ class SequenceMatcher(Generic[_T]): 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: ... - if sys.version_info >= (3, 9): - def find_longest_match( - self, alo: int = ..., ahi: Optional[int] = ..., blo: int = ..., bhi: Optional[int] = ... - ) -> Match: ... - else: - def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ... + 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: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - # mypy thinks the signatures of the overloads overlap, but the types still work fine @overload def get_close_matches( # type: ignore @@ -105,28 +91,15 @@ class HtmlDiff(object): linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ..., ) -> None: ... - if sys.version_info >= (3, 5): - def make_file( - self, - fromlines: Sequence[_StrType], - tolines: Sequence[_StrType], - fromdesc: _StrType = ..., - todesc: _StrType = ..., - context: bool = ..., - numlines: int = ..., - *, - charset: str = ..., - ) -> _StrType: ... - else: - def make_file( - self, - fromlines: Sequence[_StrType], - tolines: Sequence[_StrType], - fromdesc: _StrType = ..., - todesc: _StrType = ..., - context: bool = ..., - numlines: int = ..., - ) -> _StrType: ... + 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], @@ -139,15 +112,3 @@ class HtmlDiff(object): def restore(delta: Iterable[_StrType], which: int) -> Iterator[_StrType]: ... -if sys.version_info >= (3, 5): - def diff_bytes( - dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]], - a: Sequence[bytes], - b: Sequence[bytes], - fromfile: bytes = ..., - tofile: bytes = ..., - fromfiledate: bytes = ..., - tofiledate: bytes = ..., - n: int = ..., - lineterm: bytes = ..., - ) -> Iterator[bytes]: ... diff --git a/stdlib/@python2/dis.pyi b/stdlib/@python2/dis.pyi index b52d0ed624f6..63edc4b85def 100644 --- a/stdlib/@python2/dis.pyi +++ b/stdlib/@python2/dis.pyi @@ -16,68 +16,20 @@ from opcode import ( ) from typing import IO, Any, Callable, Dict, Iterator, List, NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3, 4): - from opcode import stack_effect as stack_effect - -if sys.version_info >= (3, 6): - from opcode import hasnargs as hasnargs - # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) _have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type, Callable[..., Any]] _have_code_or_string = Union[_have_code, str, bytes] -if sys.version_info >= (3, 4): - class Instruction(NamedTuple): - opname: str - opcode: int - arg: Optional[int] - argval: Any - argrepr: str - offset: int - starts_line: Optional[int] - is_jump_target: bool - class Bytecode: - codeobj: types.CodeType - first_line: int - def __init__( - self, x: _have_code_or_string, *, first_line: Optional[int] = ..., current_offset: Optional[int] = ... - ) -> None: ... - def __iter__(self) -> Iterator[Instruction]: ... - def __repr__(self) -> str: ... - def info(self) -> str: ... - def dis(self) -> str: ... - @classmethod - def from_traceback(cls, tb: types.TracebackType) -> Bytecode: ... - COMPILER_FLAG_NAMES: Dict[int, str] def findlabels(code: _have_code) -> List[int]: ... def findlinestarts(code: _have_code) -> Iterator[Tuple[int, int]]: ... -if sys.version_info >= (3, 0): - def pretty_flags(flags: int) -> str: ... - def code_info(x: _have_code_or_string) -> str: ... - -if sys.version_info >= (3, 7): - def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ..., depth: Optional[int] = ...) -> None: ... +def dis(x: _have_code_or_string = ...) -> None: ... -elif sys.version_info >= (3, 4): - def dis(x: Optional[_have_code_or_string] = ..., *, file: Optional[IO[str]] = ...) -> None: ... - -else: - def dis(x: _have_code_or_string = ...) -> None: ... - -if sys.version_info >= (3, 4): - def distb(tb: Optional[types.TracebackType] = ..., *, file: Optional[IO[str]] = ...) -> None: ... - def disassemble(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... - def disco(co: _have_code, lasti: int = ..., *, file: Optional[IO[str]] = ...) -> None: ... - def show_code(co: _have_code, *, file: Optional[IO[str]] = ...) -> None: ... - def get_instructions(x: _have_code, *, first_line: Optional[int] = ...) -> Iterator[Instruction]: ... - -else: - def distb(tb: types.TracebackType = ...) -> None: ... - def disassemble(co: _have_code, lasti: int = ...) -> None: ... - def disco(co: _have_code, lasti: int = ...) -> None: ... - if sys.version_info >= (3, 0): - def show_code(co: _have_code) -> None: ... +def distb(tb: types.TracebackType = ...) -> None: ... +def disassemble(co: _have_code, lasti: int = ...) -> None: ... +def disco(co: _have_code, lasti: int = ...) -> None: ... +if sys.version_info >= (3, 0): + def show_code(co: _have_code) -> None: ... diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index ae84c2c25efc..5e10f2c5ecea 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -24,9 +24,6 @@ REPORT_UDIFF: int REPORT_CDIFF: int REPORT_NDIFF: int REPORT_ONLY_FIRST_FAILURE: int -if sys.version_info >= (3, 4): - FAIL_FAST: int - REPORTING_FLAGS: int BLANKLINE_MARKER: str @@ -189,11 +186,7 @@ class SkipDocTestCase(DocTestCase): def test_skip(self) -> None: ... def shortDescription(self) -> str: ... -if sys.version_info >= (3, 4): - class _DocTestSuite(unittest.TestSuite): ... - -else: - _DocTestSuite = unittest.TestSuite +_DocTestSuite = unittest.TestSuite def DocTestSuite( module: Union[None, str, types.ModuleType] = ..., diff --git a/stdlib/@python2/ensurepip/__init__.pyi b/stdlib/@python2/ensurepip/__init__.pyi index a411dbb456d2..83fd43ff002e 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -3,23 +3,11 @@ from typing import Optional def version() -> str: ... -if sys.version_info >= (3, 0): - def bootstrap( - *, - root: Optional[str] = ..., - upgrade: bool = ..., - user: bool = ..., - altinstall: bool = ..., - default_pip: bool = ..., - verbosity: int = ..., - ) -> None: ... - -else: - def bootstrap( - root: Optional[str] = ..., - upgrade: bool = ..., - user: bool = ..., - altinstall: bool = ..., - default_pip: bool = ..., - verbosity: int = ..., - ) -> None: ... +def bootstrap( + root: Optional[str] = ..., + upgrade: bool = ..., + user: bool = ..., + altinstall: bool = ..., + default_pip: bool = ..., + verbosity: int = ..., +) -> None: ... diff --git a/stdlib/@python2/filecmp.pyi b/stdlib/@python2/filecmp.pyi index b05eebac07c9..5767ada0bd08 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -1,44 +1,17 @@ import sys from typing import Any, AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Text, Tuple, Union -if sys.version_info >= (3, 6): - from os import PathLike - -if sys.version_info >= (3, 9): - from types import GenericAlias - DEFAULT_IGNORES: List[str] -if sys.version_info >= (3, 6): - def cmp( - f1: Union[bytes, Text, PathLike[AnyStr]], f2: Union[bytes, Text, PathLike[AnyStr]], shallow: Union[int, bool] = ... - ) -> bool: ... - def cmpfiles( - a: Union[AnyStr, PathLike[AnyStr]], - b: Union[AnyStr, PathLike[AnyStr]], - common: Iterable[AnyStr], - shallow: Union[int, bool] = ..., - ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... - -else: - def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ... - def cmpfiles( - a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: Union[int, bool] = ... - ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... +def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ... +def cmpfiles( + a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: Union[int, bool] = ... +) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... class dircmp(Generic[AnyStr]): - if sys.version_info >= (3, 6): - def __init__( - self, - a: Union[AnyStr, PathLike[AnyStr]], - b: Union[AnyStr, PathLike[AnyStr]], - ignore: Optional[Sequence[AnyStr]] = ..., - hide: Optional[Sequence[AnyStr]] = ..., - ) -> None: ... - else: - def __init__( - self, a: AnyStr, b: AnyStr, ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ... - ) -> None: ... + def __init__( + self, a: AnyStr, b: AnyStr, ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ... + ) -> None: ... left: AnyStr right: AnyStr hide: Sequence[AnyStr] @@ -66,8 +39,3 @@ class dircmp(Generic[AnyStr]): def phase3(self) -> None: ... def phase4(self) -> None: ... def phase4_closure(self) -> None: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - -if sys.version_info >= (3,): - def clear_cache() -> None: ... diff --git a/stdlib/@python2/fileinput.pyi b/stdlib/@python2/fileinput.pyi index fbb602b3bf45..bd6050523553 100644 --- a/stdlib/@python2/fileinput.pyi +++ b/stdlib/@python2/fileinput.pyi @@ -2,25 +2,14 @@ import sys from _typeshed import AnyPath from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Optional, Union -if sys.version_info >= (3, 8): - def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., - inplace: bool = ..., - backup: str = ..., - *, - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> FileInput[AnyStr]: ... - -else: - def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> FileInput[AnyStr]: ... +def input( + files: Union[AnyPath, Iterable[AnyPath], None] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., +) -> FileInput[AnyStr]: ... def close() -> None: ... def nextfile() -> None: ... @@ -32,31 +21,17 @@ def isfirstline() -> bool: ... def isstdin() -> bool: ... class FileInput(Iterable[AnyStr], Generic[AnyStr]): - if sys.version_info >= (3, 8): - def __init__( - self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., - inplace: bool = ..., - backup: str = ..., - *, - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> None: ... - else: - def __init__( - self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., - ) -> None: ... + def __init__( + self, + files: Union[None, AnyPath, Iterable[AnyPath]] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... - if sys.version_info >= (3, 2): - def __enter__(self) -> FileInput[AnyStr]: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... def __iter__(self) -> Iterator[AnyStr]: ... def __next__(self) -> AnyStr: ... def __getitem__(self, i: int) -> AnyStr: ... @@ -71,8 +46,4 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): def hook_compressed(filename: AnyPath, mode: str) -> IO[Any]: ... -if sys.version_info >= (3, 6): - def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[AnyPath, str], IO[Any]]: ... - -else: - def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... +def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index 75cfa48a1cf6..a51fcda41e3e 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -7,15 +7,14 @@ from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] _T = TypeVar("_T") -if sys.version_info < (3, 9): - @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: ... +@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 @@ -33,8 +32,6 @@ class Fraction(Rational): @classmethod def from_decimal(cls, dec: Decimal) -> Fraction: ... def limit_denominator(self, max_denominator: int = ...) -> Fraction: ... - if sys.version_info >= (3, 8): - def as_integer_ratio(self) -> Tuple[int, int]: ... @property def numerator(self) -> int: ... @property @@ -87,19 +84,18 @@ class Fraction(Rational): def __rtruediv__(self, other: float) -> float: ... @overload def __rtruediv__(self, other: complex) -> complex: ... - if sys.version_info < (3, 0): - @overload - def __div__(self, other: Union[int, Fraction]) -> Fraction: ... - @overload - def __div__(self, other: float) -> float: ... - @overload - def __div__(self, other: complex) -> complex: ... - @overload - def __rdiv__(self, other: Union[int, Fraction]) -> Fraction: ... - @overload - def __rdiv__(self, other: float) -> float: ... - @overload - def __rdiv__(self, other: complex) -> complex: ... + @overload + def __div__(self, other: Union[int, Fraction]) -> Fraction: ... + @overload + def __div__(self, other: float) -> float: ... + @overload + def __div__(self, other: complex) -> complex: ... + @overload + def __rdiv__(self, other: Union[int, Fraction]) -> Fraction: ... + @overload + def __rdiv__(self, other: float) -> float: ... + @overload + def __rdiv__(self, other: complex) -> complex: ... @overload def __floordiv__(self, other: Union[int, Fraction]) -> int: ... @overload @@ -138,23 +134,13 @@ class Fraction(Rational): def __neg__(self) -> Fraction: ... def __abs__(self) -> Fraction: ... def __trunc__(self) -> int: ... - if sys.version_info >= (3, 0): - def __floor__(self) -> int: ... - def __ceil__(self) -> int: ... - @overload - def __round__(self, ndigits: None = ...) -> int: ... - @overload - def __round__(self, ndigits: int) -> Fraction: ... 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: ... - if sys.version_info >= (3, 0): - def __bool__(self) -> bool: ... - else: - def __nonzero__(self) -> bool: ... + def __nonzero__(self) -> bool: ... # Not actually defined within fractions.py, but provides more useful # overrides @property diff --git a/stdlib/@python2/ftplib.pyi b/stdlib/@python2/ftplib.pyi index bdb1716549c0..7658630f2b58 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -13,9 +13,6 @@ MSG_OOB: int FTP_PORT: int MAXLINE: int CRLF: str -if sys.version_info >= (3,): - B_CRLF: bytes - class Error(Exception): ... class error_reply(Error): ... class error_temp(Error): ... @@ -40,35 +37,12 @@ class FTP: af: int lastresp: str - if sys.version_info >= (3,): - file: Optional[TextIO] - encoding: str - def __enter__(self: _T) -> _T: ... - def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> None: ... - else: - file: Optional[BinaryIO] + file: Optional[BinaryIO] - if sys.version_info >= (3, 3): - source_address: Optional[Tuple[str, int]] - def __init__( - self, - host: Text = ..., - user: Text = ..., - passwd: Text = ..., - acct: Text = ..., - timeout: float = ..., - source_address: Optional[Tuple[str, int]] = ..., - ) -> None: ... - def connect( - self, host: Text = ..., port: int = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ... - ) -> str: ... - else: - 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 __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: ... @@ -108,8 +82,6 @@ class FTP: def nlst(self, *args: Text) -> List[str]: ... # Technically only the last arg can be a Callable but ... def dir(self, *args: Union[str, Callable[[str], None]]) -> None: ... - if sys.version_info >= (3, 3): - def mlsd(self, path: Text = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, Dict[str, str]]]: ... def rename(self, fromname: Text, toname: Text) -> str: ... def delete(self, filename: Text) -> str: ... def cwd(self, dirname: Text) -> str: ... @@ -141,16 +113,12 @@ class FTP_TLS(FTP): def auth(self) -> str: ... def prot_p(self) -> str: ... def prot_c(self) -> str: ... - if sys.version_info >= (3, 3): - def ccc(self) -> str: ... - -if sys.version_info < (3,): - class Netrc: - def __init__(self, filename: Optional[Text] = ...) -> None: ... - def get_hosts(self) -> List[str]: ... - def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ... - def get_macros(self) -> List[str]: ... - def get_macro(self, macro: Text) -> Tuple[str, ...]: ... +class Netrc: + def __init__(self, filename: Optional[Text] = ...) -> None: ... + def get_hosts(self) -> List[str]: ... + def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ... + def get_macros(self) -> List[str]: ... + def get_macro(self, macro: Text) -> Tuple[str, ...]: ... def parse150(resp: str) -> Optional[int]: ... # undocumented def parse227(resp: str) -> Tuple[str, int]: ... # undocumented diff --git a/stdlib/@python2/genericpath.pyi b/stdlib/@python2/genericpath.pyi index 17a0df575c56..04b9884998e4 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -26,7 +26,3 @@ def getatime(filename: AnyPath) -> float: ... def getmtime(filename: AnyPath) -> float: ... def getctime(filename: AnyPath) -> float: ... -if sys.version_info >= (3, 4): - def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... - def sameopenfile(fp1: int, fp2: int) -> bool: ... - def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/@python2/hmac.pyi b/stdlib/@python2/hmac.pyi index ca4013da7879..db12da93f9dc 100644 --- a/stdlib/@python2/hmac.pyi +++ b/stdlib/@python2/hmac.pyi @@ -9,26 +9,9 @@ _DigestMod = Union[str, Callable[[], _Hash], ModuleType] digest_size: None -if sys.version_info >= (3, 8): - # In reality digestmod has a default value, but the function always throws an error - # if the argument is not given, so we pretend it is a required argument. - @overload - def new(key: bytes, msg: Optional[ReadableBuffer], digestmod: _DigestMod) -> HMAC: ... - @overload - def new(key: bytes, *, digestmod: _DigestMod) -> HMAC: ... - -elif sys.version_info >= (3, 4): - def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... - -else: - def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... +def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... class HMAC: - if sys.version_info >= (3,): - digest_size: int - if sys.version_info >= (3, 4): - block_size: int - name: str def __init__(self, key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: _DigestMod = ...) -> None: ... def update(self, msg: ReadableBuffer) -> None: ... def digest(self) -> bytes: ... @@ -40,5 +23,3 @@ 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: str) -> bytes: ... diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index bb9e9c6db132..2ce3edaf78ff 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -31,12 +31,8 @@ class IMAP4: welcome: bytes = ... capabilities: Tuple[str] = ... PROTOCOL_VERSION: str = ... - if sys.version_info >= (3, 9): - def __init__(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... - def open(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ... - else: - def __init__(self, host: str = ..., port: int = ...) -> None: ... - def open(self, host: str = ..., port: int = ...) -> None: ... + 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 = ... @@ -58,10 +54,6 @@ class IMAP4: def create(self, mailbox: str) -> _CommandResults: ... def delete(self, mailbox: str) -> _CommandResults: ... def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... - if sys.version_info >= (3, 5): - def enable(self, capability: str) -> _CommandResults: ... - def __enter__(self) -> IMAP4: ... - def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... @@ -85,54 +77,27 @@ class IMAP4: 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: ... - if sys.version_info >= (3,): - def starttls(self, ssl_context: Optional[Any] = ...) -> Tuple[Literal["OK"], List[None]]: ... 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: ... - if sys.version_info >= (3, 9): - def unselect(self) -> _CommandResults: ... def xatom(self, name: str, *args: str) -> _CommandResults: ... def print_log(self) -> None: ... class IMAP4_SSL(IMAP4): keyfile: str = ... certfile: str = ... - if sys.version_info >= (3, 9): - def __init__( - self, - host: str = ..., - port: int = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - ssl_context: Optional[SSLContext] = ..., - timeout: Optional[float] = ..., - ) -> None: ... - elif sys.version_info >= (3, 3): - def __init__( - self, - host: str = ..., - port: int = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - ssl_context: Optional[SSLContext] = ..., - ) -> None: ... - else: - def __init__( - self, host: str = ..., port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ... - ) -> None: ... + def __init__( + self, host: str = ..., port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ... + ) -> None: ... host: str = ... port: int = ... sock: _socket = ... sslobj: SSLSocket = ... file: IO[Any] = ... - if sys.version_info >= (3, 9): - def open(self, host: str = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... - else: - def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... + def open(self, host: str = ..., port: Optional[int] = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... @@ -150,10 +115,7 @@ class IMAP4_stream(IMAP4): process: subprocess.Popen[bytes] = ... writefile: IO[Any] = ... readfile: IO[Any] = ... - if sys.version_info >= (3, 9): - def open(self, host: Optional[str] = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ... - else: - def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ... + def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... diff --git a/stdlib/@python2/imghdr.pyi b/stdlib/@python2/imghdr.pyi index ffdbbf20e97b..77b1fc75e583 100644 --- a/stdlib/@python2/imghdr.pyi +++ b/stdlib/@python2/imghdr.pyi @@ -7,10 +7,7 @@ class _ReadableBinary(Protocol): def read(self, size: int) -> bytes: ... def seek(self, offset: int) -> Any: ... -if sys.version_info >= (3, 6): - _File = Union[Text, os.PathLike[Text], _ReadableBinary] -else: - _File = Union[Text, _ReadableBinary] +_File = Union[Text, _ReadableBinary] @overload def what(file: _File, h: None = ...) -> Optional[str]: ... diff --git a/stdlib/@python2/ipaddress.pyi b/stdlib/@python2/ipaddress.pyi index b4e2b2c4b3f9..a742ac76be7d 100644 --- a/stdlib/@python2/ipaddress.pyi +++ b/stdlib/@python2/ipaddress.pyi @@ -87,9 +87,6 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): def overlaps(self, other: _BaseNetwork[_A]) -> bool: ... @property def prefixlen(self) -> int: ... - if sys.version_info >= (3, 7): - def subnet_of(self: _T, other: _T) -> bool: ... - def supernet_of(self: _T, other: _T) -> bool: ... def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ... def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ... @property diff --git a/stdlib/@python2/keyword.pyi b/stdlib/@python2/keyword.pyi index 3e095ed5f94c..fb113141222e 100644 --- a/stdlib/@python2/keyword.pyi +++ b/stdlib/@python2/keyword.pyi @@ -5,6 +5,3 @@ def iskeyword(s: Text) -> bool: ... kwlist: Sequence[str] -if sys.version_info >= (3, 9): - def issoftkeyword(s: str) -> bool: ... - softkwlist: Sequence[str] diff --git a/stdlib/@python2/lib2to3/pgen2/token.pyi b/stdlib/@python2/lib2to3/pgen2/token.pyi index 19660cb0ce26..a933c291b32d 100644 --- a/stdlib/@python2/lib2to3/pgen2/token.pyi +++ b/stdlib/@python2/lib2to3/pgen2/token.pyi @@ -54,13 +54,6 @@ DOUBLESLASHEQUAL: int OP: int COMMENT: int NL: int -if sys.version_info >= (3,): - RARROW: int -if sys.version_info >= (3, 5): - AT: int - ATEQUAL: int - AWAIT: int - ASYNC: int ERRORTOKEN: int N_TOKENS: int NT_OFFSET: int diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 955763588cd1..2f52b66d45c9 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -36,9 +36,8 @@ class Base: def leaves(self) -> Iterator[Leaf]: ... def depth(self) -> int: ... def get_suffix(self) -> Text: ... - if sys.version_info < (3,): - def get_prefix(self) -> Text: ... - def set_prefix(self, prefix: Text) -> None: ... + def get_prefix(self) -> Text: ... + def set_prefix(self, prefix: Text) -> None: ... class Node(Base): fixers_applied: List[Any] diff --git a/stdlib/@python2/linecache.pyi b/stdlib/@python2/linecache.pyi index f52267bdba98..62c94d4b9770 100644 --- a/stdlib/@python2/linecache.pyi +++ b/stdlib/@python2/linecache.pyi @@ -9,5 +9,3 @@ def getlines(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> def checkcache(filename: Optional[Text] = ...) -> None: ... def updatecache(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... -if sys.version_info >= (3, 5): - def lazycache(filename: Text, module_globals: _ModuleGlobals) -> bool: ... diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 9be4aa2735e1..1d1ec020e707 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -3,10 +3,7 @@ from decimal import Decimal from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union # workaround for mypy#2010 -if sys.version_info >= (3, 0): - from builtins import str as _str -else: - from __builtin__ import str as _str +from __builtin__ import str as _str CODESET: int D_T_FMT: int @@ -91,17 +88,10 @@ def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... def format(percent: _str, value: Union[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 = ...) -> _str: ... def currency(val: Union[int, float, Decimal], symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ... -if sys.version_info >= (3, 5): - def delocalize(string: _str) -> _str: ... - def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... def str(val: float) -> _str: ... diff --git a/stdlib/@python2/macpath.pyi b/stdlib/@python2/macpath.pyi index 296f3a9ba151..3604ed501a68 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -11,9 +11,6 @@ from genericpath import ( isfile as isfile, ) -if sys.version_info >= (3, 4): - from genericpath import samefile as samefile, sameopenfile as sameopenfile, samestat as samestat - # Re-export common definitions from posixpath to reduce duplication from posixpath import ( abspath as abspath, @@ -36,69 +33,27 @@ from typing import AnyStr, Optional, Text, Tuple, overload altsep: Optional[str] -if sys.version_info >= (3, 6): - from os import PathLike - @overload - def basename(s: PathLike[AnyStr]) -> AnyStr: ... - @overload - def basename(s: AnyStr) -> AnyStr: ... - @overload - def dirname(s: PathLike[AnyStr]) -> AnyStr: ... - @overload - def dirname(s: AnyStr) -> AnyStr: ... - @overload - def normcase(path: PathLike[AnyStr]) -> AnyStr: ... - @overload - def normcase(path: AnyStr) -> AnyStr: ... - @overload - def normpath(s: PathLike[AnyStr]) -> AnyStr: ... - @overload - def normpath(s: AnyStr) -> AnyStr: ... - @overload - def realpath(path: PathLike[AnyStr]) -> AnyStr: ... - @overload - def realpath(path: AnyStr) -> AnyStr: ... - -else: - 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 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: AnyPath) -> bool: ... -if sys.version_info >= (3, 6): - # Mypy complains that the signatures overlap, but things seem to behave correctly anyway. - @overload - def join(s: StrPath, *paths: StrPath) -> Text: ... - @overload - def join(s: BytesPath, *paths: BytesPath) -> bytes: ... - -elif sys.version_info >= (3, 0): - def join(s: AnyStr, *paths: AnyStr) -> AnyStr: ... - -else: - # 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: AnyPath) -> Text: ... - @overload - def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... - @overload - def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... - @overload - def join(__p1: Text, *p: AnyPath) -> Text: ... - -if sys.version_info >= (3, 6): - @overload - def split(s: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... - @overload - def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... - -else: - def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +# 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: AnyPath) -> Text: ... +@overload +def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... +@overload +def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... +@overload +def join(__p1: Text, *p: AnyPath) -> Text: ... + +def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index d968e7d77244..3bef884d0d5e 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -25,9 +25,6 @@ from typing import ( ) from typing_extensions import Literal -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") _MessageT = TypeVar("_MessageT", bound=Message) _MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]] @@ -80,9 +77,6 @@ class Mailbox(Generic[_MessageT]): def lock(self) -> None: ... def unlock(self) -> None: ... def close(self) -> None: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - class Maildir(Mailbox[MaildirMessage]): colon: str @@ -190,9 +184,6 @@ class _ProxyFile(Generic[AnyStr]): def flush(self) -> None: ... @property def closed(self) -> bool: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - class _PartialFile(_ProxyFile[AnyStr]): def __init__(self, f: IO[AnyStr], start: Optional[int] = ..., stop: Optional[int] = ...) -> None: ... diff --git a/stdlib/@python2/math.pyi b/stdlib/@python2/math.pyi index 6f9a89996dc0..e7234d4d5569 100644 --- a/stdlib/@python2/math.pyi +++ b/stdlib/@python2/math.pyi @@ -3,12 +3,6 @@ from typing import Iterable, Optional, SupportsFloat, SupportsInt, Tuple, overlo e: float pi: float -if sys.version_info >= (3, 5): - inf: float - nan: float -if sys.version_info >= (3, 6): - tau: float - def acos(__x: SupportsFloat) -> float: ... def acosh(__x: SupportsFloat) -> float: ... def asin(__x: SupportsFloat) -> float: ... @@ -17,23 +11,13 @@ def atan(__x: SupportsFloat) -> float: ... def atan2(__y: SupportsFloat, __x: SupportsFloat) -> float: ... def atanh(__x: SupportsFloat) -> float: ... -if sys.version_info >= (3,): - def ceil(__x: SupportsFloat) -> int: ... - -else: - def ceil(__x: SupportsFloat) -> float: ... - -if sys.version_info >= (3, 8): - def comb(__n: int, __k: int) -> int: ... +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: ... -if sys.version_info >= (3, 8): - def dist(__p: Iterable[SupportsFloat], __q: Iterable[SupportsFloat]) -> float: ... - def erf(__x: SupportsFloat) -> float: ... def erfc(__x: SupportsFloat) -> float: ... def exp(__x: SupportsFloat) -> float: ... @@ -41,75 +25,31 @@ def expm1(__x: SupportsFloat) -> float: ... def fabs(__x: SupportsFloat) -> float: ... def factorial(__x: SupportsInt) -> int: ... -if sys.version_info >= (3,): - def floor(__x: SupportsFloat) -> int: ... - -else: - def floor(__x: SupportsFloat) -> float: ... +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: ... -if sys.version_info >= (3, 9): - def gcd(*integers: int) -> int: ... - -elif sys.version_info >= (3, 5): - def gcd(__x: int, __y: int) -> int: ... - -if sys.version_info >= (3, 8): - def hypot(*coordinates: SupportsFloat) -> float: ... - -else: - def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... - -if sys.version_info >= (3, 5): - def isclose(a: SupportsFloat, b: SupportsFloat, *, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... +def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... def isinf(__x: SupportsFloat) -> bool: ... -if sys.version_info >= (3,): - def isfinite(__x: SupportsFloat) -> bool: ... - def isnan(__x: SupportsFloat) -> bool: ... -if sys.version_info >= (3, 8): - def isqrt(__n: int) -> int: ... - -if sys.version_info >= (3, 9): - def lcm(*integers: int) -> int: ... - 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: ... -if sys.version_info >= (3, 3): - def log2(__x: SupportsFloat) -> float: ... - def modf(__x: SupportsFloat) -> Tuple[float, float]: ... -if sys.version_info >= (3, 9): - def nextafter(__x: SupportsFloat, __y: SupportsFloat) -> float: ... - -if sys.version_info >= (3, 8): - def perm(__n: int, __k: Optional[int] = ...) -> int: ... - def pow(__x: SupportsFloat, __y: SupportsFloat) -> float: ... -if sys.version_info >= (3, 8): - @overload - def prod(__iterable: Iterable[int], *, start: int = ...) -> int: ... # type: ignore - @overload - def prod(__iterable: Iterable[SupportsFloat], *, start: SupportsFloat = ...) -> float: ... - def radians(__x: SupportsFloat) -> float: ... -if sys.version_info >= (3, 7): - def remainder(__x: SupportsFloat, __y: SupportsFloat) -> float: ... - def sin(__x: SupportsFloat) -> float: ... def sinh(__x: SupportsFloat) -> float: ... def sqrt(__x: SupportsFloat) -> float: ... @@ -117,5 +57,3 @@ def tan(__x: SupportsFloat) -> float: ... def tanh(__x: SupportsFloat) -> float: ... def trunc(__x: SupportsFloat) -> int: ... -if sys.version_info >= (3, 9): - def ulp(__x: SupportsFloat) -> float: ... diff --git a/stdlib/@python2/mimetypes.pyi b/stdlib/@python2/mimetypes.pyi index f0cfac32cafd..f4c7b6132d2f 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -1,12 +1,7 @@ import sys from typing import IO, Dict, List, Optional, Sequence, Text, Tuple, Union -if sys.version_info >= (3, 8): - from os import PathLike - def guess_type(url: Union[Text, PathLike[str]], strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... - -else: - def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... +def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> Optional[str]: ... diff --git a/stdlib/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index 0ba69e5896d7..485ddcdc2545 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -34,10 +34,7 @@ class _mmap(Generic[AnyStr]): self, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = ..., offset: int = ... ) -> None: ... def close(self) -> None: ... - if sys.version_info >= (3, 8): - def flush(self, offset: int = ..., size: int = ...) -> None: ... - else: - def flush(self, offset: int = ..., size: int = ...) -> int: ... + def flush(self, offset: int = ..., size: int = ...) -> int: ... def move(self, dest: int, src: int, count: int) -> None: ... def read_byte(self) -> AnyStr: ... def readline(self) -> AnyStr: ... @@ -48,73 +45,13 @@ class _mmap(Generic[AnyStr]): def write_byte(self, byte: AnyStr) -> None: ... def __len__(self) -> int: ... -if sys.version_info >= (3,): - class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], Sized): - closed: bool - if sys.version_info >= (3, 8) and sys.platform != "win32": - def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ... - def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... - def read(self, n: Optional[int] = ...) -> bytes: ... - if sys.version_info >= (3, 6): - def write(self, bytes: ReadableBuffer) -> int: ... - else: - def write(self, bytes: ReadableBuffer) -> None: ... - @overload - def __getitem__(self, index: int) -> int: ... - @overload - def __getitem__(self, index: slice) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... - @overload - def __setitem__(self, index: int, object: int) -> None: ... - @overload - def __setitem__(self, index: slice, object: bytes) -> None: ... - # Doesn't actually exist, but the object is actually iterable because it has __getitem__ and - # __len__, so we claim that there is also an __iter__ to help type checkers. - def __iter__(self) -> Iterator[bytes]: ... - -else: - class mmap(_mmap[bytes], Sequence[bytes]): - 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: Union[int, slice]) -> bytes: ... - def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... - def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... - -if sys.version_info >= (3, 8) and sys.platform != "win32": - MADV_NORMAL: int - MADV_RANDOM: int - MADV_SEQUENTIAL: int - MADV_WILLNEED: int - MADV_DONTNEED: int - - if sys.platform == "linux": - MADV_REMOVE: int - MADV_DONTFORK: int - MADV_DOFORK: int - MADV_HWPOISON: int - MADV_MERGEABLE: int - MADV_UNMERGEABLE: int - # Seems like this constant is not defined in glibc. - # See https://github.com/python/typeshed/pull/5360 for details - # MADV_SOFT_OFFLINE: int - MADV_HUGEPAGE: int - MADV_NOHUGEPAGE: int - MADV_DONTDUMP: int - MADV_DODUMP: int - MADV_FREE: int - - # This Values are defined for FreeBSD but type checkers do not support conditions for these - if sys.platform != "linux" and sys.platform != "darwin": - MADV_NOSYNC: int - MADV_AUTOSYNC: int - MADV_NOCORE: int - MADV_CORE: int - MADV_PROTECT: int +class mmap(_mmap[bytes], Sequence[bytes]): + 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: Union[int, slice]) -> bytes: ... + def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... + def __delitem__(self, index: Union[int, slice]) -> None: ... + def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... -if sys.version_info >= (3, 10) and sys.platform == "darwin": - MADV_FREE_REUSABLE: int - MADV_FREE_REUSE: int diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index 89119b6029df..b8884b8b62bf 100644 --- a/stdlib/@python2/modulefinder.pyi +++ b/stdlib/@python2/modulefinder.pyi @@ -31,22 +31,13 @@ class ModuleFinder: excludes: Container[str] # undocumented replace_paths: Sequence[Tuple[str, str]] # undocumented - if sys.version_info >= (3, 8): - def __init__( - self, - path: Optional[List[str]] = ..., - debug: int = ..., - excludes: Optional[Container[str]] = ..., - replace_paths: Optional[Sequence[Tuple[str, str]]] = ..., - ) -> None: ... - else: - def __init__( - self, - path: Optional[List[str]] = ..., - debug: int = ..., - excludes: Container[str] = ..., - replace_paths: Sequence[Tuple[str, str]] = ..., - ) -> None: ... + def __init__( + self, + path: Optional[List[str]] = ..., + 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 @@ -62,8 +53,6 @@ class ModuleFinder: def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented def import_module(self, partname: str, fqname: str, parent: Module) -> Optional[Module]: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: Tuple[str, str, str]) -> Module: ... # undocumented - if sys.version_info >= (3, 6): - def scan_opcodes(self, co: CodeType) -> Iterator[Tuple[str, Tuple[Any, ...]]]: ... # 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 diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index 0442ffaaec83..c783493f315e 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -7,8 +7,7 @@ if sys.platform == "win32": from _msi import _Database AMD64: bool - if sys.version_info < (3, 7): - Itanium: bool + Itanium: bool Win64: bool datasizemask: Literal[0x00FF] diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index 36fe063c8486..cb52934f9f17 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -74,9 +74,8 @@ class _NNTPBase: def over( self, message_spec: Union[None, str, List[Any], Tuple[Any, ...]], *, file: _File = ... ) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... - if sys.version_info < (3, 9): - def xgtitle(self, group: str, *, file: _File = ...) -> Tuple[str, List[Tuple[str, str]]]: ... - def xpath(self, id: Any) -> Tuple[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: Union[bytes, Iterable[bytes]]) -> str: ... def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ... diff --git a/stdlib/@python2/numbers.pyi b/stdlib/@python2/numbers.pyi index 4f8a5a5d67fc..796b44366aa3 100644 --- a/stdlib/@python2/numbers.pyi +++ b/stdlib/@python2/numbers.pyi @@ -12,10 +12,7 @@ class Number(metaclass=ABCMeta): class Complex(Number): @abstractmethod def __complex__(self) -> complex: ... - if sys.version_info >= (3, 0): - def __bool__(self) -> bool: ... - else: - def __nonzero__(self) -> bool: ... + def __nonzero__(self) -> bool: ... @property @abstractmethod def real(self) -> Any: ... @@ -36,11 +33,10 @@ class Complex(Number): def __mul__(self, other: Any) -> Any: ... @abstractmethod def __rmul__(self, other: Any) -> Any: ... - if sys.version_info < (3, 0): - @abstractmethod - def __div__(self, other): ... - @abstractmethod - def __rdiv__(self, other): ... + @abstractmethod + def __div__(self, other): ... + @abstractmethod + def __rdiv__(self, other): ... @abstractmethod def __truediv__(self, other: Any) -> Any: ... @abstractmethod @@ -52,25 +48,13 @@ class Complex(Number): def __abs__(self) -> Real: ... def conjugate(self) -> Any: ... def __eq__(self, other: Any) -> bool: ... - if sys.version_info < (3, 0): - def __ne__(self, other: Any) -> bool: ... + def __ne__(self, other: Any) -> bool: ... class Real(Complex, SupportsFloat): @abstractmethod def __float__(self) -> float: ... @abstractmethod def __trunc__(self) -> int: ... - if sys.version_info >= (3, 0): - @abstractmethod - def __floor__(self) -> int: ... - @abstractmethod - def __ceil__(self) -> int: ... - @abstractmethod - @overload - def __round__(self, ndigits: None = ...) -> int: ... - @abstractmethod - @overload - def __round__(self, ndigits: int) -> Any: ... def __divmod__(self, other: Any) -> Any: ... def __rdivmod__(self, other: Any) -> Any: ... @abstractmethod @@ -102,12 +86,8 @@ class Rational(Real): def __float__(self) -> float: ... class Integral(Rational): - if sys.version_info >= (3, 0): - @abstractmethod - def __int__(self) -> int: ... - else: - @abstractmethod - def __long__(self) -> long: ... + @abstractmethod + def __long__(self) -> long: ... def __index__(self) -> int: ... @abstractmethod def __pow__(self, exponent: Any, modulus: Optional[Any] = ...) -> Any: ... diff --git a/stdlib/@python2/opcode.pyi b/stdlib/@python2/opcode.pyi index 6307c280aebe..6cf9835514dc 100644 --- a/stdlib/@python2/opcode.pyi +++ b/stdlib/@python2/opcode.pyi @@ -15,11 +15,3 @@ opmap: Dict[str, int] HAVE_ARGUMENT: int EXTENDED_ARG: int -if sys.version_info >= (3, 8): - def stack_effect(__opcode: int, __oparg: Optional[int] = ..., *, jump: Optional[bool] = ...) -> int: ... - -elif sys.version_info >= (3, 4): - def stack_effect(__opcode: int, __oparg: Optional[int] = ...) -> int: ... - -if sys.version_info >= (3, 6): - hasnargs: List[int] diff --git a/stdlib/@python2/operator.pyi b/stdlib/@python2/operator.pyi index 03510fed90fc..0bbf22c9a2c8 100644 --- a/stdlib/@python2/operator.pyi +++ b/stdlib/@python2/operator.pyi @@ -42,9 +42,8 @@ def __add__(a: Any, b: Any) -> Any: ... def and_(__a: Any, __b: Any) -> Any: ... def __and__(a: Any, b: Any) -> Any: ... -if sys.version_info < (3,): - def div(a: Any, b: Any) -> Any: ... - def __div__(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: ... @@ -61,10 +60,6 @@ def __mod__(a: Any, b: Any) -> Any: ... def mul(__a: Any, __b: Any) -> Any: ... def __mul__(a: Any, b: Any) -> Any: ... -if sys.version_info >= (3, 5): - def matmul(__a: Any, __b: Any) -> Any: ... - def __matmul__(a: Any, b: Any) -> Any: ... - def neg(__a: Any) -> Any: ... def __neg__(a: Any) -> Any: ... def or_(__a: Any, __b: Any) -> Any: ... @@ -99,9 +94,8 @@ def __delitem__(a: MutableSequence[Any], b: slice) -> None: ... @overload def __delitem__(a: MutableMapping[_K, Any], b: _K) -> None: ... -if sys.version_info < (3,): - def delslice(a: MutableSequence[Any], b: int, c: int) -> None: ... - def __delslice__(a: MutableSequence[Any], b: int, c: int) -> 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: ... @@ -116,18 +110,15 @@ def __getitem__(a: Sequence[_T], b: slice) -> Sequence[_T]: ... @overload def __getitem__(a: Mapping[_K, _V], b: _K) -> _V: ... -if sys.version_info < (3,): - def getslice(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ... - def __getslice__(a: Sequence[_T], b: int, c: int) -> Sequence[_T]: ... +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: ... -if sys.version_info < (3,): - def repeat(a: Any, b: int) -> Any: ... - def __repeat__(a: Any, b: int) -> Any: ... +def repeat(a: Any, b: int) -> Any: ... +def __repeat__(a: Any, b: int) -> Any: ... -if sys.version_info < (3,): - def sequenceIncludes(a: Container[Any], b: Any) -> bool: ... +def sequenceIncludes(a: Container[Any], b: Any) -> bool: ... @overload def setitem(__a: MutableSequence[_T], __b: int, __c: _T) -> None: ... @@ -142,12 +133,8 @@ def __setitem__(a: MutableSequence[_T], b: slice, c: Sequence[_T]) -> None: ... @overload def __setitem__(a: MutableMapping[_K, _V], b: _K, c: _V) -> None: ... -if sys.version_info < (3,): - 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: ... - -if sys.version_info >= (3, 4): - def length_hint(__obj: Any, __default: int = ...) -> int: ... +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 @@ -186,9 +173,8 @@ def __iand__(a: Any, b: Any) -> Any: ... def iconcat(__a: Any, __b: Any) -> Any: ... def __iconcat__(a: Any, b: Any) -> Any: ... -if sys.version_info < (3,): - def idiv(a: Any, b: Any) -> Any: ... - def __idiv__(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: ... @@ -199,18 +185,13 @@ def __imod__(a: Any, b: Any) -> Any: ... def imul(__a: Any, __b: Any) -> Any: ... def __imul__(a: Any, b: Any) -> Any: ... -if sys.version_info >= (3, 5): - def imatmul(__a: Any, __b: Any) -> Any: ... - def __imatmul__(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: ... -if sys.version_info < (3,): - def irepeat(a: Any, b: int) -> Any: ... - def __irepeat__(a: Any, b: int) -> 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: ... @@ -221,8 +202,7 @@ def __itruediv__(a: Any, b: Any) -> Any: ... def ixor(__a: Any, __b: Any) -> Any: ... def __ixor__(a: Any, b: Any) -> Any: ... -if sys.version_info < (3,): - def isCallable(x: Any) -> bool: ... - def isMappingType(x: Any) -> bool: ... - def isNumberType(x: Any) -> bool: ... - def isSequenceType(x: Any) -> bool: ... +def isCallable(x: Any) -> bool: ... +def isMappingType(x: Any) -> bool: ... +def isNumberType(x: Any) -> bool: ... +def isSequenceType(x: Any) -> bool: ... diff --git a/stdlib/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index 2229807bc641..6726d827aa4d 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -2,10 +2,7 @@ import sys from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] NO_DEFAULT: Tuple[_Text, ...] SUPPRESS_HELP: _Text @@ -14,8 +11,7 @@ SUPPRESS_USAGE: _Text def check_builtin(option: Option, opt: Any, value: _Text) -> Any: ... def check_choice(option: Option, opt: Any, value: _Text) -> Any: ... -if sys.version_info < (3,): - def isbasestring(x: Any) -> bool: ... +def isbasestring(x: Any) -> bool: ... class OptParseError(Exception): msg: _Text diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 7b32f5087495..3be2b0a24da1 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -37,15 +37,6 @@ _T = TypeVar("_T") error = OSError -if sys.version_info >= (3, 2): - supports_bytes_environ: bool - -if sys.version_info >= (3, 3): - supports_dir_fd: Set[Callable[..., Any]] - supports_fd: Set[Callable[..., Any]] - supports_effective_ids: Set[Callable[..., Any]] - supports_follow_symlinks: Set[Callable[..., Any]] - SEEK_SET: int SEEK_CUR: int SEEK_END: int @@ -110,9 +101,6 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): def __len__(self) -> int: ... environ: _Environ[str] -if sys.version_info >= (3, 2): - environb: _Environ[bytes] - if sys.platform != "win32": # Unix only confstr_names: Dict[str, int] @@ -245,11 +233,7 @@ def symlink(source: AnyPath, link_name: AnyPath) -> None: ... def unlink(path: AnyPath) -> None: ... # TODO: add ns, dir_fd, follow_symlinks argument -if sys.version_info >= (3, 0): - def utime(path: AnyPath, times: Optional[Tuple[float, float]] = ...) -> None: ... - -else: - def utime(path: AnyPath, times: Optional[Tuple[float, float]]) -> None: ... +def utime(path: AnyPath, times: Optional[Tuple[float, float]]) -> None: ... if sys.platform != "win32": # Unix only @@ -275,18 +259,9 @@ if sys.platform != "win32": def pathconf(path: AnyPath, name: Union[str, int]) -> int: ... def statvfs(path: AnyPath) -> _StatVFS: ... -if sys.version_info >= (3, 6): - def walk( - top: Union[AnyStr, PathLike[AnyStr]], - topdown: bool = ..., - onerror: Optional[Callable[[OSError], Any]] = ..., - followlinks: bool = ..., - ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... - -else: - def walk( - top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... - ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... +def walk( + top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... +) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... def abort() -> NoReturn: ... @@ -317,17 +292,10 @@ if sys.platform != "win32": def nice(increment: int) -> int: ... def plock(op: int) -> None: ... # ???op is int? -if sys.version_info >= (3, 0): - class popen(_TextIOWrapper): - # TODO 'b' modes or bytes command not accepted? - def __init__(self, command: str, mode: str = ..., bufsize: int = ...) -> None: ... - def close(self) -> Any: ... # may return int - -else: - 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 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: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, path: AnyPath, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig @@ -362,18 +330,9 @@ else: def getloadavg() -> Tuple[float, float, float]: ... def sysconf(name: Union[str, int]) -> int: ... -if sys.version_info >= (3, 0): - def sched_getaffinity(id: int) -> Set[int]: ... - -if sys.version_info >= (3, 3): - class waitresult: - si_pid: int - def waitid(idtype: int, id: int, options: int) -> waitresult: ... - -if sys.version_info < (3, 0): - def tmpfile() -> IO[Any]: ... - def tmpnam() -> str: ... - def tempnam(dir: str = ..., prefix: str = ...) -> str: ... +def tmpfile() -> IO[Any]: ... +def tmpnam() -> str: ... +def tempnam(dir: str = ..., prefix: str = ...) -> str: ... P_ALL: int WEXITED: int diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index 2750e9ea0f4b..87393734040e 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -17,11 +17,7 @@ def runeval(expression: str, globals: Optional[Dict[str, Any]] = ..., locals: Op def runctx(statement: str, globals: Dict[str, Any], locals: Mapping[str, Any]) -> None: ... def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... -if sys.version_info >= (3, 7): - def set_trace(*, header: Optional[str] = ...) -> None: ... - -else: - def set_trace() -> None: ... +def set_trace() -> None: ... def post_mortem(t: Optional[TracebackType] = ...) -> None: ... def pm() -> None: ... @@ -46,33 +42,13 @@ class Pdb(Bdb, Cmd): curframe: Optional[FrameType] curframe_locals: Mapping[str, Any] - if sys.version_info >= (3, 6): - def __init__( - self, - completekey: str = ..., - stdin: Optional[IO[str]] = ..., - stdout: Optional[IO[str]] = ..., - skip: Optional[Iterable[str]] = ..., - nosigint: bool = ..., - readrc: bool = ..., - ) -> None: ... - elif sys.version_info >= (3, 2): - def __init__( - self, - completekey: str = ..., - stdin: Optional[IO[str]] = ..., - stdout: Optional[IO[str]] = ..., - skip: Optional[Iterable[str]] = ..., - nosigint: bool = ..., - ) -> None: ... - else: - def __init__( - self, - completekey: str = ..., - stdin: Optional[IO[str]] = ..., - stdout: Optional[IO[str]] = ..., - skip: Optional[Iterable[str]] = ..., - ) -> None: ... + def __init__( + self, + completekey: str = ..., + stdin: Optional[IO[str]] = ..., + stdout: Optional[IO[str]] = ..., + skip: Optional[Iterable[str]] = ..., + ) -> None: ... def forget(self) -> None: ... def setup(self, f: Optional[FrameType], tb: Optional[TracebackType]) -> None: ... def execRcLines(self) -> None: ... @@ -140,101 +116,54 @@ class Pdb(Bdb, Cmd): do_h = do_help def help_exec(self) -> None: ... def help_pdb(self) -> None: ... - if sys.version_info < (3, 2): - 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 - - if sys.version_info >= (3, 2): - def sigint_handler(self, signum: signal.Signals, frame: FrameType) -> None: ... - def message(self, msg: str) -> None: ... - def error(self, msg: str) -> None: ... - def _select_frame(self, number: int) -> None: ... - def _getval_except(self, arg: str, frame: Optional[FrameType] = ...) -> object: ... - def _print_lines( - self, lines: Sequence[str], start: int, breaks: Sequence[int] = ..., frame: Optional[FrameType] = ... - ) -> None: ... - def _cmdloop(self) -> None: ... - def do_display(self, arg: str) -> Optional[bool]: ... - def do_interact(self, arg: str) -> Optional[bool]: ... - def do_longlist(self, arg: str) -> Optional[bool]: ... - def do_source(self, arg: str) -> Optional[bool]: ... - def do_undisplay(self, arg: str) -> Optional[bool]: ... - do_ll = do_longlist - - if sys.version_info >= (3, 3): - def _complete_location(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def _complete_bpnumber(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def _complete_expression(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def complete_undisplay(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - def complete_unalias(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ... - complete_commands = _complete_bpnumber - complete_break = _complete_location - complete_b = _complete_location - complete_tbreak = _complete_location - complete_enable = _complete_bpnumber - complete_disable = _complete_bpnumber - complete_condition = _complete_bpnumber - complete_ignore = _complete_bpnumber - complete_clear = _complete_location - complete_cl = _complete_location - complete_debug = _complete_expression - complete_print = _complete_expression - complete_p = _complete_expression - complete_pp = _complete_expression - complete_source = _complete_expression - complete_whatis = _complete_expression - complete_display = _complete_expression - - if sys.version_info >= (3, 7): - def _runmodule(self, module_name: str) -> None: ... - if sys.version_info >= (3,) and sys.version_info < (3, 4): - do_print = do_p + 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 @@ -242,9 +171,5 @@ def find_function(funcname: str, filename: str) -> Optional[Tuple[str, str, int] def main() -> None: ... def help() -> None: ... -if sys.version_info >= (3, 2): - def getsourcelines(obj: _SourceObjectType) -> Tuple[List[str], int]: ... - def lasti2lineno(code: CodeType, lasti: int) -> int: ... - class _rstr(str): def __repr__(self) -> _rstr: ... diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index ddf8a4401399..a511b702bb9b 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -2,53 +2,12 @@ import sys from typing import IO, Any, Callable, Iterable, Iterator, Mapping, Optional, Tuple, Type, Union HIGHEST_PROTOCOL: int -if sys.version_info >= (3, 0): - DEFAULT_PROTOCOL: int - bytes_types: Tuple[Type[Any], ...] # undocumented -if sys.version_info >= (3, 8): - # TODO: holistic design for buffer interface (typing.Buffer?) - class PickleBuffer: - # buffer must be a buffer-providing object - def __init__(self, buffer: Any) -> None: ... - def raw(self) -> memoryview: ... - def release(self) -> None: ... - _BufferCallback = Optional[Callable[[PickleBuffer], Any]] - def dump( - obj: Any, - file: IO[bytes], - protocol: Optional[int] = ..., - *, - fix_imports: bool = ..., - buffer_callback: _BufferCallback = ..., - ) -> None: ... - def dumps( - obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ... - ) -> bytes: ... - def load( - file: IO[bytes], - *, - fix_imports: bool = ..., - encoding: str = ..., - errors: str = ..., - buffers: Optional[Iterable[Any]] = ..., - ) -> Any: ... - def loads( - __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Optional[Iterable[Any]] = ... - ) -> Any: ... - -elif sys.version_info >= (3, 0): - def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... - def dumps(obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> bytes: ... - def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... - def loads(data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... - -else: - def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... - def dumps(obj: Any, protocol: Optional[int] = ...) -> bytes: ... - def load(file: IO[bytes]) -> Any: ... - def loads(string: bytes) -> Any: ... +def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... +def dumps(obj: Any, protocol: Optional[int] = ...) -> bytes: ... +def load(file: IO[bytes]) -> Any: ... +def loads(string: bytes) -> Any: ... class PickleError(Exception): ... class PicklingError(PickleError): ... @@ -64,47 +23,15 @@ _reducedtype = Union[ class Pickler: fast: bool - if sys.version_info >= (3, 3): - dispatch_table: Mapping[type, Callable[[Any], _reducedtype]] - - if sys.version_info >= (3, 8): - def __init__( - self, - file: IO[bytes], - protocol: Optional[int] = ..., - *, - fix_imports: bool = ..., - buffer_callback: _BufferCallback = ..., - ) -> None: ... - def reducer_override(self, obj: Any) -> Any: ... - elif sys.version_info >= (3, 0): - def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ... - else: - def __init__(self, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... + def __init__(self, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... def dump(self, __obj: Any) -> None: ... def clear_memo(self) -> None: ... def persistent_id(self, obj: Any) -> Any: ... class Unpickler: - if sys.version_info >= (3, 8): - def __init__( - self, - file: IO[bytes], - *, - fix_imports: bool = ..., - encoding: str = ..., - errors: str = ..., - buffers: Optional[Iterable[Any]] = ..., - ) -> None: ... - elif sys.version_info >= (3, 0): - def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> None: ... - else: - def __init__(self, file: IO[bytes]) -> None: ... + def __init__(self, file: IO[bytes]) -> None: ... def load(self) -> Any: ... def find_class(self, __module_name: str, __global_name: str) -> Any: ... - if sys.version_info >= (3, 0): - def persistent_load(self, pid: Any) -> Any: ... - MARK: bytes STOP: bytes POP: bytes @@ -164,23 +91,5 @@ NEWFALSE: bytes LONG1: bytes LONG4: bytes -if sys.version_info >= (3, 0): - # protocol 3 - BINBYTES: bytes - SHORT_BINBYTES: bytes - -if sys.version_info >= (3, 4): - # protocol 4 - SHORT_BINUNICODE: bytes - BINUNICODE8: bytes - BINBYTES8: bytes - EMPTY_SET: bytes - ADDITEMS: bytes - FROZENSET: bytes - NEWOBJ_EX: bytes - STACK_GLOBAL: bytes - MEMOIZE: bytes - FRAME: bytes - def encode_long(x: int) -> bytes: ... # undocumented def decode_long(data: bytes) -> int: ... # undocumented diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index ec279524bc50..4ad75fb8bbbf 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -3,17 +3,9 @@ from typing import IO, Any, Callable, Iterator, List, MutableMapping, Optional, _Reader = Callable[[IO[bytes]], Any] -if sys.version_info >= (3, 0): - bytes_types: Tuple[Type[Any], ...] - UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int TAKEN_FROM_ARGUMENT4: int -if sys.version_info >= (3, 3): - TAKEN_FROM_ARGUMENT4U: int -if sys.version_info >= (3, 4): - TAKEN_FROM_ARGUMENT8U: int - class ArgumentDescriptor(object): name: str n: int @@ -33,14 +25,6 @@ def read_int4(f: IO[bytes]) -> int: ... int4: ArgumentDescriptor -if sys.version_info >= (3, 3): - def read_uint4(f: IO[bytes]) -> int: ... - uint4: ArgumentDescriptor - -if sys.version_info >= (3, 5): - def read_uint8(f: IO[bytes]) -> int: ... - uint8: ArgumentDescriptor - def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, Text]: ... stringnl: ArgumentDescriptor @@ -61,32 +45,14 @@ def read_string4(f: IO[bytes]) -> str: ... string4: ArgumentDescriptor -if sys.version_info >= (3, 3): - def read_bytes1(f: IO[bytes]) -> bytes: ... - bytes1: ArgumentDescriptor - def read_bytes4(f: IO[bytes]) -> bytes: ... - bytes4: ArgumentDescriptor - -if sys.version_info >= (3, 4): - def read_bytes8(f: IO[bytes]) -> bytes: ... - bytes8: ArgumentDescriptor - def read_unicodestringnl(f: IO[bytes]) -> Text: ... unicodestringnl: ArgumentDescriptor -if sys.version_info >= (3, 4): - def read_unicodestring1(f: IO[bytes]) -> Text: ... - unicodestring1: ArgumentDescriptor - def read_unicodestring4(f: IO[bytes]) -> Text: ... unicodestring4: ArgumentDescriptor -if sys.version_info >= (3, 4): - def read_unicodestring8(f: IO[bytes]) -> Text: ... - unicodestring8: ArgumentDescriptor - def read_decimalnl_short(f: IO[bytes]) -> int: ... def read_decimalnl_long(f: IO[bytes]) -> int: ... @@ -120,19 +86,12 @@ pylong: StackObject pyinteger_or_bool: StackObject pybool: StackObject pyfloat: StackObject -if sys.version_info >= (3, 4): - pybytes_or_str: StackObject pystring: StackObject -if sys.version_info >= (3, 0): - pybytes: StackObject pyunicode: StackObject pynone: StackObject pytuple: StackObject pylist: StackObject pydict: StackObject -if sys.version_info >= (3, 4): - pyset: StackObject - pyfrozenset: StackObject anyobject: StackObject markobject: StackObject stackslice: StackObject @@ -161,19 +120,9 @@ opcodes: List[OpcodeInfo] def genops(pickle: Union[bytes, IO[bytes]]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... def optimize(p: Union[bytes, IO[bytes]]) -> bytes: ... -if sys.version_info >= (3, 2): - def dis( - pickle: Union[bytes, IO[bytes]], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., - indentlevel: int = ..., - annotate: int = ..., - ) -> None: ... - -else: - def dis( - pickle: Union[bytes, IO[bytes]], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., - indentlevel: int = ..., - ) -> None: ... +def dis( + pickle: Union[bytes, IO[bytes]], + out: Optional[IO[str]] = ..., + memo: Optional[MutableMapping[int, Any]] = ..., + indentlevel: int = ..., +) -> None: ... diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 0935e922562e..a068d421f5f5 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -2,21 +2,11 @@ import sys from _typeshed import SupportsRead from typing import IO, Any, Callable, Iterable, Iterator, List, NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3,): - from importlib.abc import Loader, MetaPathFinder, PathEntryFinder -else: - Loader = Any - MetaPathFinder = Any - PathEntryFinder = Any +Loader = Any +MetaPathFinder = Any +PathEntryFinder = Any -if sys.version_info >= (3, 6): - class ModuleInfo(NamedTuple): - module_finder: Union[MetaPathFinder, PathEntryFinder] - name: str - ispkg: bool - _ModuleInfoLike = ModuleInfo -else: - _ModuleInfoLike = Tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] +_ModuleInfoLike = Tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] def extend_path(path: List[str], name: str) -> List[str]: ... @@ -37,5 +27,3 @@ def walk_packages( ) -> Iterator[_ModuleInfoLike]: ... def get_data(package: str, resource: str) -> Optional[bytes]: ... -if sys.version_info >= (3, 9): - def resolve_name(name: str) -> Any: ... diff --git a/stdlib/@python2/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 5aadae9fc97b..9266067019a6 100644 --- a/stdlib/@python2/plistlib.pyi +++ b/stdlib/@python2/plistlib.pyi @@ -1,72 +1,26 @@ import sys from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Optional, Text, Type, Union -if sys.version_info >= (3,): - from enum import Enum - class PlistFormat(Enum): - FMT_XML: int - FMT_BINARY: int - FMT_XML = PlistFormat.FMT_XML - FMT_BINARY = PlistFormat.FMT_BINARY - _Path = Union[str, Text] -if sys.version_info >= (3, 9): - def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... - def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... - -elif sys.version_info >= (3, 4): - def load( - fp: IO[bytes], - *, - fmt: Optional[PlistFormat] = ..., - use_builtin_types: bool = ..., - dict_type: Type[MutableMapping[str, Any]] = ..., - ) -> Any: ... - def loads( - value: bytes, - *, - fmt: Optional[PlistFormat] = ..., - use_builtin_types: bool = ..., - dict_type: Type[MutableMapping[str, Any]] = ..., - ) -> Any: ... - -if sys.version_info >= (3, 4): - def dump( - value: Mapping[str, Any], fp: IO[bytes], *, fmt: PlistFormat = ..., sort_keys: bool = ..., skipkeys: bool = ... - ) -> None: ... - def dumps(value: Mapping[str, Any], *, fmt: PlistFormat = ..., skipkeys: bool = ..., sort_keys: bool = ...) -> bytes: ... - -if sys.version_info < (3, 9): - def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... - def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... - def readPlistFromBytes(data: bytes) -> Any: ... - def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... - -if sys.version_info < (3,): - 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: ... +def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... +def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... +def readPlistFromBytes(data: bytes) -> Any: ... +def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... -if sys.version_info < (3, 7): - class Dict(DictT[str, Any]): - def __getattr__(self, attr: str) -> Any: ... - def __setattr__(self, attr: str, value: Any) -> None: ... - def __delattr__(self, attr: str) -> None: ... +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: ... -if sys.version_info < (3, 9): - class Data: - data: bytes - def __init__(self, data: bytes) -> None: ... +class Dict(DictT[str, Any]): + def __getattr__(self, attr: str) -> Any: ... + def __setattr__(self, attr: str, value: Any) -> None: ... + def __delattr__(self, attr: str) -> None: ... -if sys.version_info >= (3, 8): - class UID: - data: int - def __init__(self, data: int) -> None: ... - def __index__(self) -> int: ... - def __reduce__(self) -> Any: ... - def __hash__(self) -> int: ... +class Data: + data: bytes + def __init__(self, data: bytes) -> None: ... class InvalidFileException(ValueError): def __init__(self, message: str = ...) -> None: ... diff --git a/stdlib/@python2/poplib.pyi b/stdlib/@python2/poplib.pyi index 2c08f3586c0f..0e400db66bc2 100644 --- a/stdlib/@python2/poplib.pyi +++ b/stdlib/@python2/poplib.pyi @@ -14,9 +14,6 @@ LF: bytes CRLF: bytes class POP3: - if sys.version_info >= (3, 0): - encoding: Text - host: Text port: int sock: socket.socket @@ -38,36 +35,13 @@ class POP3: def rpop(self, user: Text) -> bytes: ... timestamp: Pattern[Text] - if sys.version_info < (3, 0): - def apop(self, user: Text, secret: Text) -> bytes: ... - else: - def apop(self, user: Text, password: Text) -> bytes: ... + 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: ... - if sys.version_info >= (3, 5): - def utf8(self) -> bytes: ... - if sys.version_info >= (3, 4): - def capa(self) -> Dict[Text, List[Text]]: ... - def stls(self, context: Optional[ssl.SSLContext] = ...) -> bytes: ... - class POP3_SSL(POP3): - if sys.version_info >= (3, 0): - def __init__( - self, - host: Text, - port: int = ..., - keyfile: Optional[Text] = ..., - certfile: Optional[Text] = ..., - timeout: float = ..., - context: Optional[ssl.SSLContext] = ..., - ) -> None: ... - else: - def __init__( - self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... - ) -> None: ... - if sys.version_info >= (3, 4): - # "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored - def stls(self, context: Any = ..., keyfile: Any = ..., certfile: Any = ...) -> bytes: ... + def __init__( + self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... + ) -> None: ... diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index 9484f92eca46..28abac6e83c7 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -1,145 +1,20 @@ import sys from typing import IO, Any, Dict, Optional, Tuple -if sys.version_info >= (3, 10): - def pformat( - object: object, - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> str: ... +def pformat(object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ...) -> str: ... -elif sys.version_info >= (3, 8): - def pformat( - object: object, - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - ) -> str: ... - -elif sys.version_info >= (3, 4): - def pformat( - object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ..., *, compact: bool = ... - ) -> str: ... - -else: - def pformat(object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ...) -> str: ... - -if sys.version_info >= (3, 10): - def pp( - object: object, - stream: Optional[IO[str]] = ..., - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> None: ... - -elif sys.version_info >= (3, 8): - def pp( - object: object, - stream: Optional[IO[str]] = ..., - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - ) -> None: ... - -if sys.version_info >= (3, 10): - def pprint( - object: object, - stream: Optional[IO[str]] = ..., - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> None: ... - -elif sys.version_info >= (3, 8): - def pprint( - object: object, - stream: Optional[IO[str]] = ..., - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - ) -> None: ... - -elif sys.version_info >= (3, 4): - def pprint( - object: object, - stream: Optional[IO[str]] = ..., - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - *, - compact: bool = ..., - ) -> None: ... - -else: - def pprint( - object: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., depth: Optional[int] = ... - ) -> None: ... +def pprint( + object: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., depth: Optional[int] = ... +) -> None: ... def isreadable(object: object) -> bool: ... def isrecursive(object: object) -> bool: ... def saferepr(object: object) -> str: ... class PrettyPrinter: - if sys.version_info >= (3, 10): - def __init__( - self, - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - stream: Optional[IO[str]] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - underscore_numbers: bool = ..., - ) -> None: ... - elif sys.version_info >= (3, 8): - def __init__( - self, - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - stream: Optional[IO[str]] = ..., - *, - compact: bool = ..., - sort_dicts: bool = ..., - ) -> None: ... - elif sys.version_info >= (3, 4): - def __init__( - self, - indent: int = ..., - width: int = ..., - depth: Optional[int] = ..., - stream: Optional[IO[str]] = ..., - *, - compact: bool = ..., - ) -> None: ... - else: - def __init__( - self, indent: int = ..., width: int = ..., depth: Optional[int] = ..., stream: Optional[IO[str]] = ... - ) -> None: ... + def __init__( + self, indent: int = ..., width: int = ..., depth: Optional[int] = ..., stream: Optional[IO[str]] = ... + ) -> None: ... def pformat(self, object: object) -> str: ... def pprint(self, object: object) -> None: ... def isreadable(self, object: object) -> bool: ... diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index 9c74aeb9c3de..59eb08730680 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -7,19 +7,6 @@ from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) -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 Stats: sort_arg_dict_default: Dict[str, Tuple[Any, str]] def __init__( diff --git a/stdlib/@python2/pty.pyi b/stdlib/@python2/pty.pyi index f31e2c61ca9b..81012ac4dce7 100644 --- a/stdlib/@python2/pty.pyi +++ b/stdlib/@python2/pty.pyi @@ -14,8 +14,4 @@ def master_open() -> Tuple[int, str]: ... def slave_open(tty_name: str) -> int: ... def fork() -> Tuple[int, int]: ... -if sys.version_info >= (3, 4): - def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... - -else: - def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... +def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index 49473b17708e..b6dfc0639350 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -10,43 +10,8 @@ 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 = ... - def _get_default_invalidation_mode() -> PycInvalidationMode: ... - -if sys.version_info >= (3, 8): - def compile( - file: AnyStr, - cfile: Optional[AnyStr] = ..., - dfile: Optional[AnyStr] = ..., - doraise: bool = ..., - optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., - quiet: int = ..., - ) -> Optional[AnyStr]: ... - -elif sys.version_info >= (3, 7): - def compile( - file: AnyStr, - cfile: Optional[AnyStr] = ..., - dfile: Optional[AnyStr] = ..., - doraise: bool = ..., - optimize: int = ..., - invalidation_mode: Optional[PycInvalidationMode] = ..., - ) -> Optional[AnyStr]: ... - -elif sys.version_info >= (3, 2): - def compile( - file: AnyStr, cfile: Optional[AnyStr] = ..., dfile: Optional[AnyStr] = ..., doraise: bool = ..., optimize: int = ... - ) -> Optional[AnyStr]: ... - -else: - def compile( - file: _EitherStr, cfile: Optional[_EitherStr] = ..., dfile: Optional[_EitherStr] = ..., doraise: bool = ... - ) -> None: ... +def compile( + file: _EitherStr, cfile: Optional[_EitherStr] = ..., dfile: Optional[_EitherStr] = ..., doraise: bool = ... +) -> None: ... def main(args: Optional[List[Text]] = ...) -> int: ... diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 665ea43c0d4a..8dd739ef0ce6 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -9,18 +9,7 @@ class Class: file: int lineno: int - if sys.version_info >= (3, 7): - def __init__( - self, - module: str, - name: str, - super: Optional[List[Union[Class, str]]], - file: str, - lineno: int, - parent: Optional[Class] = ..., - ) -> None: ... - else: - def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... + def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... class Function: module: str @@ -28,10 +17,7 @@ class Function: file: int lineno: int - if sys.version_info >= (3, 7): - def __init__(self, module: str, name: str, file: str, lineno: int, parent: Optional[Function] = ...) -> 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) -> None: ... def readmodule(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Class]: ... def readmodule_ex(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Union[Class, Function, List[str]]]: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 39252dd9f725..52f8c92cc517 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -19,10 +19,7 @@ from typing import ( Union, ) -if sys.version_info >= (3,): - from reprlib import Repr -else: - from repr import Repr +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]] @@ -266,8 +263,7 @@ def apropos(key: str) -> None: ... def ispath(x: Any) -> bool: ... def cli() -> None: ... -if sys.version_info < (3,): - def serve( - port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ... - ) -> None: ... - def gui() -> None: ... +def serve( + port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ... +) -> None: ... +def gui() -> None: ... diff --git a/stdlib/@python2/pyexpat/errors.pyi b/stdlib/@python2/pyexpat/errors.pyi index 6cde43e3b61f..61420a6caa51 100644 --- a/stdlib/@python2/pyexpat/errors.pyi +++ b/stdlib/@python2/pyexpat/errors.pyi @@ -1,10 +1,6 @@ import sys from typing import Dict -if sys.version_info >= (3, 2): - codes: Dict[str, int] - messages: Dict[int, str] - XML_ERROR_ABORTED: str XML_ERROR_ASYNC_ENTITY: str XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: str diff --git a/stdlib/@python2/queue.pyi b/stdlib/@python2/queue.pyi index 82fde5989d34..f3d215676758 100644 --- a/stdlib/@python2/queue.pyi +++ b/stdlib/@python2/queue.pyi @@ -2,9 +2,6 @@ import sys from threading import Condition, Lock from typing import Any, Generic, Optional, TypeVar -if sys.version_info >= (3, 9): - from types import GenericAlias - _T = TypeVar("_T") class Empty(Exception): ... @@ -33,20 +30,6 @@ class Queue(Generic[_T]): def qsize(self) -> int: ... def _qsize(self) -> int: ... def task_done(self) -> None: ... - if sys.version_info >= (3, 9): - def __class_getitem__(cls, item: Any) -> GenericAlias: ... - class PriorityQueue(Queue[_T]): ... class LifoQueue(Queue[_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: Optional[float] = ...) -> _T: ... - def get_nowait(self) -> _T: ... - def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> 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/stdlib/@python2/readline.pyi b/stdlib/@python2/readline.pyi index 8f28a2b2b760..18bc6ff4418d 100644 --- a/stdlib/@python2/readline.pyi +++ b/stdlib/@python2/readline.pyi @@ -13,9 +13,6 @@ def redisplay() -> None: ... def read_history_file(__filename: Optional[AnyPath] = ...) -> None: ... def write_history_file(__filename: Optional[AnyPath] = ...) -> None: ... -if sys.version_info >= (3, 5): - def append_history_file(__nelements: int, __filename: Optional[AnyPath] = ...) -> None: ... - def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... @@ -25,9 +22,6 @@ def remove_history_item(__pos: int) -> None: ... def replace_history_item(__pos: int, __line: str) -> None: ... def add_history(__string: str) -> None: ... -if sys.version_info >= (3, 6): - def set_auto_history(__enabled: bool) -> None: ... - def set_startup_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... def set_pre_input_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... def set_completer(__function: _CompleterT = ...) -> None: ... diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index 3733cc13110c..12b4b4966f9e 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -1,10 +1,7 @@ import sys from typing import Any, Dict, Optional, Union -if sys.version_info >= (3,): - _Text = str -else: - _Text = Union[str, unicode] +_Text = Union[str, unicode] class Completer: def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... diff --git a/stdlib/@python2/sched.pyi b/stdlib/@python2/sched.pyi index 21d81e16ec60..7775c050776c 100644 --- a/stdlib/@python2/sched.pyi +++ b/stdlib/@python2/sched.pyi @@ -9,30 +9,10 @@ class Event(NamedTuple): kwargs: Dict[Text, Any] class scheduler: - if sys.version_info >= (3, 3): - def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], None] = ...) -> None: ... - def enterabs( - self, - time: float, - priority: Any, - action: Callable[..., Any], - 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] = ..., - ) -> Event: ... - def run(self, blocking: bool = ...) -> Optional[float]: ... - else: - 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 __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 diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index e0cf3bdd4d75..5c88d27bf66a 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -28,10 +28,7 @@ def select( __rlist: Iterable[Any], __wlist: Iterable[Any], __xlist: Iterable[Any], __timeout: Optional[float] = ... ) -> Tuple[List[Any], List[Any], List[Any]]: ... -if sys.version_info >= (3, 3): - error = OSError -else: - class error(Exception): ... +class error(Exception): ... if sys.platform != "linux" and sys.platform != "win32": # BSD only @@ -103,18 +100,7 @@ if sys.platform != "linux" and sys.platform != "win32": if sys.platform == "linux": class epoll(object): - if sys.version_info >= (3, 3): - def __init__(self, sizehint: int = ..., flags: int = ...) -> None: ... - else: - def __init__(self, sizehint: int = ...) -> None: ... - if sys.version_info >= (3, 4): - def __enter__(self) -> epoll: ... - def __exit__( - self, - exc_type: Optional[Type[BaseException]] = ..., - exc_val: Optional[BaseException] = ..., - exc_tb: Optional[TracebackType] = ..., - ) -> None: ... + def __init__(self, sizehint: int = ...) -> None: ... def close(self) -> None: ... closed: bool def fileno(self) -> int: ... @@ -139,14 +125,3 @@ if sys.platform == "linux": EPOLL_RDHUP: int if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win32": - if sys.version_info >= (3, 3): - # Solaris only - class devpoll: - if sys.version_info >= (3, 4): - 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: Optional[float] = ...) -> List[Tuple[int, int]]: ... diff --git a/stdlib/@python2/shutil.pyi b/stdlib/@python2/shutil.pyi index c0779d871c14..1803f0fe55fe 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -18,119 +18,38 @@ from typing import ( overload, ) -if sys.version_info >= (3, 6): - _AnyStr = str - _AnyPath = TypeVar("_AnyPath", str, os.PathLike[str]) - # Return value of some functions that may either return a path-like object that was passed in or - # a string - _PathReturn = Any -elif sys.version_info >= (3,): - _AnyStr = str - _AnyPath = str - _PathReturn = str -else: - _AnyStr = TypeVar("_AnyStr", str, unicode) - _AnyPath = TypeVar("_AnyPath", str, unicode) - _PathReturn = Type[None] +_AnyStr = TypeVar("_AnyStr", str, unicode) +_AnyPath = TypeVar("_AnyPath", str, unicode) +_PathReturn = Type[None] -if sys.version_info >= (3,): - class Error(OSError): ... - class SameFileError(Error): ... - class SpecialFileError(OSError): ... - class ExecError(OSError): ... - class ReadError(OSError): ... - class RegistryError(Exception): ... - -else: - class Error(EnvironmentError): ... - class SpecialFileError(EnvironmentError): ... - class ExecError(EnvironmentError): ... +class Error(EnvironmentError): ... +class SpecialFileError(EnvironmentError): ... +class ExecError(EnvironmentError): ... def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ... -if sys.version_info >= (3,): - def copyfile(src: StrPath, dst: _AnyPath, *, follow_symlinks: bool = ...) -> _AnyPath: ... - def copymode(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ... - def copystat(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ... - def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ... - def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ... - -else: - def copyfile(src: StrPath, dst: StrPath) -> None: ... - def copymode(src: StrPath, dst: StrPath) -> None: ... - def copystat(src: StrPath, dst: StrPath) -> None: ... - def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... - def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... +def copyfile(src: StrPath, dst: StrPath) -> None: ... +def copymode(src: StrPath, dst: StrPath) -> None: ... +def copystat(src: StrPath, dst: StrPath) -> None: ... +def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... +def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... def ignore_patterns(*patterns: StrPath) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... -if sys.version_info >= (3, 8): - def copytree( - src: StrPath, - dst: StrPath, - symlinks: bool = ..., - ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ..., - copy_function: Callable[[str, str], None] = ..., - ignore_dangling_symlinks: bool = ..., - dirs_exist_ok: bool = ..., - ) -> _PathReturn: ... - -elif sys.version_info >= (3,): - def copytree( - src: StrPath, - dst: StrPath, - symlinks: bool = ..., - ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ..., - copy_function: Callable[[str, str], None] = ..., - ignore_dangling_symlinks: bool = ..., - ) -> _PathReturn: ... +def copytree( + src: AnyStr, + dst: AnyStr, + symlinks: bool = ..., + ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ..., +) -> _PathReturn: ... -else: - def copytree( - src: AnyStr, - dst: AnyStr, - symlinks: bool = ..., - ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ..., - ) -> _PathReturn: ... - -if sys.version_info >= (3,): - def rmtree( - path: Union[bytes, StrPath], ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ... - ) -> None: ... - -else: - def rmtree( - path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ... - ) -> None: ... +def rmtree( + path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ... +) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] -if sys.version_info >= (3, 9): - def move(src: StrPath, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ... - -elif sys.version_info >= (3, 5): - # See https://bugs.python.org/issue32689 - def move(src: str, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ... - -else: - def move(src: StrPath, dst: StrPath) -> _PathReturn: ... - -if sys.version_info >= (3,): - class _ntuple_diskusage(NamedTuple): - total: int - used: int - free: int - def disk_usage(path: StrPath) -> _ntuple_diskusage: ... - def chown(path: StrPath, user: Optional[Union[str, int]] = ..., group: Optional[Union[str, int]] = ...) -> None: ... - -if sys.version_info >= (3, 8): - @overload - def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... - @overload - def which(cmd: bytes, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[bytes]: ... - -elif sys.version_info >= (3,): - def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ... +def move(src: StrPath, dst: StrPath) -> _PathReturn: ... def make_archive( base_name: _AnyStr, @@ -152,19 +71,3 @@ def register_archive_format( ) -> None: ... def unregister_archive_format(name: str) -> None: ... -if sys.version_info >= (3,): - if sys.version_info >= (3, 7): - def unpack_archive(filename: StrPath, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... - else: - # See http://bugs.python.org/issue30218 - def unpack_archive(filename: str, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ... - def register_unpack_format( - name: str, - extensions: List[str], - function: Any, - extra_args: Optional[Sequence[Tuple[str, Any]]] = ..., - description: str = ..., - ) -> None: ... - def unregister_unpack_format(name: str) -> None: ... - def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ... - def get_terminal_size(fallback: Tuple[int, int] = ...) -> os.terminal_size: ... diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index 92f078a063f6..bd0093cb98bf 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -10,39 +10,7 @@ class SMTPChannel(asynchat.async_chat): COMMAND: int DATA: int - if sys.version_info >= (3,): - command_size_limits: DefaultDict[str, int] - smtp_server: SMTPServer - conn: socket.socket - addr: Any - received_lines: List[Text] - smtp_state: int - seen_greeting: str - mailfrom: str - rcpttos: List[str] - received_data: str - fqdn: str - peer: str - - command_size_limit: int - data_size_limit: int - - enable_SMTPUTF8: bool - @property - def max_command_size_limit(self) -> int: ... - if sys.version_info >= (3,): - def __init__( - self, - server: SMTPServer, - conn: socket.socket, - addr: Any, - data_size_limit: int = ..., - map: Optional[asyncore._maptype] = ..., - enable_SMTPUTF8: bool = ..., - decode_data: bool = ..., - ) -> None: ... - else: - def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... + def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... # base asynchat.async_chat.push() accepts bytes def push(self, msg: Text) -> None: ... # type: ignore def collect_incoming_data(self, data: bytes) -> None: ... @@ -54,30 +22,13 @@ class SMTPChannel(asynchat.async_chat): def smtp_RCPT(self, arg: str) -> None: ... def smtp_RSET(self, arg: str) -> None: ... def smtp_DATA(self, arg: str) -> None: ... - if sys.version_info >= (3, 3): - def smtp_EHLO(self, arg: str) -> None: ... - def smtp_HELP(self, arg: str) -> None: ... - def smtp_VRFY(self, arg: str) -> None: ... - def smtp_EXPN(self, arg: str) -> None: ... - class SMTPServer(asyncore.dispatcher): channel_class: Type[SMTPChannel] data_size_limit: int enable_SMTPUTF8: bool - if sys.version_info >= (3,): - def __init__( - self, - localaddr: _Address, - remoteaddr: _Address, - data_size_limit: int = ..., - map: Optional[asyncore._maptype] = ..., - enable_SMTPUTF8: bool = ..., - decode_data: bool = ..., - ) -> None: ... - else: - def __init__(self, localaddr: _Address, remoteaddr: _Address, data_size_limit: int = ...) -> None: ... + 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: Union[bytes, str], **kwargs: Any diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index ef025ac571a7..3345f5f011e2 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -2,16 +2,7 @@ import sys from _typeshed import AnyPath from typing import NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3, 5): - class SndHeaders(NamedTuple): - filetype: str - framerate: int - nchannels: int - nframes: int - sampwidth: Union[int, str] - _SndHeaders = SndHeaders -else: - _SndHeaders = Tuple[str, int, int, int, Union[int, str]] +_SndHeaders = Tuple[str, int, int, int, Union[int, str]] def what(filename: AnyPath) -> Optional[_SndHeaders]: ... def whathdr(filename: AnyPath) -> Optional[_SndHeaders]: ... diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index e3f5d9b35bef..8d2722bbb01d 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -13,9 +13,6 @@ from typing_extensions import Literal # Constants defined by Python (i.e. not OS constants re-exported from C) has_ipv6: bool SocketType: Any -if sys.version_info >= (3,): - SocketIO: Any - # Re-exported errno EAGAIN: int EBADF: int @@ -263,9 +260,6 @@ TCP_NODELAY: int TCP_QUICKACK: int TCP_SYNCNT: int TCP_WINDOW_CLAMP: int -if sys.version_info >= (3, 7): - TCP_NOTSENT_LOWAT: int - # Specifically-documented constants if sys.platform == "linux" and sys.version_info >= (3,): @@ -387,8 +381,6 @@ if sys.platform == "linux" and sys.version_info >= (3,): if sys.platform == "win32": SIO_RCVALL: int SIO_KEEPALIVE_VALS: int - if sys.version_info >= (3, 6): - SIO_LOOPBACK_FAST_PATH: int RCVALL_IPLEVEL: int RCVALL_MAX: int RCVALL_OFF: int @@ -451,14 +443,6 @@ AF_LINK: AddressFamily # Availability: BSD, macOS # BDADDR_* and HCI_* listed with other bluetooth constants below -if sys.version_info >= (3, 6): - SO_DOMAIN: int - SO_PASSSEC: int - SO_PEERSEC: int - SO_PROTOCOL: int - TCP_CONGESTION: int - TCP_USER_TIMEOUT: int - if sys.platform == "linux" and sys.version_info >= (3, 8): AF_QIPCRTR: AddressFamily @@ -506,90 +490,15 @@ if sys.platform == "darwin": SYSPROTO_CONTROL: int # enum versions of above flags -if sys.version_info >= (3, 4): - from enum import IntEnum - class AddressFamily(IntEnum): - AF_UNIX: int - AF_INET: int - AF_INET6: int - AF_AAL5: int - AF_ALG: int - AF_APPLETALK: int - AF_ASH: int - AF_ATMPVC: int - AF_ATMSVC: int - AF_AX25: int - AF_BLUETOOTH: int - AF_BRIDGE: int - AF_CAN: int - AF_DECnet: int - AF_ECONET: int - AF_IPX: int - AF_IRDA: int - AF_KEY: int - AF_LINK: int - AF_LLC: int - AF_NETBEUI: int - AF_NETLINK: int - AF_NETROM: int - AF_PACKET: int - AF_PPPOX: int - AF_QIPCRTR: int - AF_RDS: int - AF_ROSE: int - AF_ROUTE: int - AF_SECURITY: int - AF_SNA: int - AF_SYSTEM: int - AF_TIPC: int - AF_UNSPEC: int - AF_VSOCK: int - AF_WANPIPE: int - AF_X25: int - class SocketKind(IntEnum): - SOCK_STREAM: int - SOCK_DGRAM: int - SOCK_RAW: int - SOCK_RDM: int - SOCK_SEQPACKET: int - SOCK_CLOEXEC: int - SOCK_NONBLOCK: int - -else: - AddressFamily = int - SocketKind = int - -if sys.version_info >= (3, 6): - from enum import IntFlag - class AddressInfo(IntFlag): - AI_ADDRCONFIG: int - AI_ALL: int - AI_CANONNAME: int - AI_NUMERICHOST: int - AI_NUMERICSERV: int - AI_PASSIVE: int - AI_V4MAPPED: int - class MsgFlag(IntFlag): - MSG_CTRUNC: int - MSG_DONTROUTE: int - MSG_DONTWAIT: int - MSG_EOR: int - MSG_OOB: int - MSG_PEEK: int - MSG_TRUNC: int - MSG_WAITALL: int +AddressFamily = int +SocketKind = int -else: - AddressInfo = int - MsgFlag = int +AddressInfo = int +MsgFlag = int # ----- Exceptions ----- -if sys.version_info < (3,): - class error(IOError): ... - -else: - error = OSError +class error(IOError): ... class herror(error): def __init__(self, herror: int = ..., string: str = ...) -> None: ... @@ -618,12 +527,7 @@ class socket: type: int proto: int - if sys.version_info < (3,): - def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... - else: - def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: Optional[int] = ...) -> None: ... - def __enter__(self: _SelfT) -> _SelfT: ... - def __exit__(self, *args: Any) -> None: ... + def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... # --- methods --- def accept(self) -> Tuple[socket, _RetAddress]: ... def bind(self, address: Union[_Address, bytes]) -> None: ... @@ -633,57 +537,22 @@ class socket: def detach(self) -> int: ... def dup(self) -> socket: ... def fileno(self) -> int: ... - if sys.version_info >= (3, 4): - def get_inheritable(self) -> bool: ... 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: ... - if sys.version_info >= (3, 7): - def getblocking(self) -> bool: ... def gettimeout(self) -> Optional[float]: ... if sys.platform == "win32" and sys.version_info >= (3, 6): def ioctl(self, control: int, option: Union[int, Tuple[int, int, int], bool]) -> None: ... elif sys.platform == "win32": def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ... - if sys.version_info >= (3, 5): - def listen(self, __backlog: int = ...) -> None: ... - else: - def listen(self, __backlog: int) -> None: ... + def listen(self, __backlog: int) -> None: ... # Note that the makefile's documented windows-specific behavior is not represented - if sys.version_info >= (3,): - # mode strings with duplicates are intentionally excluded - @overload - def makefile( - self, - mode: Literal["r", "w", "rw", "wr", ""] = ..., - buffering: Optional[int] = ..., - *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> TextIO: ... - @overload - def makefile( - self, - mode: Literal["b", "rb", "br", "wb", "bw", "rwb", "rbw", "wrb", "wbr", "brw", "bwr"], - buffering: Optional[int] = ..., - *, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - ) -> BinaryIO: ... - else: - def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... + 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]: ... - if sys.version_info >= (3, 3) and sys.platform != "win32": - def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ... - def recvmsg_into( - self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ..., __flags: int = ... - ) -> Tuple[int, List[_CMSG], int, Any]: ... 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: ... @@ -692,72 +561,39 @@ class socket: def sendto(self, data: bytes, address: _Address) -> int: ... @overload def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... - if sys.version_info >= (3, 3) and sys.platform != "win32": - def sendmsg( - self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., __flags: int = ..., __address: _Address = ... - ) -> int: ... if sys.platform == "linux" and sys.version_info >= (3, 6): def sendmsg_afalg( self, msg: Iterable[bytes] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ... ) -> int: ... - if sys.version_info >= (3,): - def sendfile(self, file: BinaryIO, offset: int = ..., count: Optional[int] = ...) -> int: ... - def set_inheritable(self, inheritable: bool) -> None: ... def setblocking(self, flag: bool) -> None: ... def settimeout(self, value: Optional[float]) -> None: ... - if sys.version_info < (3, 6): - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... - else: - @overload - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... - @overload - def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ... + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... if sys.platform == "win32": def share(self, process_id: int) -> bytes: ... def shutdown(self, how: int) -> None: ... # ----- Functions ----- -if sys.version_info >= (3, 7): - def close(fd: int) -> None: ... - def create_connection( address: Tuple[Optional[str], int], timeout: Optional[float] = ..., source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ..., ) -> socket: ... -if sys.version_info >= (3, 8): - def create_server( - address: _Address, *, family: int = ..., backlog: Optional[int] = ..., reuse_port: bool = ..., dualstack_ipv6: bool = ... - ) -> socket: ... - def has_dualstack_ipv6() -> bool: ... - def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... if sys.platform == "win32" and sys.version_info >= (3, 3): def fromshare(info: bytes) -> socket: ... # the 5th tuple item is an address -if sys.version_info >= (3,): - def getaddrinfo( - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], - family: int = ..., - type: int = ..., - proto: int = ..., - flags: int = ..., - ) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]: ... - -else: - def getaddrinfo( - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], - family: int = ..., - socktype: int = ..., - proto: int = ..., - flags: int = ..., - ) -> List[Tuple[AddressFamily, SocketKind, int, str, Tuple[Any, ...]]]: ... +def getaddrinfo( + host: Optional[Union[bytearray, bytes, Text]], + port: Union[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: ... @@ -784,26 +620,6 @@ 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: ... -if sys.version_info >= (3, 9): - if sys.platform != "win32": - # flags and address appear to be unused in send_fds and recv_fds - def send_fds( - sock: socket, buffers: Iterable[bytes], fds: Union[bytes, Iterable[int]], flags: int = ..., address: None = ... - ) -> int: ... - def recv_fds(sock: socket, bufsize: int, maxfds: int, flags: int = ...) -> Tuple[bytes, List[int], int, Any]: ... - -if sys.version_info >= (3, 3): - def CMSG_LEN(length: int) -> int: ... - def CMSG_SPACE(length: int) -> int: ... - def getdefaulttimeout() -> Optional[float]: ... def setdefaulttimeout(timeout: Optional[float]) -> None: ... -if sys.version_info >= (3, 3): - if sys.platform != "win32": - def sethostname(name: str) -> None: ... - # Windows added these in 3.8, but didn't have them before - if sys.platform != "win32" or sys.version_info >= (3, 8): - def if_nameindex() -> List[Tuple[int, str]]: ... - def if_nametoindex(name: str) -> int: ... - def if_indextoname(index: int) -> str: ... diff --git a/stdlib/@python2/socketserver.pyi b/stdlib/@python2/socketserver.pyi index f0617e393b7e..4580fff7fe26 100644 --- a/stdlib/@python2/socketserver.pyi +++ b/stdlib/@python2/socketserver.pyi @@ -71,8 +71,6 @@ if sys.platform != "win32": timeout: Optional[float] # undocumented active_children: Optional[List[int]] # undocumented max_children: int # undocumented - if sys.version_info >= (3, 7): - block_on_close: bool def collect_children(self, *, blocking: bool = ...) -> None: ... # undocumented def handle_timeout(self) -> None: ... # undocumented def service_actions(self) -> None: ... # undocumented @@ -81,8 +79,6 @@ if sys.platform != "win32": class ThreadingMixIn: daemon_threads: bool - if sys.version_info >= (3, 7): - block_on_close: 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: ... def server_close(self) -> None: ... diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 74caa0e64cf1..9f0bdd1b1bcf 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -18,10 +18,7 @@ def TimestampFromTicks(ticks: float) -> Timestamp: ... version_info: Tuple[int, int, int] sqlite_version_info: Tuple[int, int, int] -if sys.version_info >= (3,): - Binary = memoryview -else: - Binary = buffer +Binary = buffer # The remaining definitions are imported from _sqlite3. @@ -67,51 +64,25 @@ version: str def adapt(obj, protocol, alternate): ... def complete_statement(sql: str) -> bool: ... -if sys.version_info >= (3, 7): - def connect( - database: Union[bytes, Text, os.PathLike[Text]], - timeout: float = ..., - detect_types: int = ..., - isolation_level: Optional[str] = ..., - check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., - cached_statements: int = ..., - uri: bool = ..., - ) -> Connection: ... - -elif sys.version_info >= (3, 4): - def connect( - database: Union[bytes, Text], - timeout: float = ..., - detect_types: int = ..., - isolation_level: Optional[str] = ..., - check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., - cached_statements: int = ..., - uri: bool = ..., - ) -> Connection: ... - -else: - def connect( - database: Union[bytes, Text], - timeout: float = ..., - detect_types: int = ..., - isolation_level: Optional[str] = ..., - check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., - cached_statements: int = ..., - ) -> Connection: ... +def connect( + database: Union[bytes, Text], + timeout: float = ..., + detect_types: int = ..., + isolation_level: Optional[str] = ..., + check_same_thread: bool = ..., + factory: Optional[Type[Connection]] = ..., + 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], Union[int, float, str, bytes]]) -> None: ... def register_converter(__name: str, __converter: Callable[[bytes], Any]) -> None: ... -if sys.version_info < (3, 8): - class Cache(object): - def __init__(self, *args, **kwargs) -> None: ... - def display(self, *args, **kwargs) -> None: ... - def get(self, *args, **kwargs) -> 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: ... @@ -138,10 +109,7 @@ class Connection(object): 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: ... - if sys.version_info >= (3, 8): - def create_function(self, name: str, narg: int, func: Any, *, deterministic: bool = ...) -> None: ... - else: - def create_function(self, name: str, num_params: int, func: Any) -> None: ... + def create_function(self, name: str, num_params: int, func: Any) -> None: ... def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ... def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this @@ -161,16 +129,6 @@ class Connection(object): # 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: ... - if sys.version_info >= (3, 7): - def backup( - self, - target: Connection, - *, - pages: int = ..., - progress: Optional[Callable[[int, int, int], object]] = ..., - name: str = ..., - sleep: float = ..., - ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __enter__(self) -> Connection: ... def __exit__(self, t: Optional[type], exc: Optional[BaseException], tb: Optional[Any]) -> None: ... @@ -196,10 +154,7 @@ class Cursor(Iterator[Any]): def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ... def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ... def __iter__(self) -> Cursor: ... - if sys.version_info >= (3, 0): - def __next__(self) -> Any: ... - else: - def next(self) -> Any: ... + def next(self) -> Any: ... class DataError(DatabaseError): ... class DatabaseError(Error): ... @@ -210,73 +165,70 @@ class InternalError(DatabaseError): ... class NotSupportedError(DatabaseError): ... class OperationalError(DatabaseError): ... -if sys.version_info >= (3,): - OptimizedUnicode = str -else: - 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 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: ... @@ -297,8 +249,7 @@ class Row(object): def __lt__(self, other): ... def __ne__(self, other): ... -if sys.version_info < (3, 8): - class Statement(object): - def __init__(self, *args, **kwargs): ... +class Statement(object): + def __init__(self, *args, **kwargs): ... class Warning(Exception): ... diff --git a/stdlib/@python2/sre_compile.pyi b/stdlib/@python2/sre_compile.pyi index 9b50b75d8c31..0c48b7c38e18 100644 --- a/stdlib/@python2/sre_compile.pyi +++ b/stdlib/@python2/sre_compile.pyi @@ -15,17 +15,8 @@ from sre_constants import ( from sre_parse import SubPattern from typing import Any, List, Pattern, Tuple, Type, Union -if sys.version_info >= (3,): - from sre_constants import SRE_FLAG_ASCII as SRE_FLAG_ASCII - MAXCODE: int -if sys.version_info < (3, 0): - STRING_TYPES: Tuple[Type[str], Type[unicode]] - _IsStringType = int -else: - from sre_constants import _NamedIntConstant - def dis(code: List[_NamedIntConstant]) -> None: ... - _IsStringType = bool - +STRING_TYPES: Tuple[Type[str], Type[unicode]] +_IsStringType = int def isstring(obj: Any) -> _IsStringType: ... def compile(p: Union[str, bytes, SubPattern], flags: int = ...) -> Pattern[Any]: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 838211d959e5..2ad69b546426 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -4,9 +4,6 @@ from _typeshed import StrPath from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Text, Tuple, Type, Union, overload from typing_extensions import Literal -if sys.version_info >= (3, 4): - import enum - _PCTRTT = Tuple[Tuple[str, str], ...] _PCTRTTT = Tuple[_PCTRTT, ...] _PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] @@ -14,10 +11,7 @@ _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] _EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] _PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] -if sys.version_info >= (3, 5): - _SC1ArgT = Union[SSLSocket, SSLObject] -else: - _SC1ArgT = SSLSocket +_SC1ArgT = SSLSocket _SrvnmeCbType = Callable[[_SC1ArgT, Optional[str], SSLSocket], Optional[int]] class SSLError(OSError): @@ -30,13 +24,7 @@ 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 CertificateError(ValueError): ... def wrap_socket( sock: socket.socket, @@ -54,40 +42,21 @@ def create_default_context( purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[Text, bytes, None] = ... ) -> SSLContext: ... -if sys.version_info >= (3, 7): - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: int = ..., - check_hostname: bool = ..., - purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., - ) -> SSLContext: ... - -else: - def _create_unverified_context( - protocol: int = ..., - *, - cert_reqs: Optional[int] = ..., - check_hostname: bool = ..., - purpose: Any = ..., - certfile: Optional[str] = ..., - keyfile: Optional[str] = ..., - cafile: Optional[str] = ..., - capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., - ) -> SSLContext: ... +def _create_unverified_context( + protocol: int = ..., + *, + cert_reqs: Optional[int] = ..., + check_hostname: bool = ..., + purpose: Any = ..., + certfile: Optional[str] = ..., + keyfile: Optional[str] = ..., + cafile: Optional[str] = ..., + capath: Optional[str] = ..., + cadata: Union[Text, bytes, None] = ..., +) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] -if sys.version_info >= (3, 3): - def RAND_bytes(__num: int) -> bytes: ... - def RAND_pseudo_bytes(__num: int) -> Tuple[bytes, bool]: ... - def RAND_status() -> bool: ... def RAND_egd(path: str) -> None: ... def RAND_add(__s: bytes, __entropy: float) -> None: ... @@ -128,64 +97,17 @@ PROTOCOL_TLSv1: int PROTOCOL_TLSv1_1: int PROTOCOL_TLSv1_2: int PROTOCOL_TLS: int -if sys.version_info >= (3, 6): - PROTOCOL_TLS_CLIENT: int - PROTOCOL_TLS_SERVER: 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 -if sys.version_info >= (3, 6): - class Options(enum.IntFlag): - 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_NO_TLSv1_3: int - OP_CIPHER_SERVER_PREFERENCE: int - OP_SINGLE_DH_USE: int - OP_SINGLE_ECDH_USE: int - OP_NO_COMPRESSION: int - OP_NO_TICKET: int - if sys.version_info >= (3, 7): - OP_NO_RENEGOTIATION: int - if sys.version_info >= (3, 8): - OP_ENABLE_MIDDLEBOX_COMPAT: int - OP_ALL: Options - OP_NO_SSLv2: Options - OP_NO_SSLv3: Options - OP_NO_TLSv1: Options - OP_NO_TLSv1_1: Options - OP_NO_TLSv1_2: Options - OP_NO_TLSv1_3: Options - OP_CIPHER_SERVER_PREFERENCE: Options - 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 - if sys.version_info >= (3, 8): - OP_ENABLE_MIDDLEBOX_COMPAT: Options -else: - 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 - -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_TLSv1_3: bool HAS_ALPN: bool HAS_ECDH: bool HAS_SNI: bool @@ -230,47 +152,35 @@ class _ASN1Object(NamedTuple): longname: str oid: str -if sys.version_info >= (3, 4): - class Purpose(_ASN1Object, enum.Enum): - SERVER_AUTH: _ASN1Object - CLIENT_AUTH: _ASN1Object - -else: - class Purpose(_ASN1Object): - SERVER_AUTH: ClassVar[Purpose] - CLIENT_AUTH: ClassVar[Purpose] +class Purpose(_ASN1Object): + SERVER_AUTH: ClassVar[Purpose] + CLIENT_AUTH: ClassVar[Purpose] class SSLSocket(socket.socket): context: SSLContext server_side: bool server_hostname: Optional[str] - if sys.version_info >= (3, 6): - session: Optional[SSLSession] - session_reused: Optional[bool] - if sys.version_info < (3, 7): - def __init__( - self, - sock: Optional[socket.socket] = ..., - keyfile: Optional[str] = ..., - certfile: Optional[str] = ..., - server_side: bool = ..., - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: Optional[str] = ..., - do_handshake_on_connect: bool = ..., - family: int = ..., - type: int = ..., - proto: int = ..., - fileno: Optional[int] = ..., - suppress_ragged_eofs: bool = ..., - npn_protocols: Optional[Iterable[str]] = ..., - ciphers: Optional[str] = ..., - server_hostname: Optional[str] = ..., - _context: Optional[SSLContext] = ..., - _session: Optional[Any] = ..., - ) -> None: ... - else: - def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def __init__( + self, + sock: Optional[socket.socket] = ..., + keyfile: Optional[str] = ..., + certfile: Optional[str] = ..., + server_side: bool = ..., + cert_reqs: int = ..., + ssl_version: int = ..., + ca_certs: Optional[str] = ..., + do_handshake_on_connect: bool = ..., + family: int = ..., + type: int = ..., + proto: int = ..., + fileno: Optional[int] = ..., + suppress_ragged_eofs: bool = ..., + npn_protocols: Optional[Iterable[str]] = ..., + ciphers: Optional[str] = ..., + server_hostname: Optional[str] = ..., + _context: Optional[SSLContext] = ..., + _session: Optional[Any] = ..., + ) -> None: ... def connect(self, addr: Union[socket._Address, bytes]) -> None: ... def connect_ex(self, addr: Union[socket._Address, bytes]) -> int: ... def recv(self, buflen: int = ..., flags: int = ...) -> bytes: ... @@ -293,8 +203,6 @@ class SSLSocket(socket.socket): @overload def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def cipher(self) -> Optional[Tuple[str, str, int]]: ... - if sys.version_info >= (3, 5): - def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... def compression(self) -> Optional[str]: ... def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... def selected_alpn_protocol(self) -> Optional[str]: ... @@ -303,39 +211,15 @@ class SSLSocket(socket.socket): def unwrap(self) -> socket.socket: ... def version(self) -> Optional[str]: ... def pending(self) -> int: ... - 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 SSLContext: check_hostname: bool - if sys.version_info >= (3, 6): - options: Options - else: - options: int - if sys.version_info >= (3, 8): - post_handshake_auth: bool - if sys.version_info >= (3, 5): - def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> SSLContext: ... - else: - def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> SSLContext: ... + options: int + def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> SSLContext: ... @property def protocol(self) -> int: ... verify_flags: int verify_mode: int - if sys.version_info >= (3, 5): - def __init__(self, protocol: int = ...) -> None: ... - else: - def __init__(self, protocol: int) -> None: ... + def __init__(self, protocol: int) -> None: ... def cert_store_stats(self) -> Dict[str, int]: ... def load_cert_chain( self, certfile: StrPath, keyfile: Optional[StrPath] = ..., password: Optional[_PasswordType] = ... @@ -348,113 +232,19 @@ class SSLContext: def set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... - if sys.version_info >= (3, 7): - sni_callback: Optional[Callable[[SSLObject, str, SSLContext], Union[None, int]]] - sslobject_class: Type[SSLObject] def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... - if sys.version_info >= (3, 7): - def set_servername_callback(self, server_name_callback: Optional[_SrvnmeCbType]) -> None: ... - else: - def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> None: ... + def set_servername_callback(self, __method: Optional[_SrvnmeCbType]) -> None: ... def load_dh_params(self, __path: str) -> None: ... def set_ecdh_curve(self, __name: str) -> None: ... - if sys.version_info >= (3, 6): - def wrap_socket( - self, - sock: socket.socket, - server_side: bool = ..., - do_handshake_on_connect: bool = ..., - suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ..., - session: Optional[SSLSession] = ..., - ) -> SSLSocket: ... - else: - def wrap_socket( - self, - sock: socket.socket, - server_side: bool = ..., - do_handshake_on_connect: bool = ..., - suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ..., - ) -> SSLSocket: ... - if sys.version_info >= (3, 6): - def wrap_bio( - self, - incoming: MemoryBIO, - outgoing: MemoryBIO, - server_side: bool = ..., - server_hostname: Optional[str] = ..., - session: Optional[SSLSession] = ..., - ) -> SSLObject: ... - elif sys.version_info >= (3, 5): - def wrap_bio( - self, incoming: MemoryBIO, outgoing: MemoryBIO, server_side: bool = ..., server_hostname: Optional[str] = ... - ) -> SSLObject: ... + def wrap_socket( + self, + sock: socket.socket, + server_side: bool = ..., + do_handshake_on_connect: bool = ..., + suppress_ragged_eofs: bool = ..., + server_hostname: Optional[str] = ..., + ) -> SSLSocket: ... def session_stats(self) -> Dict[str, int]: ... - if sys.version_info >= (3, 7): - hostname_checks_common_name: bool - maximum_version: TLSVersion - minimum_version: TLSVersion - -if sys.version_info >= (3, 5): - class SSLObject: - context: SSLContext - server_side: bool - server_hostname: Optional[str] - if sys.version_info >= (3, 6): - session: Optional[SSLSession] - session_reused: bool - if sys.version_info >= (3, 7): - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - else: - def __init__( - self, sslobj: Any, owner: Optional[Union[SSLSocket, SSLObject]] = ..., session: Optional[Any] = ... - ) -> None: ... - def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... - def write(self, data: bytes) -> int: ... - @overload - def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ... - @overload - def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ... - @overload - def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... - def selected_alpn_protocol(self) -> Optional[str]: ... - def selected_npn_protocol(self) -> Optional[str]: ... - def cipher(self) -> Optional[Tuple[str, str, int]]: ... - def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... - def compression(self) -> Optional[str]: ... - def pending(self) -> int: ... - def do_handshake(self) -> None: ... - def unwrap(self) -> None: ... - def version(self) -> Optional[str]: ... - def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... - if sys.version_info >= (3, 8): - def verify_client_post_handshake(self) -> None: ... - class MemoryBIO: - pending: int - eof: bool - def read(self, __size: int = ...) -> bytes: ... - def write(self, __buf: bytes) -> int: ... - def write_eof(self) -> None: ... - -if sys.version_info >= (3, 6): - class SSLSession: - id: bytes - time: int - timeout: int - ticket_lifetime_hint: int - has_ticket: bool - class VerifyFlags(enum.IntFlag): - VERIFY_DEFAULT: int - VERIFY_CRL_CHECK_LEAF: int - VERIFY_CRL_CHECK_CHAIN: int - VERIFY_X509_STRICT: int - VERIFY_X509_TRUSTED_FIRST: int - class VerifyMode(enum.IntEnum): - CERT_NONE: int - CERT_OPTIONAL: int - CERT_REQUIRED: int - # TODO below documented in cpython but not in docs.python.org # taken from python 3.4 SSL_ERROR_EOF: int @@ -469,8 +259,7 @@ SSL_ERROR_ZERO_RETURN: int def get_protocol_name(protocol_code: int) -> str: ... -if sys.version_info < (3, 9): - AF_INET: int +AF_INET: int PEM_FOOTER: str PEM_HEADER: str SOCK_STREAM: int diff --git a/stdlib/@python2/struct.pyi b/stdlib/@python2/struct.pyi index 096f8b7b85ca..f100e6aa0c81 100644 --- a/stdlib/@python2/struct.pyi +++ b/stdlib/@python2/struct.pyi @@ -6,33 +6,21 @@ from typing import Any, Iterator, Text, Tuple, Union class error(Exception): ... _FmtType = Union[bytes, Text] -if sys.version_info >= (3,): - _BufferType = Union[array[int], bytes, bytearray, memoryview, mmap] - _WriteBufferType = Union[array[Any], bytearray, memoryview, mmap] -else: - _BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] - _WriteBufferType = Union[array[Any], bytearray, buffer, memoryview, mmap] +_BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] +_WriteBufferType = Union[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, ...]: ... -if sys.version_info >= (3, 4): - def iter_unpack(__format: _FmtType, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... - def calcsize(__format: _FmtType) -> int: ... class Struct: - if sys.version_info >= (3, 7): - format: str - else: - format: bytes + 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, ...]: ... - if sys.version_info >= (3, 4): - def iter_unpack(self, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index 175068861ee9..020fac474df0 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -20,23 +20,10 @@ AUDIO_FILE_ENCODING_ADPCM_G723_5: int AUDIO_FILE_ENCODING_ALAW_8: int AUDIO_UNKNOWN_SIZE: int -if sys.version_info >= (3, 0): - class _sunau_params(NamedTuple): - nchannels: int - sampwidth: int - framerate: int - nframes: int - comptype: str - compname: str - -else: - _sunau_params = Tuple[int, int, int, int, str, str] +_sunau_params = Tuple[int, int, int, int, str, str] class Au_read: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 3): - def __enter__(self) -> Au_read: ... - def __exit__(self, *args: Any) -> None: ... def getfp(self) -> Optional[IO[bytes]]: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -55,9 +42,6 @@ class Au_read: class Au_write: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 3): - def __enter__(self) -> Au_write: ... - def __exit__(self, *args: Any) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... @@ -80,5 +64,4 @@ class Au_write: # Returns a Au_read if mode is rb and Au_write if mode is wb def open(f: _File, mode: Optional[str] = ...) -> Any: ... -if sys.version_info < (3, 9): - openfp = open +openfp = open diff --git a/stdlib/@python2/symtable.pyi b/stdlib/@python2/symtable.pyi index b528481bf510..8417f5948660 100644 --- a/stdlib/@python2/symtable.pyi +++ b/stdlib/@python2/symtable.pyi @@ -13,8 +13,7 @@ class SymbolTable(object): def is_nested(self) -> bool: ... def has_children(self) -> bool: ... def has_exec(self) -> bool: ... - if sys.version_info < (3, 0): - def has_import_star(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]: ... @@ -30,20 +29,13 @@ class Class(SymbolTable): def get_methods(self) -> Tuple[str, ...]: ... class Symbol(object): - if sys.version_info >= (3, 8): - def __init__( - self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ..., *, module_scope: bool = ... - ) -> None: ... - else: - def __init__(self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ...) -> None: ... + def __init__(self, name: str, flags: int, namespaces: Optional[Sequence[SymbolTable]] = ...) -> 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: ... - if sys.version_info >= (3, 6): - def is_annotated(self) -> bool: ... def is_free(self) -> bool: ... def is_imported(self) -> bool: ... def is_assigned(self) -> bool: ... diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index afb88161d68b..3eb461578b58 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -46,14 +46,10 @@ GNU_TYPES: Tuple[bytes, ...] PAX_FIELDS: Tuple[str, ...] PAX_NUMBER_FIELDS: Dict[str, type] -if sys.version_info >= (3,): - PAX_NAME_FIELDS: Set[str] - ENCODING: str -if sys.version_info < (3,): - TAR_PLAIN: int - TAR_GZIPPED: int +TAR_PLAIN: int +TAR_GZIPPED: int def open( name: Optional[AnyPath] = ..., @@ -92,8 +88,7 @@ class TarFile(Iterable[TarInfo]): debug: Optional[int] errorlevel: Optional[int] offset: int # undocumented - if sys.version_info < (3,): - posix: bool + posix: bool def __init__( self, name: Optional[AnyPath] = ..., @@ -204,23 +199,10 @@ class TarFile(Iterable[TarInfo]): def getmember(self, name: str) -> TarInfo: ... def getmembers(self) -> List[TarInfo]: ... def getnames(self) -> List[str]: ... - if sys.version_info >= (3, 5): - def list(self, verbose: bool = ..., *, members: Optional[List[TarInfo]] = ...) -> None: ... - else: - def list(self, verbose: bool = ...) -> None: ... + def list(self, verbose: bool = ...) -> None: ... def next(self) -> Optional[TarInfo]: ... - if sys.version_info >= (3, 5): - def extractall( - self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ... - ) -> None: ... - else: - def extractall(self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... - if sys.version_info >= (3, 5): - def extract( - self, member: Union[str, TarInfo], path: AnyPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... - ) -> None: ... - else: - def extract(self, member: Union[str, TarInfo], path: AnyPath = ...) -> None: ... + def extractall(self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... + def extract(self, member: Union[str, TarInfo], path: AnyPath = ...) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... def makedir(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makefile(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented @@ -228,58 +210,29 @@ class TarFile(Iterable[TarInfo]): def makefifo(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makedev(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def makelink(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - if sys.version_info >= (3, 5): - def chown(self, tarinfo: TarInfo, targetpath: AnyPath, numeric_owner: bool) -> None: ... # undocumented - else: - def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented + def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def chmod(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented def utime(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - if sys.version_info >= (3, 7): - def add( - self, - name: StrPath, - arcname: Optional[StrPath] = ..., - recursive: bool = ..., - *, - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., - ) -> None: ... - elif sys.version_info >= (3,): - def add( - self, - name: StrPath, - arcname: Optional[StrPath] = ..., - recursive: bool = ..., - exclude: Optional[Callable[[str], bool]] = ..., - *, - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., - ) -> None: ... - else: - def add( - self, - name: str, - arcname: Optional[str] = ..., - recursive: bool = ..., - exclude: Optional[Callable[[str], bool]] = ..., - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., - ) -> None: ... + def add( + self, + name: str, + arcname: Optional[str] = ..., + recursive: bool = ..., + exclude: Optional[Callable[[str], bool]] = ..., + filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., + ) -> None: ... def addfile(self, tarinfo: TarInfo, fileobj: Optional[IO[bytes]] = ...) -> None: ... def gettarinfo( self, name: Optional[str] = ..., arcname: Optional[str] = ..., fileobj: Optional[IO[bytes]] = ... ) -> TarInfo: ... def close(self) -> None: ... -if sys.version_info >= (3, 9): - def is_tarfile(name: Union[AnyPath, IO[bytes]]) -> bool: ... +def is_tarfile(name: AnyPath) -> bool: ... -else: - def is_tarfile(name: AnyPath) -> bool: ... +def filemode(mode: int) -> str: ... # undocumented -if sys.version_info < (3, 8): - def filemode(mode: int) -> str: ... # undocumented - -if sys.version_info < (3,): - class TarFileCompat: - def __init__(self, filename: str, mode: str = ..., compression: int = ...) -> None: ... +class TarFileCompat: + def __init__(self, filename: str, mode: str = ..., compression: int = ...) -> None: ... class TarError(Exception): ... class ReadError(TarError): ... @@ -309,12 +262,8 @@ class TarInfo: gname: str pax_headers: Mapping[str, str] def __init__(self, name: str = ...) -> None: ... - if sys.version_info >= (3,): - @classmethod - def frombuf(cls, buf: bytes, encoding: str, errors: str) -> TarInfo: ... - else: - @classmethod - def frombuf(cls, buf: bytes) -> TarInfo: ... + @classmethod + def frombuf(cls, buf: bytes) -> TarInfo: ... @classmethod def fromtarfile(cls, tarfile: TarFile) -> TarInfo: ... @property diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index 31fd3eef81cd..d59efc994be8 100644 --- a/stdlib/@python2/telnetlib.pyi +++ b/stdlib/@python2/telnetlib.pyi @@ -110,6 +110,3 @@ class Telnet: def expect( self, list: Sequence[Union[Pattern[bytes], bytes]], timeout: Optional[float] = ... ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... - if sys.version_info >= (3, 6): - def __enter__(self) -> Telnet: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index af0b0af89d9b..f8e1fc46b10a 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -12,30 +12,17 @@ __all__: List[str] def active_count() -> int: ... -if sys.version_info < (3,): - def activeCount() -> int: ... +def activeCount() -> int: ... def current_thread() -> Thread: ... def currentThread() -> Thread: ... -if sys.version_info >= (3,): - def get_ident() -> int: ... - def enumerate() -> List[Thread]: ... -if sys.version_info >= (3, 4): - def main_thread() -> Thread: ... - -if sys.version_info >= (3, 8): - from _thread import get_native_id as get_native_id - def settrace(func: _TF) -> None: ... def setprofile(func: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... -if sys.version_info >= (3,): - TIMEOUT_MAX: float - class ThreadError(Exception): ... class local(object): @@ -47,37 +34,21 @@ class Thread: name: str ident: Optional[int] daemon: bool - if sys.version_info >= (3,): - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - *, - daemon: Optional[bool] = ..., - ) -> None: ... - else: - def __init__( - self, - group: None = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[Text] = ..., - args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., - ) -> None: ... + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[Text] = ..., + args: Iterable[Any] = ..., + kwargs: Optional[Mapping[Text, Any]] = ..., + ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: Text) -> None: ... - if sys.version_info >= (3, 8): - @property - def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... - if sys.version_info < (3, 9): - def isAlive(self) -> bool: ... + def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... def setDaemon(self, daemonic: bool) -> None: ... @@ -89,10 +60,7 @@ class Lock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -102,10 +70,7 @@ class _RLock: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock @@ -116,14 +81,9 @@ class Condition: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... + def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... - if sys.version_info >= (3,): - def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -133,56 +93,23 @@ class Semaphore: def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> Optional[bool]: ... - if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ... - else: - def acquire(self, blocking: bool = ...) -> bool: ... - def __enter__(self, blocking: bool = ...) -> bool: ... - if sys.version_info >= (3, 9): - def release(self, n: int = ...) -> None: ... - else: - def release(self) -> 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: ... - if sys.version_info < (3,): - def isSet(self) -> bool: ... + def isSet(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... -if sys.version_info >= (3, 8): - from _thread import _excepthook, _ExceptHookArgs - - excepthook = _excepthook - ExceptHookArgs = _ExceptHookArgs - class Timer(Thread): - if sys.version_info >= (3,): - def __init__( - self, - interval: float, - function: Callable[..., Any], - args: Optional[Iterable[Any]] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., - ) -> None: ... - else: - def __init__( - self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... - ) -> None: ... + def __init__( + self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... + ) -> None: ... def cancel(self) -> None: ... -if sys.version_info >= (3,): - class Barrier: - parties: int - n_waiting: int - broken: bool - def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> int: ... - def reset(self) -> None: ... - def abort(self) -> None: ... - class BrokenBarrierError(RuntimeError): ... diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index 6e926c68dc39..37a088682537 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -1,40 +1,14 @@ import sys from typing import Any, NamedTuple, Optional, Tuple, Union -if sys.version_info >= (3, 3): - from types import SimpleNamespace - _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] -if sys.version_info < (3, 3): - accept2dyear: bool +accept2dyear: bool altzone: int 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.version_info >= (3, 3) and sys.platform != "win32": - CLOCK_MONOTONIC: int - CLOCK_MONOTONIC_RAW: int - CLOCK_PROCESS_CPUTIME_ID: int - CLOCK_REALTIME: int - CLOCK_THREAD_CPUTIME_ID: int - if sys.platform != "linux" and sys.platform != "darwin": - CLOCK_HIGHRES: int # Solaris only - -if sys.version_info >= (3, 8) and sys.platform == "darwin": - CLOCK_UPTIME_RAW: int - -if sys.version_info >= (3, 9) and sys.platform == "linux": - CLOCK_TAI: int - class _struct_time(NamedTuple): tm_year: int tm_mon: int @@ -52,41 +26,13 @@ class _struct_time(NamedTuple): @property def n_unnamed_fields(self) -> int: ... -if sys.version_info >= (3, 3): - class struct_time(_struct_time): - def __init__( - self, - o: Union[ - Tuple[int, int, int, int, int, int, int, int, int], - Tuple[int, int, int, int, int, int, int, int, int, str], - Tuple[int, int, int, int, int, int, int, int, int, str, int], - ], - _arg: Any = ..., - ) -> None: ... - def __new__( - cls, - o: Union[ - Tuple[int, int, int, int, int, int, int, int, int], - Tuple[int, int, int, int, int, int, int, int, int, str], - Tuple[int, int, int, int, int, int, int, int, int, str, int], - ], - _arg: Any = ..., - ) -> struct_time: ... - if sys.version_info >= (3, 6) or sys.platform != "win32": - @property - def tm_zone(self) -> str: ... - @property - def tm_gmtoff(self) -> int: ... - -else: - class struct_time(_struct_time): - def __init__(self, o: _TimeTuple, _arg: Any = ...) -> None: ... - def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ... +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: Union[_TimeTuple, struct_time] = ...) -> str: ... -if sys.version_info < (3, 8): - def clock() -> float: ... +def clock() -> float: ... def ctime(secs: Optional[float] = ...) -> str: ... def gmtime(secs: Optional[float] = ...) -> struct_time: ... @@ -100,23 +46,3 @@ def time() -> float: ... if sys.platform != "win32": def tzset() -> None: ... # Unix only -if sys.version_info >= (3, 3): - def get_clock_info(name: str) -> SimpleNamespace: ... - def monotonic() -> float: ... - def perf_counter() -> float: ... - def process_time() -> float: ... - if sys.platform != "win32": - def clock_getres(clk_id: int) -> float: ... # Unix only - 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: ... - 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/stdlib/@python2/timeit.pyi b/stdlib/@python2/timeit.pyi index 8de9af28d7ad..89ba33e31ae1 100644 --- a/stdlib/@python2/timeit.pyi +++ b/stdlib/@python2/timeit.pyi @@ -8,36 +8,14 @@ _stmt = Union[_str, Callable[[], Any]] default_timer: _Timer class Timer: - if sys.version_info >= (3, 5): - def __init__( - self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., globals: Optional[Dict[str, Any]] = ... - ) -> None: ... - else: - def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> None: ... + def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> None: ... def print_exc(self, file: Optional[IO[str]] = ...) -> None: ... def timeit(self, number: int = ...) -> float: ... def repeat(self, repeat: int = ..., number: int = ...) -> List[float]: ... - if sys.version_info >= (3, 6): - def autorange(self, callback: Optional[Callable[[int, float], Any]] = ...) -> Tuple[int, float]: ... - -if sys.version_info >= (3, 5): - def timeit( - stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., number: int = ..., globals: Optional[Dict[str, Any]] = ... - ) -> float: ... - def repeat( - stmt: _stmt = ..., - setup: _stmt = ..., - timer: _Timer = ..., - repeat: int = ..., - number: int = ..., - globals: Optional[Dict[str, Any]] = ..., - ) -> List[float]: ... - -else: - 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]: ... +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] diff --git a/stdlib/@python2/token.pyi b/stdlib/@python2/token.pyi index a806a466b8ea..8a469a87c639 100644 --- a/stdlib/@python2/token.pyi +++ b/stdlib/@python2/token.pyi @@ -26,8 +26,7 @@ GREATER: int EQUAL: int DOT: int PERCENT: int -if sys.version_info < (3,): - BACKQUOTE: int +BACKQUOTE: int LBRACE: int RBRACE: int EQEQUAL: int @@ -53,33 +52,11 @@ DOUBLESTAREQUAL: int DOUBLESLASH: int DOUBLESLASHEQUAL: int AT: int -if sys.version_info >= (3,): - RARROW: int - ELLIPSIS: int -if sys.version_info >= (3, 5): - ATEQUAL: int - if sys.version_info < (3, 7): - # These were removed in Python 3.7 but added back in Python 3.8 - AWAIT: int - ASYNC: int -if sys.version_info >= (3, 8): - AWAIT: int - ASYNC: int OP: int 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 -if sys.version_info >= (3, 8): - TYPE_COMMENT: int - TYPE_IGNORE: int - COLONEQUAL: int - EXACT_TOKEN_TYPES: Dict[str, int] - def ISTERMINAL(x: int) -> bool: ... def ISNONTERMINAL(x: int) -> bool: ... def ISEOF(x: int) -> bool: ... diff --git a/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 3c24ee21bee4..6a8d52cf134c 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -7,191 +7,36 @@ _PT = Tuple[str, int, str, Optional[str]] def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -if sys.version_info >= (3, 10): - def print_exception( - __exc: Optional[Type[BaseException]], - value: Optional[BaseException] = ..., - tb: Optional[TracebackType] = ..., - limit: Optional[int] = ..., - file: Optional[IO[str]] = ..., - chain: bool = ..., - ) -> None: ... +def print_exception( + etype: Optional[Type[BaseException]], + value: Optional[BaseException], + tb: Optional[TracebackType], + limit: Optional[int] = ..., + file: Optional[IO[str]] = ..., +) -> None: ... -elif sys.version_info >= (3,): - def print_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., - file: Optional[IO[str]] = ..., - chain: bool = ..., - ) -> None: ... - -else: - def print_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., - file: Optional[IO[str]] = ..., - ) -> None: ... - -if sys.version_info >= (3,): - def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... - def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... - -else: - def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... - def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... def print_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -if sys.version_info >= (3, 5): - def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> StackSummary: ... - def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> StackSummary: ... - def format_list(extracted_list: List[FrameSummary]) -> List[str]: ... - # undocumented - def print_list(extracted_list: List[FrameSummary], file: Optional[SupportsWrite[str]] = ...) -> None: ... - -else: - def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... - def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... - def format_list(extracted_list: List[_PT]) -> List[str]: ... - -if sys.version_info >= (3, 10): - def format_exception_only(__exc: Optional[Type[BaseException]], value: Optional[BaseException] = ...) -> List[str]: ... +def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... +def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... +def format_list(extracted_list: List[_PT]) -> List[str]: ... -else: - def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... +def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... -if sys.version_info >= (3, 10): - def format_exception( - __exc: Optional[Type[BaseException]], - value: Optional[BaseException] = ..., - tb: Optional[TracebackType] = ..., - limit: Optional[int] = ..., - chain: bool = ..., - ) -> List[str]: ... +def format_exception( + etype: Optional[Type[BaseException]], + value: Optional[BaseException], + tb: Optional[TracebackType], + limit: Optional[int] = ..., +) -> List[str]: ... -elif sys.version_info >= (3,): - def format_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., - chain: bool = ..., - ) -> List[str]: ... - -else: - def format_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., - ) -> List[str]: ... - -if sys.version_info >= (3,): - def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... - -else: - def format_exc(limit: Optional[int] = ...) -> str: ... +def format_exc(limit: Optional[int] = ...) -> str: ... def format_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ... def format_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[str]: ... -if sys.version_info >= (3, 4): - def clear_frames(tb: TracebackType) -> None: ... - -if sys.version_info >= (3, 5): - def walk_stack(f: Optional[FrameType]) -> Iterator[Tuple[FrameType, int]]: ... - def walk_tb(tb: Optional[TracebackType]) -> Iterator[Tuple[FrameType, int]]: ... - -if sys.version_info < (3,): - def tb_lineno(tb: TracebackType) -> int: ... +def tb_lineno(tb: TracebackType) -> int: ... -if sys.version_info >= (3, 5): - class TracebackException: - __cause__: TracebackException - __context__: TracebackException - __suppress_context__: bool - stack: StackSummary - exc_type: Type[BaseException] - filename: str - lineno: int - text: str - offset: int - msg: str - if sys.version_info >= (3, 10): - def __init__( - self, - exc_type: Type[BaseException], - exc_value: BaseException, - exc_traceback: TracebackType, - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - compact: bool = ..., - _seen: Optional[Set[int]] = ..., - ) -> None: ... - @classmethod - def from_exception( - cls, - exc: BaseException, - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - compact: bool = ..., - ) -> TracebackException: ... - else: - def __init__( - self, - exc_type: Type[BaseException], - exc_value: BaseException, - exc_traceback: TracebackType, - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - _seen: Optional[Set[int]] = ..., - ) -> None: ... - @classmethod - def from_exception( - cls, exc: BaseException, *, limit: Optional[int] = ..., lookup_lines: bool = ..., capture_locals: bool = ... - ) -> TracebackException: ... - def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ... - def format_exception_only(self) -> Generator[str, None, None]: ... - class FrameSummary(Iterable[Any]): - filename: str - lineno: int - name: str - line: str - locals: Optional[Dict[str, str]] - def __init__( - self, - filename: str, - lineno: int, - name: str, - *, - lookup_line: bool = ..., - locals: Optional[Mapping[str, str]] = ..., - line: Optional[str] = ..., - ) -> None: ... - # TODO: more precise typing for __getitem__ and __iter__, - # for a namedtuple-like view on (filename, lineno, name, str). - def __getitem__(self, i: int) -> Any: ... - def __iter__(self) -> Iterator[Any]: ... - class StackSummary(List[FrameSummary]): - @classmethod - def extract( - cls, - frame_gen: Generator[Tuple[FrameType, int], None, None], - *, - limit: Optional[int] = ..., - lookup_lines: bool = ..., - capture_locals: bool = ..., - ) -> StackSummary: ... - @classmethod - def from_list(cls, a_list: List[_PT]) -> StackSummary: ... - def format(self) -> List[str]: ... diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index a44b25926968..d2fd7c0708d2 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -1,12 +1,9 @@ import sys from typing import Any, Callable, Dict, List, Optional, Sequence, Text, Tuple, TypeVar, Union, overload -if sys.version_info >= (3,): - from tkinter import Canvas, PhotoImage -else: - # TODO: Replace these aliases once we have Python 2 stubs for the Tkinter module. - Canvas = Any - PhotoImage = Any +# 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 @@ -32,18 +29,6 @@ class TurtleScreenBase(object): xscale: float = ... yscale: float = ... def __init__(self, cv: Canvas) -> None: ... - if sys.version_info >= (3,): - def mainloop(self) -> None: ... - def textinput(self, title: str, prompt: str) -> Optional[str]: ... - def numinput( - self, - title: str, - prompt: str, - default: Optional[float] = ..., - minval: Optional[float] = ..., - maxval: Optional[float] = ..., - ) -> Optional[float]: ... - class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... @@ -102,10 +87,6 @@ class TurtleScreen(TurtleScreenBase): resetscreen = reset clearscreen = clear addshape = register_shape - if sys.version_info >= (3,): - def onkeypress(self, fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... - onkeyrelease = onkey - class TNavigator(object): START_ORIENTATION: Dict[str, Vec2D] = ... DEFAULT_MODE: str = ... @@ -239,19 +220,6 @@ class RawTurtle(TPen, TNavigator): def shapesize( self, stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ... ) -> None: ... - if sys.version_info >= (3,): - @overload - def shearfactor(self, shear: None = ...) -> float: ... - @overload - def shearfactor(self, shear: float) -> None: ... - # Unsafely overlaps when no arguments are provided - @overload - def shapetransform(self) -> Tuple[float, float, float, float]: ... # type: ignore - @overload - def shapetransform( - self, t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... - ) -> None: ... - def get_shapepoly(self) -> Optional[_PolygonCoords]: ... def settiltangle(self, angle: float) -> None: ... @overload def tiltangle(self, angle: None = ...) -> float: ... @@ -318,12 +286,6 @@ def write_docstringdict(filename: str = ...) -> None: ... # TurtleScreenBase in Python 3.0 def mainloop() -> None: ... -if sys.version_info >= (3,): - def textinput(title: str, prompt: str) -> Optional[str]: ... - def numinput( - title: str, prompt: str, default: Optional[float] = ..., minval: Optional[float] = ..., maxval: Optional[float] = ... - ) -> Optional[float]: ... - # Functions copied from TurtleScreen: def clear() -> None: ... @@ -375,10 +337,6 @@ onscreenclick = onclick resetscreen = reset clearscreen = clear addshape = register_shape -if sys.version_info >= (3,): - def onkeypress(fun: Callable[[], Any], key: Optional[str] = ...) -> None: ... - onkeyrelease = onkey - # Functions copied from _Screen: def setup(width: float = ..., height: float = ..., startx: Optional[int] = ..., starty: Optional[int] = ...) -> None: ... @@ -509,20 +467,6 @@ def shapesize() -> Tuple[float, float, float]: ... # type: ignore @overload def shapesize(stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ...) -> None: ... -if sys.version_info >= (3,): - @overload - def shearfactor(shear: None = ...) -> float: ... - @overload - def shearfactor(shear: float) -> None: ... - # Unsafely overlaps when no arguments are provided - @overload - def shapetransform() -> Tuple[float, float, float, float]: ... # type: ignore - @overload - def shapetransform( - t11: Optional[float] = ..., t12: Optional[float] = ..., t21: Optional[float] = ..., t22: Optional[float] = ... - ) -> None: ... - def get_shapepoly() -> Optional[_PolygonCoords]: ... - def settiltangle(angle: float) -> None: ... @overload def tiltangle(angle: None = ...) -> float: ... diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index 0250866f3eb8..e38bcf372a9e 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -55,15 +55,10 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): # Mypy plugin hook for 'pop' expects that 'default' has a type variable type. def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore def update(self: _T, __m: _T) -> None: ... - if sys.version_info >= (3, 0): - def items(self) -> ItemsView[str, object]: ... - def keys(self) -> KeysView[str]: ... - def values(self) -> ValuesView[object]: ... - else: - def has_key(self, k: str) -> bool: ... - def viewitems(self) -> ItemsView[str, object]: ... - def viewkeys(self) -> KeysView[str]: ... - def viewvalues(self) -> ValuesView[object]: ... + 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. @@ -71,21 +66,6 @@ TypedDict: object = ... OrderedDict = _Alias() -if sys.version_info >= (3, 3): - from typing import ChainMap as ChainMap - -if sys.version_info >= (3, 5): - from typing import ( - AsyncContextManager as AsyncContextManager, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - Coroutine as Coroutine, - ) - -if sys.version_info >= (3, 6): - from typing import AsyncGenerator as AsyncGenerator - def get_type_hints( obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., @@ -93,10 +73,6 @@ def get_type_hints( include_extras: bool = ..., ) -> Dict[str, Any]: ... -if sys.version_info >= (3, 7): - def get_args(tp: Any) -> Tuple[Any, ...]: ... - def get_origin(tp: Any) -> Optional[Any]: ... - Annotated: _SpecialForm = ... _AnnotatedAlias: Any = ... # undocumented @@ -106,27 +82,24 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta): def __index__(self) -> int: ... # PEP 612 support for Python < 3.9 -if sys.version_info >= (3, 10): - from typing import Concatenate as Concatenate, ParamSpec as ParamSpec, TypeAlias as TypeAlias, TypeGuard as TypeGuard -else: - 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__: Optional[Type[Any]] - __covariant__: bool - __contravariant__: bool - def __init__( - self, name: str, *, bound: Union[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 = ... +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__: Optional[Type[Any]] + __covariant__: bool + __contravariant__: bool + def __init__( + self, name: str, *, bound: Union[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/stdlib/@python2/unicodedata.pyi b/stdlib/@python2/unicodedata.pyi index a83d79ff2ed0..f45ee9a66120 100644 --- a/stdlib/@python2/unicodedata.pyi +++ b/stdlib/@python2/unicodedata.pyi @@ -15,9 +15,6 @@ def decomposition(__chr: Text) -> Text: ... def digit(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... def east_asian_width(__chr: Text) -> Text: ... -if sys.version_info >= (3, 8): - def is_normalized(__form: str, __unistr: str) -> bool: ... - def lookup(__name: Union[Text, bytes]) -> Text: ... def mirrored(__chr: Text) -> int: ... def name(__chr: Text, __default: _T = ...) -> Union[Text, _T]: ... diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index 2bb2c2a1c90e..d32bf7a4f273 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -5,12 +5,6 @@ _File = Union[Text, BinaryIO] class Error(Exception): ... -if sys.version_info >= (3, 7): - def encode( - in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ..., *, backtick: bool = ... - ) -> None: ... - -else: - def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... +def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... def decode(in_file: _File, out_file: Optional[_File] = ..., mode: Optional[int] = ..., quiet: int = ...) -> None: ... diff --git a/stdlib/@python2/uuid.pyi b/stdlib/@python2/uuid.pyi index 68b235162210..8ce48d1ed988 100644 --- a/stdlib/@python2/uuid.pyi +++ b/stdlib/@python2/uuid.pyi @@ -6,38 +6,16 @@ _Int = int _Bytes = bytes _FieldsType = 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 UUID: - if sys.version_info >= (3, 7): - def __init__( - self, - hex: Optional[Text] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., - *, - is_safe: SafeUUID = ..., - ) -> None: ... - @property - def is_safe(self) -> SafeUUID: ... - else: - def __init__( - self, - hex: Optional[Text] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., - ) -> None: ... + def __init__( + self, + hex: Optional[Text] = ..., + bytes: Optional[_Bytes] = ..., + bytes_le: Optional[_Bytes] = ..., + fields: Optional[_FieldsType] = ..., + int: Optional[_Int] = ..., + version: Optional[_Int] = ..., + ) -> None: ... @property def bytes(self) -> _Bytes: ... @property @@ -71,29 +49,22 @@ class UUID: @property def version(self) -> Optional[_Int]: ... def __int__(self) -> _Int: ... - if sys.version_info >= (3,): - def __eq__(self, other: Any) -> bool: ... - def __lt__(self, other: Any) -> bool: ... - def __le__(self, other: Any) -> bool: ... - def __gt__(self, other: Any) -> bool: ... - def __ge__(self, other: Any) -> bool: ... - else: - 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) -> Optional[_Int]: ... - def __cmp__(self, other: Any) -> _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) -> Optional[_Int]: ... + def __cmp__(self, other: Any) -> _Int: ... def getnode() -> int: ... def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ... diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index 0e64ec574775..290700c5ce8f 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -31,28 +31,15 @@ class WarningMessage: lineno: int file: Optional[TextIO] line: Optional[str] - if sys.version_info >= (3, 6): - source: Optional[Any] - def __init__( - self, - message: Union[Warning, str], - category: Type[Warning], - filename: str, - lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., - source: Optional[Any] = ..., - ) -> None: ... - else: - def __init__( - self, - message: Union[Warning, str], - category: Type[Warning], - filename: str, - lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., - ) -> None: ... + def __init__( + self, + message: Union[Warning, str], + category: Type[Warning], + filename: str, + lineno: int, + file: Optional[TextIO] = ..., + line: Optional[str] = ..., + ) -> None: ... class catch_warnings: @overload diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index d415630427da..038254666112 100644 --- a/stdlib/@python2/wave.pyi +++ b/stdlib/@python2/wave.pyi @@ -7,23 +7,10 @@ class Error(Exception): ... WAVE_FORMAT_PCM: int -if sys.version_info >= (3, 0): - class _wave_params(NamedTuple): - nchannels: int - sampwidth: int - framerate: int - nframes: int - comptype: str - compname: str - -else: - _wave_params = Tuple[int, int, int, int, str, str] +_wave_params = Tuple[int, int, int, int, str, str] class Wave_read: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 0): - def __enter__(self) -> Wave_read: ... - def __exit__(self, *args: Any) -> None: ... def getfp(self) -> Optional[BinaryIO]: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -42,9 +29,6 @@ class Wave_read: class Wave_write: def __init__(self, f: _File) -> None: ... - if sys.version_info >= (3, 0): - def __enter__(self) -> Wave_write: ... - def __exit__(self, *args: Any) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... @@ -70,5 +54,4 @@ class Wave_write: # Returns a Wave_read if mode is rb and Wave_write if mode is wb def open(f: _File, mode: Optional[str] = ...) -> Any: ... -if sys.version_info < (3, 9): - openfp = open +openfp = open diff --git a/stdlib/@python2/weakref.pyi b/stdlib/@python2/weakref.pyi index b43b634d6216..a107db5ea323 100644 --- a/stdlib/@python2/weakref.pyi +++ b/stdlib/@python2/weakref.pyi @@ -29,8 +29,7 @@ from _weakref import ( ref as ref, ) -if sys.version_info < (3, 0): - from exceptions import ReferenceError as ReferenceError +from exceptions import ReferenceError as ReferenceError _S = TypeVar("_S") _T = TypeVar("_T") @@ -39,11 +38,6 @@ _VT = TypeVar("_VT") ProxyTypes: Tuple[Type[Any], ...] -if sys.version_info >= (3, 4): - class WeakMethod(ref[types.MethodType]): - def __new__(cls, meth: types.MethodType, callback: Optional[Callable[[types.MethodType], Any]] = ...) -> WeakMethod: ... - def __call__(self) -> Optional[types.MethodType]: ... - class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @@ -53,24 +47,17 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... def __delitem__(self, v: _KT) -> None: ... - if sys.version_info < (3, 0): - def has_key(self, key: object) -> bool: ... + def has_key(self, key: object) -> bool: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... def copy(self) -> WeakValueDictionary[_KT, _VT]: ... - if sys.version_info >= (3, 0): - # These are incompatible with Mapping - def keys(self) -> Iterator[_KT]: ... # type: ignore - def values(self) -> Iterator[_VT]: ... # type: ignore - def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore - else: - 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 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]]: ... @@ -89,32 +76,17 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... def __delitem__(self, v: _KT) -> None: ... - if sys.version_info < (3, 0): - def has_key(self, key: object) -> bool: ... + def has_key(self, key: object) -> bool: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... def copy(self) -> WeakKeyDictionary[_KT, _VT]: ... - if sys.version_info >= (3, 0): - # These are incompatible with Mapping - def keys(self) -> Iterator[_KT]: ... # type: ignore - def values(self) -> Iterator[_VT]: ... # type: ignore - def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore - else: - 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 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]]: ... -if sys.version_info >= (3, 4): - class finalize: - def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - def __call__(self, _: Any = ...) -> Optional[Any]: ... - def detach(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... - def peek(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... - alive: bool - atexit: bool diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index 322ec2764e39..1ee0f3c563f2 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -3,15 +3,9 @@ from typing import Callable, List, Optional, Sequence, Text, Union class Error(Exception): ... -if sys.version_info >= (3, 7): - def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., *, preferred: bool = ... - ) -> None: ... - -else: - def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... - ) -> None: ... +def register( + name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... +) -> None: ... def get(using: Optional[Text] = ...) -> BaseBrowser: ... def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... diff --git a/stdlib/@python2/wsgiref/handlers.pyi b/stdlib/@python2/wsgiref/handlers.pyi index ff764e434169..ce7ea2d5e961 100644 --- a/stdlib/@python2/wsgiref/handlers.pyi +++ b/stdlib/@python2/wsgiref/handlers.pyi @@ -11,9 +11,6 @@ _exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Option def format_date_time(timestamp: Optional[float]) -> str: ... # undocumented -if sys.version_info >= (3, 2): - def read_environ() -> Dict[str, str]: ... - class BaseHandler: wsgi_version: Tuple[int, int] # undocumented wsgi_multithread: bool diff --git a/stdlib/@python2/wsgiref/headers.pyi b/stdlib/@python2/wsgiref/headers.pyi index c3e943200e40..ebdc07053ebf 100644 --- a/stdlib/@python2/wsgiref/headers.pyi +++ b/stdlib/@python2/wsgiref/headers.pyi @@ -6,16 +6,12 @@ _HeaderList = List[Tuple[str, str]] tspecials: Pattern[str] # undocumented class Headers: - if sys.version_info < (3, 5): - def __init__(self, headers: _HeaderList) -> None: ... - else: - def __init__(self, headers: Optional[_HeaderList] = ...) -> None: ... + 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) -> Optional[str]: ... - if sys.version_info < (3,): - def has_key(self, name: str) -> bool: ... + def has_key(self, name: str) -> bool: ... def __contains__(self, name: str) -> bool: ... def get_all(self, name: str) -> List[str]: ... @overload @@ -25,7 +21,5 @@ class Headers: def keys(self) -> List[str]: ... def values(self) -> List[str]: ... def items(self) -> _HeaderList: ... - if sys.version_info >= (3,): - def __bytes__(self) -> bytes: ... def setdefault(self, name: str, value: str) -> str: ... def add_header(self, _name: str, _value: Optional[str], **_params: Optional[str]) -> None: ... diff --git a/stdlib/@python2/wsgiref/simple_server.pyi b/stdlib/@python2/wsgiref/simple_server.pyi index 4e0abd7e8e9d..c10ac27beaeb 100644 --- a/stdlib/@python2/wsgiref/simple_server.pyi +++ b/stdlib/@python2/wsgiref/simple_server.pyi @@ -4,10 +4,7 @@ from typing import List, Optional, Type, TypeVar, overload from .handlers import SimpleHandler from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment -if sys.version_info >= (3, 0): - from http.server import BaseHTTPRequestHandler, HTTPServer -else: - from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer server_version: str # undocumented sys_version: str # undocumented diff --git a/stdlib/@python2/wsgiref/util.pyi b/stdlib/@python2/wsgiref/util.pyi index 1c66bc1fabdf..b77e9df72f33 100644 --- a/stdlib/@python2/wsgiref/util.pyi +++ b/stdlib/@python2/wsgiref/util.pyi @@ -10,10 +10,7 @@ class FileWrapper: def __init__(self, filelike: IO[bytes], blksize: int = ...) -> None: ... def __getitem__(self, key: Any) -> bytes: ... def __iter__(self) -> FileWrapper: ... - if sys.version_info >= (3, 0): - def __next__(self) -> bytes: ... - else: - def next(self) -> bytes: ... + def next(self) -> bytes: ... def guess_scheme(environ: WSGIEnvironment) -> str: ... def application_uri(environ: WSGIEnvironment) -> str: ... diff --git a/stdlib/@python2/wsgiref/validate.pyi b/stdlib/@python2/wsgiref/validate.pyi index bc9f0b8c680f..cd62d785b701 100644 --- a/stdlib/@python2/wsgiref/validate.pyi +++ b/stdlib/@python2/wsgiref/validate.pyi @@ -9,12 +9,8 @@ def validator(application: WSGIApplication) -> WSGIApplication: ... class InputWrapper: input: InputStream def __init__(self, wsgi_input: InputStream) -> None: ... - if sys.version_info >= (3, 0): - def read(self, size: int) -> bytes: ... - def readline(self, size: int = ...) -> bytes: ... - else: - def read(self, size: int = ...) -> bytes: ... - def readline(self) -> bytes: ... + 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: ... @@ -44,9 +40,6 @@ class IteratorWrapper: check_start_response: Optional[bool] def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: Optional[bool]) -> None: ... def __iter__(self) -> IteratorWrapper: ... - if sys.version_info >= (3, 0): - def __next__(self) -> bytes: ... - else: - def next(self) -> bytes: ... + def next(self) -> bytes: ... def close(self) -> None: ... def __del__(self) -> None: ... diff --git a/stdlib/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 67e9b1189528..47a7227bf621 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -17,14 +17,8 @@ class Node(xml.dom.Node): nextSibling: Any previousSibling: Any prefix: Any - if sys.version_info >= (3, 9): - def toxml(self, encoding: Optional[Any] = ..., standalone: Optional[Any] = ...): ... - def toprettyxml( - self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ..., standalone: Optional[Any] = ... - ): ... - else: - def toxml(self, encoding: Optional[Any] = ...): ... - def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ... + def toxml(self, encoding: Optional[Any] = ...): ... + def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ... def hasChildNodes(self) -> bool: ... def insertBefore(self, newChild, refChild): ... def appendChild(self, node): ... @@ -295,18 +289,7 @@ class Document(Node, DocumentLS): def getElementsByTagNameNS(self, namespaceURI: str, localName): ... def isSupported(self, feature, version): ... def importNode(self, node, deep): ... - if sys.version_info >= (3, 9): - def writexml( - self, - writer, - indent: str = ..., - addindent: str = ..., - newl: str = ..., - encoding: Optional[Any] = ..., - standalone: Optional[Any] = ..., - ) -> None: ... - else: - def writexml( - self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ... - ) -> None: ... + def writexml( + self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ... + ) -> None: ... def renameNode(self, n, namespaceURI: str, name): ... diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 4aa0173fa82f..60e006c2601e 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -13,13 +13,4 @@ def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[ # 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... -if sys.version_info >= (3, 9): - def include( - elem: Element, - loader: Optional[Callable[..., Union[str, Element]]] = ..., - base_url: Optional[str] = ..., - max_depth: Optional[int] = ..., - ) -> None: ... - -else: - def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... +def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index ca4e3832f37e..7117caff1033 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -47,47 +47,13 @@ _parser_input_type = Union[bytes, Text] _str_argument_type = Union[str, Text] # Type for return values from individual tag/attr/text values -if sys.version_info >= (3,): - # note: in python3, everything comes out as str, yay: - _str_result_type = str -else: - # 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 +# 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 = Union[AnyPath, FileDescriptor, IO[Any]] -if sys.version_info >= (3, 8): - @overload - def canonicalize( - xml_data: Optional[_parser_input_type] = ..., - *, - out: None = ..., - from_file: Optional[_file_or_filename] = ..., - with_comments: bool = ..., - strip_text: bool = ..., - rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., - ) -> str: ... - @overload - def canonicalize( - xml_data: Optional[_parser_input_type] = ..., - *, - out: SupportsWrite[str], - from_file: Optional[_file_or_filename] = ..., - with_comments: bool = ..., - strip_text: bool = ..., - rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., - ) -> None: ... - class Element(MutableSequence[Element]): tag: _str_result_type attrib: Dict[_str_result_type, _str_result_type] @@ -123,10 +89,7 @@ class Element(MutableSequence[Element]): def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ... @overload def get(self, key: _str_argument_type, default: _T) -> Union[_str_result_type, _T]: ... - if sys.version_info >= (3, 2): - def insert(self, __index: int, __subelement: Element) -> None: ... - else: - def insert(self, __index: int, __element: Element) -> None: ... + def insert(self, __index: int, __element: Element) -> None: ... def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... def iterfind( @@ -147,9 +110,8 @@ class Element(MutableSequence[Element]): def __setitem__(self, i: int, o: Element) -> None: ... @overload def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ... - if sys.version_info < (3, 9): - def getchildren(self) -> List[Element]: ... - def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... + def getchildren(self) -> List[Element]: ... + def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... def SubElement( parent: Element, @@ -171,8 +133,7 @@ class ElementTree: def getroot(self) -> Element: ... def parse(self, source: _file_or_filename, parser: Optional[XMLParser] = ...) -> Element: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... - if sys.version_info < (3, 9): - def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... + def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... def find( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> Optional[Element]: ... @@ -193,137 +154,28 @@ class ElementTree: def iterfind( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> Generator[Element, None, None]: ... - if sys.version_info >= (3, 4): - def write( - self, - file_or_filename: _file_or_filename, - encoding: Optional[str] = ..., - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - method: Optional[str] = ..., - *, - short_empty_elements: bool = ..., - ) -> None: ... - else: - def write( - self, - file_or_filename: _file_or_filename, - encoding: Optional[str] = ..., - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - method: Optional[str] = ..., - ) -> None: ... - def write_c14n(self, file: _file_or_filename) -> None: ... - -def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... - -if sys.version_info >= (3, 8): - @overload - def tostring( - element: Element, - encoding: None = ..., - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> bytes: ... - @overload - def tostring( - element: Element, - encoding: Literal["unicode"], - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> str: ... - @overload - def tostring( - element: Element, - encoding: str, - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> Any: ... - @overload - def tostringlist( - element: Element, - encoding: None = ..., - method: Optional[str] = ..., - *, + def write( + self, + file_or_filename: _file_or_filename, + encoding: Optional[str] = ..., xml_declaration: Optional[bool] = ..., default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> List[bytes]: ... - @overload - def tostringlist( - element: Element, - encoding: Literal["unicode"], method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> List[str]: ... - @overload - def tostringlist( - element: Element, - encoding: str, - method: Optional[str] = ..., - *, - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - short_empty_elements: bool = ..., - ) -> List[Any]: ... + ) -> None: ... + def write_c14n(self, file: _file_or_filename) -> None: ... -elif sys.version_info >= (3,): - @overload - def tostring( - element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ... - ) -> bytes: ... - @overload - def tostring( - element: Element, encoding: Literal["unicode"], method: Optional[str] = ..., *, short_empty_elements: bool = ... - ) -> str: ... - @overload - def tostring(element: Element, encoding: str, method: Optional[str] = ..., *, short_empty_elements: bool = ...) -> Any: ... - @overload - def tostringlist( - element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ... - ) -> List[bytes]: ... - @overload - def tostringlist( - element: Element, encoding: Literal["unicode"], method: Optional[str] = ..., *, short_empty_elements: bool = ... - ) -> List[str]: ... - @overload - def tostringlist( - element: Element, encoding: str, method: Optional[str] = ..., *, short_empty_elements: bool = ... - ) -> List[Any]: ... +def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... -else: - def tostring(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> bytes: ... - def tostringlist(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> List[bytes]: ... +def tostring(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> bytes: ... +def tostringlist(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> List[bytes]: ... def dump(elem: Element) -> None: ... -if sys.version_info >= (3, 9): - def indent(tree: Union[Element, ElementTree], space: str = ..., level: int = ...) -> None: ... - def parse(source: _file_or_filename, parser: Optional[XMLParser] = ...) -> ElementTree: ... def iterparse( source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ... ) -> Iterator[Tuple[str, Any]]: ... -if sys.version_info >= (3, 4): - class XMLPullParser: - def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ... - def feed(self, data: bytes) -> None: ... - def close(self) -> None: ... - def read_events(self) -> Iterator[Tuple[str, Element]]: ... - def XML(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Element: ... def XMLID(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ... @@ -350,31 +202,13 @@ class TreeBuilder: def start(self, __tag: _parser_input_type, __attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ... def end(self, __tag: _parser_input_type) -> Element: ... -if sys.version_info >= (3, 8): - class C14NWriterTarget: - def __init__( - self, - write: Callable[[str], Any], - *, - with_comments: bool = ..., - strip_text: bool = ..., - rewrite_prefixes: bool = ..., - qname_aware_tags: Optional[Iterable[str]] = ..., - qname_aware_attrs: Optional[Iterable[str]] = ..., - exclude_attrs: Optional[Iterable[str]] = ..., - exclude_tags: Optional[Iterable[str]] = ..., - ) -> None: ... - class XMLParser: parser: Any target: Any # TODO-what is entity used for??? entity: Any version: str - if sys.version_info >= (3, 8): - def __init__(self, *, target: Any = ..., encoding: Optional[str] = ...) -> None: ... - else: - def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> None: ... - def doctype(self, __name: str, __pubid: str, __system: str) -> None: ... + def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> 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/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index a95fde106535..086f1c8e4580 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -22,11 +22,7 @@ class SAXReaderNotAvailable(SAXNotSupportedException): ... default_parser_list: List[str] -if sys.version_info >= (3, 8): - def make_parser(parser_list: Iterable[str] = ...) -> XMLReader: ... - -else: - def make_parser(parser_list: List[str] = ...) -> XMLReader: ... +def make_parser(parser_list: List[str] = ...) -> XMLReader: ... def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... def parseString(string: Union[bytes, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... diff --git a/stdlib/@python2/xml/sax/saxutils.pyi b/stdlib/@python2/xml/sax/saxutils.pyi index 8ae2b80d2a26..17b5d278ae59 100644 --- a/stdlib/@python2/xml/sax/saxutils.pyi +++ b/stdlib/@python2/xml/sax/saxutils.pyi @@ -10,19 +10,11 @@ def unescape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... def quoteattr(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... class XMLGenerator(handler.ContentHandler): - if sys.version_info >= (3, 0): - def __init__( - self, - out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., - encoding: str = ..., - short_empty_elements: bool = ..., - ) -> None: ... - else: - def __init__( - self, - out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., - encoding: Text = ..., - ) -> None: ... + def __init__( + self, + out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., + encoding: Text = ..., + ) -> None: ... def startDocument(self): ... def endDocument(self): ... def startPrefixMapping(self, prefix, uri): ... diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index 91727aa540fb..472321be1177 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -23,11 +23,7 @@ from typing import ( _SZI = Union[Text, ZipInfo] _DT = Tuple[int, int, int, int, int, int] -if sys.version_info >= (3,): - class BadZipFile(Exception): ... - BadZipfile = BadZipFile -else: - class BadZipfile(Exception): ... +class BadZipfile(Exception): ... error = BadZipfile @@ -37,28 +33,19 @@ class ZipExtFile(io.BufferedIOBase): MAX_N: int = ... MIN_READ_SIZE: int = ... - if sys.version_info < (3, 6): - PATTERN: Pattern[str] = ... - - if sys.version_info >= (3, 7): - MAX_SEEK_READ: int = ... + PATTERN: Pattern[str] = ... newlines: Optional[List[bytes]] mode: str name: str - if sys.version_info >= (3, 7): - def __init__( - self, fileobj: IO[bytes], mode: str, zipinfo: ZipInfo, pwd: Optional[bytes] = ..., close_fileobj: bool = ... - ) -> None: ... - else: - def __init__( - self, - fileobj: IO[bytes], - mode: str, - zipinfo: ZipInfo, - decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., - close_fileobj: bool = ..., - ) -> None: ... + def __init__( + self, + fileobj: IO[bytes], + mode: str, + zipinfo: ZipInfo, + decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., + close_fileobj: bool = ..., + ) -> None: ... def read(self, n: Optional[int] = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... # type: ignore def __repr__(self) -> str: ... @@ -76,30 +63,9 @@ class ZipFile: fp: Optional[IO[bytes]] NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented - if sys.version_info >= (3, 8): - def __init__( - self, - file: Union[StrPath, IO[bytes]], - mode: str = ..., - compression: int = ..., - allowZip64: bool = ..., - compresslevel: Optional[int] = ..., - *, - strict_timestamps: bool = ..., - ) -> None: ... - elif sys.version_info >= (3, 7): - def __init__( - self, - file: Union[StrPath, IO[bytes]], - mode: str = ..., - compression: int = ..., - allowZip64: bool = ..., - compresslevel: Optional[int] = ..., - ) -> None: ... - else: - def __init__( - self, file: Union[StrPath, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ... - ) -> None: ... + def __init__( + self, file: Union[StrPath, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ... + ) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] @@ -113,49 +79,15 @@ class ZipFile: def extractall( self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ... ) -> None: ... - if sys.version_info >= (3,): - def printdir(self, file: Optional[_Writer] = ...) -> None: ... - else: - def printdir(self) -> None: ... + def printdir(self) -> None: ... def setpassword(self, pwd: bytes) -> None: ... def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ... def testzip(self) -> Optional[str]: ... - if sys.version_info >= (3, 7): - def write( - self, - filename: StrPath, - arcname: Optional[StrPath] = ..., - compress_type: Optional[int] = ..., - compresslevel: Optional[int] = ..., - ) -> None: ... - else: - def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... - if sys.version_info >= (3, 7): - def writestr( - self, - zinfo_or_arcname: _SZI, - data: Union[bytes, str], - compress_type: Optional[int] = ..., - compresslevel: Optional[int] = ..., - ) -> None: ... - elif sys.version_info >= (3,): - def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ... - else: - def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ... + def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... + def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ... class PyZipFile(ZipFile): - if sys.version_info >= (3,): - def __init__( - self, - file: Union[str, IO[bytes]], - mode: str = ..., - compression: int = ..., - allowZip64: bool = ..., - optimize: int = ..., - ) -> None: ... - def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ... - else: - def writepy(self, pathname: Text, basename: Text = ...) -> None: ... + def writepy(self, pathname: Text, basename: Text = ...) -> None: ... class ZipInfo: filename: Text @@ -176,47 +108,11 @@ class ZipInfo: compress_size: int file_size: int def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ... - if sys.version_info >= (3, 8): - @classmethod - def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ... - elif sys.version_info >= (3, 6): - @classmethod - def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ...) -> ZipInfo: ... - if sys.version_info >= (3, 6): - def is_dir(self) -> bool: ... def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ... class _PathOpenProtocol(Protocol): def __call__(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... -if sys.version_info >= (3, 8): - class Path: - @property - def name(self) -> str: ... - @property - def parent(self) -> Path: ... # undocumented - def __init__(self, root: Union[ZipFile, StrPath, IO[bytes]], at: str = ...) -> None: ... - if sys.version_info >= (3, 9): - def open(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... - else: - @property - def open(self) -> _PathOpenProtocol: ... - def iterdir(self) -> Iterator[Path]: ... - def is_dir(self) -> bool: ... - def is_file(self) -> bool: ... - def exists(self) -> bool: ... - def read_text( - self, - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., - line_buffering: bool = ..., - write_through: bool = ..., - ) -> str: ... - def read_bytes(self) -> bytes: ... - def joinpath(self, add: StrPath) -> Path: ... # undocumented - def __truediv__(self, add: StrPath) -> Path: ... - def is_zipfile(filename: Union[StrPath, IO[bytes]]) -> bool: ... ZIP_STORED: int @@ -224,6 +120,3 @@ ZIP_DEFLATED: int ZIP64_LIMIT: int ZIP_FILECOUNT_LIMIT: int ZIP_MAX_COMMENT: int -if sys.version_info >= (3, 3): - ZIP_BZIP2: int - ZIP_LZMA: int diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index 0d1a330942d4..cf348c6554b1 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -3,28 +3,16 @@ import sys from types import CodeType, ModuleType from typing import Any, List, Optional, Tuple, Union -if sys.version_info >= (3, 7): - from importlib.abc import ResourceReader - class ZipImportError(ImportError): ... class zipimporter(object): archive: str prefix: str - if sys.version_info >= (3, 6): - def __init__(self, path: Union[str, bytes, os.PathLike[Any]]) -> None: ... - else: - def __init__(self, path: Union[str, bytes]) -> None: ... - if sys.version_info >= (3,): - def find_loader( - self, fullname: str, path: Optional[str] = ... - ) -> Tuple[Optional[zipimporter], List[str]]: ... # undocumented + def __init__(self, path: Union[str, bytes]) -> None: ... def find_module(self, fullname: str, path: Optional[str] = ...) -> Optional[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) -> Optional[ResourceReader]: ... # undocumented def get_source(self, fullname: str) -> Optional[str]: ... def is_package(self, fullname: str) -> bool: ... def load_module(self, fullname: str) -> ModuleType: ... diff --git a/stdlib/@python2/zlib.pyi b/stdlib/@python2/zlib.pyi index 81a9f87ce42e..2eaa418909ec 100644 --- a/stdlib/@python2/zlib.pyi +++ b/stdlib/@python2/zlib.pyi @@ -18,10 +18,6 @@ Z_HUFFMAN_ONLY: int Z_NO_FLUSH: int Z_RLE: int Z_SYNC_FLUSH: int -if sys.version_info >= (3,): - DEF_BUF_SIZE: int - ZLIB_RUNTIME_VERSION: str - class error(Exception): ... class _Compress: @@ -32,8 +28,6 @@ class _Compress: class _Decompress: unused_data: bytes unconsumed_tail: bytes - if sys.version_info >= (3,): - eof: bool def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... def flush(self, length: int = ...) -> bytes: ... def copy(self) -> _Decompress: ... @@ -41,26 +35,11 @@ class _Decompress: def adler32(__data: bytes, __value: int = ...) -> int: ... def compress(__data: bytes, level: int = ...) -> bytes: ... -if sys.version_info >= (3,): - def compressobj( - level: int = ..., - method: int = ..., - wbits: int = ..., - memLevel: int = ..., - strategy: int = ..., - zdict: Optional[bytes] = ..., - ) -> _Compress: ... - -else: - def compressobj( - level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ... - ) -> _Compress: ... +def compressobj( + level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ... +) -> _Compress: ... def crc32(__data: Union[array[Any], bytes], __value: int = ...) -> int: ... def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... -if sys.version_info >= (3,): - def decompressobj(wbits: int = ..., zdict: bytes = ...) -> _Decompress: ... - -else: - def decompressobj(wbits: int = ...) -> _Decompress: ... +def decompressobj(wbits: int = ...) -> _Decompress: ... From 9d66dc8dd1bf66b97294825a721c9e8eca496efb Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 15 May 2021 00:28:26 +0300 Subject: [PATCH 4/6] manual touch --- stdlib/@python2/select.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index 5c88d27bf66a..ba19f7ef67ee 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -124,4 +124,3 @@ if sys.platform == "linux": EPOLLWRNORM: int EPOLL_RDHUP: int -if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win32": From b113ce29ed77f393e39aaddb123881d2f1529f61 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 15 May 2021 00:29:00 +0300 Subject: [PATCH 5/6] black --- stdlib/@python2/_codecs.pyi | 4 ---- stdlib/@python2/_csv.pyi | 1 - stdlib/@python2/_curses.pyi | 4 ---- stdlib/@python2/_dummy_threading.pyi | 5 ----- stdlib/@python2/_heapq.pyi | 1 - stdlib/@python2/_thread.pyi | 1 - stdlib/@python2/_typeshed/tkinter.pyi | 1 - stdlib/@python2/_weakref.pyi | 1 + stdlib/@python2/aifc.pyi | 1 - stdlib/@python2/antigravity.pyi | 1 - stdlib/@python2/argparse.pyi | 2 +- stdlib/@python2/base64.pyi | 2 -- stdlib/@python2/binascii.pyi | 6 ------ stdlib/@python2/cProfile.pyi | 1 + stdlib/@python2/calendar.pyi | 2 ++ stdlib/@python2/cmath.pyi | 2 -- stdlib/@python2/code.pyi | 1 - stdlib/@python2/contextlib.pyi | 3 +-- stdlib/@python2/csv.pyi | 1 + stdlib/@python2/ctypes/__init__.pyi | 10 ++-------- stdlib/@python2/datetime.pyi | 3 --- stdlib/@python2/difflib.pyi | 2 +- stdlib/@python2/dis.pyi | 3 +-- stdlib/@python2/ensurepip/__init__.pyi | 1 - stdlib/@python2/fileinput.pyi | 2 -- stdlib/@python2/ftplib.pyi | 3 ++- stdlib/@python2/genericpath.pyi | 1 - stdlib/@python2/hmac.pyi | 1 - stdlib/@python2/imaplib.pyi | 4 +--- stdlib/@python2/keyword.pyi | 1 - stdlib/@python2/linecache.pyi | 1 - stdlib/@python2/locale.pyi | 3 --- stdlib/@python2/macpath.pyi | 2 -- stdlib/@python2/mailbox.pyi | 2 ++ stdlib/@python2/math.pyi | 15 +-------------- stdlib/@python2/mimetypes.pyi | 1 - stdlib/@python2/mmap.pyi | 1 - stdlib/@python2/modulefinder.pyi | 1 - stdlib/@python2/opcode.pyi | 1 - stdlib/@python2/operator.pyi | 17 ----------------- stdlib/@python2/optparse.pyi | 1 - stdlib/@python2/os/__init__.pyi | 2 -- stdlib/@python2/pdb.pyi | 3 --- stdlib/@python2/pickle.pyi | 1 + stdlib/@python2/pickletools.pyi | 2 +- stdlib/@python2/pkgutil.pyi | 1 - stdlib/@python2/plistlib.pyi | 1 - stdlib/@python2/poplib.pyi | 2 +- stdlib/@python2/pprint.pyi | 2 -- stdlib/@python2/pty.pyi | 1 - stdlib/@python2/py_compile.pyi | 1 - stdlib/@python2/pyclbr.pyi | 2 -- stdlib/@python2/pydoc.pyi | 5 +---- stdlib/@python2/queue.pyi | 2 +- stdlib/@python2/readline.pyi | 2 -- stdlib/@python2/select.pyi | 1 - stdlib/@python2/shutil.pyi | 15 ++------------- stdlib/@python2/smtpd.pyi | 3 +-- stdlib/@python2/socket.pyi | 5 ----- stdlib/@python2/sqlite3/dbapi2.pyi | 2 -- stdlib/@python2/sre_compile.pyi | 1 + stdlib/@python2/ssl.pyi | 4 ++-- stdlib/@python2/struct.pyi | 1 - stdlib/@python2/tarfile.pyi | 1 - stdlib/@python2/threading.pyi | 5 ----- stdlib/@python2/time.pyi | 3 --- stdlib/@python2/timeit.pyi | 5 ++--- stdlib/@python2/token.pyi | 1 + stdlib/@python2/traceback.pyi | 15 +-------------- stdlib/@python2/turtle.pyi | 3 ++- stdlib/@python2/typing_extensions.pyi | 3 +++ stdlib/@python2/unicodedata.pyi | 1 - stdlib/@python2/uu.pyi | 1 - stdlib/@python2/weakref.pyi | 1 - stdlib/@python2/webbrowser.pyi | 1 - stdlib/@python2/xml/etree/ElementTree.pyi | 4 ---- stdlib/@python2/xml/sax/__init__.pyi | 1 - stdlib/@python2/zlib.pyi | 8 ++------ 78 files changed, 39 insertions(+), 189 deletions(-) diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index 27fad0fdcef7..70f7da857f5a 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -24,9 +24,7 @@ def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> 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: Optional[_MapT] = ...) -> Tuple[Text, int]: ... def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ... @@ -38,10 +36,8 @@ def raw_unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tup 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]: ... diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index 9544ba91958c..393274f02851 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_csv.pyi @@ -28,7 +28,6 @@ class _reader(Iterator[List[str]]): class _writer: dialect: Dialect - def writerow(self, row: Sequence[Any]) -> Any: ... def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... diff --git a/stdlib/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index e5591d596104..2be7c690cd93 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -268,7 +268,6 @@ 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: ... @@ -342,10 +341,8 @@ def tparm( ) -> 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: ... @@ -513,4 +510,3 @@ class _CursesWindow: def vline(self, ch: _chtype, n: int) -> None: ... @overload def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... - diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index f8e1fc46b10a..6197b6459ac0 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -11,14 +11,10 @@ _T = TypeVar("_T") __all__: List[str] 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: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... @@ -112,4 +108,3 @@ class Timer(Thread): self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... ) -> None: ... def cancel(self) -> None: ... - diff --git a/stdlib/@python2/_heapq.pyi b/stdlib/@python2/_heapq.pyi index 2928f39c2c17..f111431142d5 100644 --- a/stdlib/@python2/_heapq.pyi +++ b/stdlib/@python2/_heapq.pyi @@ -8,6 +8,5 @@ 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: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... diff --git a/stdlib/@python2/_thread.pyi b/stdlib/@python2/_thread.pyi index 6cf7f5f59206..7c7c800b4d19 100644 --- a/stdlib/@python2/_thread.pyi +++ b/stdlib/@python2/_thread.pyi @@ -26,4 +26,3 @@ def get_ident() -> int: ... def stack_size(size: int = ...) -> int: ... TIMEOUT_MAX: float - diff --git a/stdlib/@python2/_typeshed/tkinter.pyi b/stdlib/@python2/_typeshed/tkinter.pyi index a4b00506a0e3..835105283b81 100644 --- a/stdlib/@python2/_typeshed/tkinter.pyi +++ b/stdlib/@python2/_typeshed/tkinter.pyi @@ -1,3 +1,2 @@ import sys from typing import Optional, Protocol - diff --git a/stdlib/@python2/_weakref.pyi b/stdlib/@python2/_weakref.pyi index 3c395dc7206e..fae196c721da 100644 --- a/stdlib/@python2/_weakref.pyi +++ b/stdlib/@python2/_weakref.pyi @@ -14,6 +14,7 @@ class ReferenceType(Generic[_T]): def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ... def __call__(self) -> Optional[_T]: ... def __hash__(self) -> int: ... + ref = ReferenceType def getweakrefcount(__object: Any) -> int: ... diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index 68c4286cc150..b7fc6bdac23f 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -68,7 +68,6 @@ def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ... def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... @overload def open(f: _File, mode: Optional[str] = ...) -> Any: ... - @overload def openfp(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ... @overload diff --git a/stdlib/@python2/antigravity.pyi b/stdlib/@python2/antigravity.pyi index 44bd5c72b94b..de101117c2d1 100644 --- a/stdlib/@python2/antigravity.pyi +++ b/stdlib/@python2/antigravity.pyi @@ -1,2 +1 @@ import sys - diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 5b0c2546ada0..064549c2e8f1 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -110,7 +110,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): _positionals: _ArgumentGroup _optionals: _ArgumentGroup _subparsers: Optional[_ArgumentGroup] - def __init__( self, prog: Optional[Text] = ..., @@ -258,6 +257,7 @@ class Action(_AttributeHolder): values: Union[Text, Sequence[Any], None], option_string: Optional[Text] = ..., ) -> None: ... + class Namespace(_AttributeHolder): def __init__(self, **kwargs: Any) -> None: ... def __getattr__(self, name: Text) -> Any: ... diff --git a/stdlib/@python2/base64.pyi b/stdlib/@python2/base64.pyi index 999b2713a456..ca7d1aee541c 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -14,9 +14,7 @@ def b32encode(s: _encodable) -> bytes: ... def b32decode(s: _decodable, casefold: bool = ..., map01: Optional[bytes] = ...) -> 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/stdlib/@python2/binascii.pyi b/stdlib/@python2/binascii.pyi index 69233a05a8fc..c068567f75af 100644 --- a/stdlib/@python2/binascii.pyi +++ b/stdlib/@python2/binascii.pyi @@ -6,13 +6,9 @@ _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: ... @@ -22,9 +18,7 @@ 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: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index cc26f9836cc1..3d23acf73d81 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -26,4 +26,5 @@ class Profile: def run(self: _SelfT, cmd: str) -> _SelfT: ... def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... + def label(code: Union[str, CodeType]) -> _Label: ... # undocumented diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index 752bd9a591cd..e10045ad4b5e 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -33,6 +33,7 @@ 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]]: ... + class TextCalendar(Calendar): def prweek(self, theweek: int, width: int) -> None: ... def formatday(self, day: int, weekday: int, width: int) -> str: ... @@ -64,6 +65,7 @@ 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: Optional[str] = ..., encoding: Optional[str] = ...) -> str: ... + class TimeEncoding: def __init__(self, locale: _LocaleType) -> None: ... def __enter__(self) -> _LocaleType: ... diff --git a/stdlib/@python2/cmath.pyi b/stdlib/@python2/cmath.pyi index 3c38ab9d04db..86f8d012fe4a 100644 --- a/stdlib/@python2/cmath.pyi +++ b/stdlib/@python2/cmath.pyi @@ -14,7 +14,6 @@ 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: ... @@ -27,4 +26,3 @@ def sinh(__z: _C) -> complex: ... def sqrt(__z: _C) -> complex: ... def tan(__z: _C) -> complex: ... def tanh(__z: _C) -> complex: ... - diff --git a/stdlib/@python2/code.pyi b/stdlib/@python2/code.pyi index aee7f518d655..b6ee3129bd23 100644 --- a/stdlib/@python2/code.pyi +++ b/stdlib/@python2/code.pyi @@ -20,5 +20,4 @@ class InteractiveConsole(InteractiveInterpreter): def interact( banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... ) -> None: ... - def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index c38d3eadb4d7..3afc41adb9a3 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -13,8 +13,8 @@ _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) class GeneratorContextManager(ContextManager[_T_co]): def __call__(self, func: _F) -> _F: ... -def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... class _SupportsClose(Protocol): @@ -24,4 +24,3 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) class closing(ContextManager[_SupportsCloseT]): def __init__(self, thing: _SupportsCloseT) -> None: ... - diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index 11d78de1fc9c..fae33f84fdea 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -20,6 +20,7 @@ from _csv import ( from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, TypeVar, overload from typing import Dict as _DictReadMapping + _T = TypeVar("_T") class excel(Dialect): diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 64c447d893f6..4adaa3975a82 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -34,12 +34,7 @@ class CDLL(object): _handle: int = ... _FuncPtr: Type[_FuncPointer] = ... def __init__( - self, - name: Optional[str], - mode: int = ..., - handle: Optional[int] = ..., - use_errno: bool = ..., - use_last_error: bool = ..., + self, name: Optional[str], mode: int = ..., handle: Optional[int] = ..., use_errno: bool = ..., use_last_error: bool = ... ) -> None: ... def __getattr__(self, name: str) -> _NamedFuncPointer: ... def __getitem__(self, name: str) -> _NamedFuncPointer: ... @@ -55,6 +50,7 @@ class LibraryLoader(Generic[_DLLT]): 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] = ... @@ -183,9 +179,7 @@ class pointer(Generic[_CT], _PointerLike, _CData): 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": diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index 18bd6a5dc917..0af202a55783 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -60,7 +60,6 @@ class time: min: ClassVar[time] max: ClassVar[time] resolution: ClassVar[timedelta] - def __init__( self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ... ) -> None: ... @@ -96,7 +95,6 @@ class timedelta(SupportsAbs[timedelta]): min: ClassVar[timedelta] max: ClassVar[timedelta] resolution: ClassVar[timedelta] - def __init__( self, days: float = ..., @@ -141,7 +139,6 @@ class datetime(date): min: ClassVar[datetime] max: ClassVar[datetime] resolution: ClassVar[timedelta] - def __new__( cls: Type[_S], year: int, diff --git a/stdlib/@python2/difflib.pyi b/stdlib/@python2/difflib.pyi index d615f3c873da..188f39baec7d 100644 --- a/stdlib/@python2/difflib.pyi +++ b/stdlib/@python2/difflib.pyi @@ -43,6 +43,7 @@ class SequenceMatcher(Generic[_T]): 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( # type: ignore @@ -111,4 +112,3 @@ class HtmlDiff(object): ) -> _StrType: ... def restore(delta: Iterable[_StrType], which: int) -> Iterator[_StrType]: ... - diff --git a/stdlib/@python2/dis.pyi b/stdlib/@python2/dis.pyi index 63edc4b85def..4f1dd94cbd05 100644 --- a/stdlib/@python2/dis.pyi +++ b/stdlib/@python2/dis.pyi @@ -25,11 +25,10 @@ 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: ... + if sys.version_info >= (3, 0): def show_code(co: _have_code) -> None: ... diff --git a/stdlib/@python2/ensurepip/__init__.pyi b/stdlib/@python2/ensurepip/__init__.pyi index 83fd43ff002e..fb9daae2d09a 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -2,7 +2,6 @@ import sys from typing import Optional def version() -> str: ... - def bootstrap( root: Optional[str] = ..., upgrade: bool = ..., diff --git a/stdlib/@python2/fileinput.pyi b/stdlib/@python2/fileinput.pyi index bd6050523553..44ca18b53d27 100644 --- a/stdlib/@python2/fileinput.pyi +++ b/stdlib/@python2/fileinput.pyi @@ -10,7 +10,6 @@ def input( mode: str = ..., openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., ) -> FileInput[AnyStr]: ... - def close() -> None: ... def nextfile() -> None: ... def filename() -> str: ... @@ -45,5 +44,4 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): def isstdin(self) -> bool: ... def hook_compressed(filename: AnyPath, mode: str) -> IO[Any]: ... - def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... diff --git a/stdlib/@python2/ftplib.pyi b/stdlib/@python2/ftplib.pyi index 7658630f2b58..070ad50881e8 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -13,6 +13,7 @@ MSG_OOB: int FTP_PORT: int MAXLINE: int CRLF: str + class Error(Exception): ... class error_reply(Error): ... class error_temp(Error): ... @@ -38,7 +39,6 @@ class FTP: lastresp: str file: Optional[BinaryIO] - def __init__( self, host: Text = ..., user: Text = ..., passwd: Text = ..., acct: Text = ..., timeout: float = ... ) -> None: ... @@ -113,6 +113,7 @@ class FTP_TLS(FTP): def auth(self) -> str: ... def prot_p(self) -> str: ... def prot_c(self) -> str: ... + class Netrc: def __init__(self, filename: Optional[Text] = ...) -> None: ... def get_hosts(self) -> List[str]: ... diff --git a/stdlib/@python2/genericpath.pyi b/stdlib/@python2/genericpath.pyi index 04b9884998e4..b1815ac56d94 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -25,4 +25,3 @@ def isdir(s: AnyPath) -> bool: ... def getatime(filename: AnyPath) -> float: ... def getmtime(filename: AnyPath) -> float: ... def getctime(filename: AnyPath) -> float: ... - diff --git a/stdlib/@python2/hmac.pyi b/stdlib/@python2/hmac.pyi index db12da93f9dc..dea498f70a78 100644 --- a/stdlib/@python2/hmac.pyi +++ b/stdlib/@python2/hmac.pyi @@ -22,4 +22,3 @@ class HMAC: def compare_digest(__a: ReadableBuffer, __b: ReadableBuffer) -> bool: ... @overload def compare_digest(__a: AnyStr, __b: AnyStr) -> bool: ... - diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index 2ce3edaf78ff..0c25ab563d50 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -89,9 +89,7 @@ class IMAP4: class IMAP4_SSL(IMAP4): keyfile: str = ... certfile: str = ... - def __init__( - self, host: str = ..., port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ... - ) -> None: ... + def __init__(self, host: str = ..., port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ...) -> None: ... host: str = ... port: int = ... sock: _socket = ... diff --git a/stdlib/@python2/keyword.pyi b/stdlib/@python2/keyword.pyi index fb113141222e..34d408141acf 100644 --- a/stdlib/@python2/keyword.pyi +++ b/stdlib/@python2/keyword.pyi @@ -4,4 +4,3 @@ from typing import Sequence, Text def iskeyword(s: Text) -> bool: ... kwlist: Sequence[str] - diff --git a/stdlib/@python2/linecache.pyi b/stdlib/@python2/linecache.pyi index 62c94d4b9770..0d455a1df521 100644 --- a/stdlib/@python2/linecache.pyi +++ b/stdlib/@python2/linecache.pyi @@ -8,4 +8,3 @@ def clearcache() -> None: ... def getlines(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... def checkcache(filename: Optional[Text] = ...) -> None: ... def updatecache(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... - diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 1d1ec020e707..4dadf744217a 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -87,11 +87,8 @@ def resetlocale(category: int = ...) -> None: ... def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... def format(percent: _str, value: Union[float, Decimal], grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... - def format_string(f: _str, val: Any, grouping: bool = ...) -> _str: ... - def currency(val: Union[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: ... diff --git a/stdlib/@python2/macpath.pyi b/stdlib/@python2/macpath.pyi index 3604ed501a68..259f22d72655 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -38,7 +38,6 @@ def dirname(s: AnyStr) -> AnyStr: ... def normcase(path: AnyStr) -> AnyStr: ... def normpath(s: AnyStr) -> AnyStr: ... def realpath(path: AnyStr) -> AnyStr: ... - def islink(s: AnyPath) -> bool: ... # Make sure signatures are disjunct, and allow combinations of bytes and unicode. @@ -55,5 +54,4 @@ def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... @overload def join(__p1: Text, *p: AnyPath) -> Text: ... - def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index 3bef884d0d5e..95f0697177c0 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -77,6 +77,7 @@ class Mailbox(Generic[_MessageT]): def lock(self) -> None: ... def unlock(self) -> None: ... def close(self) -> None: ... + class Maildir(Mailbox[MaildirMessage]): colon: str @@ -184,6 +185,7 @@ class _ProxyFile(Generic[AnyStr]): def flush(self) -> None: ... @property def closed(self) -> bool: ... + class _PartialFile(_ProxyFile[AnyStr]): def __init__(self, f: IO[AnyStr], start: Optional[int] = ..., stop: Optional[int] = ...) -> None: ... diff --git a/stdlib/@python2/math.pyi b/stdlib/@python2/math.pyi index e7234d4d5569..7b32d183c1ce 100644 --- a/stdlib/@python2/math.pyi +++ b/stdlib/@python2/math.pyi @@ -3,6 +3,7 @@ from typing import Iterable, Optional, SupportsFloat, SupportsInt, Tuple, overlo e: float pi: float + def acos(__x: SupportsFloat) -> float: ... def acosh(__x: SupportsFloat) -> float: ... def asin(__x: SupportsFloat) -> float: ... @@ -10,50 +11,36 @@ 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/stdlib/@python2/mimetypes.pyi b/stdlib/@python2/mimetypes.pyi index f4c7b6132d2f..4bc9919b2c21 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -2,7 +2,6 @@ import sys from typing import IO, Dict, List, Optional, Sequence, Text, Tuple, Union def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... - def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> Optional[str]: ... def init(files: Optional[Sequence[str]] = ...) -> None: ... diff --git a/stdlib/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index 485ddcdc2545..eeaaae1bbed3 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -54,4 +54,3 @@ class mmap(_mmap[bytes], Sequence[bytes]): def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... def __delitem__(self, index: Union[int, slice]) -> None: ... def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... - diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index b8884b8b62bf..989c04acbe9d 100644 --- a/stdlib/@python2/modulefinder.pyi +++ b/stdlib/@python2/modulefinder.pyi @@ -30,7 +30,6 @@ class ModuleFinder: indent: int # undocumented excludes: Container[str] # undocumented replace_paths: Sequence[Tuple[str, str]] # undocumented - def __init__( self, path: Optional[List[str]] = ..., diff --git a/stdlib/@python2/opcode.pyi b/stdlib/@python2/opcode.pyi index 6cf9835514dc..9cf646e53458 100644 --- a/stdlib/@python2/opcode.pyi +++ b/stdlib/@python2/opcode.pyi @@ -14,4 +14,3 @@ opname: List[str] opmap: Dict[str, int] HAVE_ARGUMENT: int EXTENDED_ARG: int - diff --git a/stdlib/@python2/operator.pyi b/stdlib/@python2/operator.pyi index 0bbf22c9a2c8..3edc111818a1 100644 --- a/stdlib/@python2/operator.pyi +++ b/stdlib/@python2/operator.pyi @@ -41,10 +41,8 @@ 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: ... @@ -59,7 +57,6 @@ 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: ... @@ -93,10 +90,8 @@ def __delitem__(a: MutableSequence[Any], b: int) -> None: ... 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 @@ -109,17 +104,12 @@ def __getitem__(a: Sequence[_T], b: int) -> _T: ... 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 @@ -132,7 +122,6 @@ def __setitem__(a: MutableSequence[_T], b: int, c: _T) -> None: ... 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: ... @@ -172,10 +161,8 @@ 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: ... @@ -184,15 +171,12 @@ 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: ... @@ -201,7 +185,6 @@ 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: ... diff --git a/stdlib/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index 6726d827aa4d..dddb648c4d98 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -10,7 +10,6 @@ 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): diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 3be2b0a24da1..0fe13c920cab 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -262,7 +262,6 @@ if sys.platform != "win32": def walk( top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., 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. @@ -296,7 +295,6 @@ 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: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, path: AnyPath, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig def spawnv(mode: int, path: AnyPath, args: List[Union[bytes, Text]]) -> int: ... diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index 87393734040e..070ca44c40a8 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -16,9 +16,7 @@ def run(statement: str, globals: Optional[Dict[str, Any]] = ..., locals: Optiona def runeval(expression: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> Any: ... def runctx(statement: str, globals: Dict[str, Any], locals: Mapping[str, Any]) -> None: ... def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... - def set_trace() -> None: ... - def post_mortem(t: Optional[TracebackType] = ...) -> None: ... def pm() -> None: ... @@ -41,7 +39,6 @@ class Pdb(Bdb, Cmd): curindex: int curframe: Optional[FrameType] curframe_locals: Mapping[str, Any] - def __init__( self, completekey: str = ..., diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index a511b702bb9b..4fa3698af099 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -32,6 +32,7 @@ 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 diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index 4ad75fb8bbbf..ad0606dfce65 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -6,6 +6,7 @@ _Reader = Callable[[IO[bytes]], Any] UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int TAKEN_FROM_ARGUMENT4: int + class ArgumentDescriptor(object): name: str n: int @@ -119,7 +120,6 @@ opcodes: List[OpcodeInfo] def genops(pickle: Union[bytes, IO[bytes]]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... def optimize(p: Union[bytes, IO[bytes]]) -> bytes: ... - def dis( pickle: Union[bytes, IO[bytes]], out: Optional[IO[str]] = ..., diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index a068d421f5f5..dc365ccb7432 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -26,4 +26,3 @@ def walk_packages( path: Optional[Iterable[str]] = ..., prefix: str = ..., onerror: Optional[Callable[[str], None]] = ... ) -> Iterator[_ModuleInfoLike]: ... def get_data(package: str, resource: str) -> Optional[bytes]: ... - diff --git a/stdlib/@python2/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 9266067019a6..bf1af0b38574 100644 --- a/stdlib/@python2/plistlib.pyi +++ b/stdlib/@python2/plistlib.pyi @@ -7,7 +7,6 @@ def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... def writePlist(value: Mapping[str, Any], pathOrFile: Union[_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: ... diff --git a/stdlib/@python2/poplib.pyi b/stdlib/@python2/poplib.pyi index 0e400db66bc2..ab499da68042 100644 --- a/stdlib/@python2/poplib.pyi +++ b/stdlib/@python2/poplib.pyi @@ -34,13 +34,13 @@ class POP3: 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: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index 28abac6e83c7..c335b14f1d3c 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -2,11 +2,9 @@ import sys from typing import IO, Any, Dict, Optional, Tuple def pformat(object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ...) -> str: ... - def pprint( object: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., depth: Optional[int] = ... ) -> None: ... - def isreadable(object: object) -> bool: ... def isrecursive(object: object) -> bool: ... def saferepr(object: object) -> str: ... diff --git a/stdlib/@python2/pty.pyi b/stdlib/@python2/pty.pyi index 81012ac4dce7..fb9a7772c544 100644 --- a/stdlib/@python2/pty.pyi +++ b/stdlib/@python2/pty.pyi @@ -13,5 +13,4 @@ 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: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index b6dfc0639350..e648909fb811 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -13,5 +13,4 @@ class PyCompileError(Exception): def compile( file: _EitherStr, cfile: Optional[_EitherStr] = ..., dfile: Optional[_EitherStr] = ..., doraise: bool = ... ) -> None: ... - def main(args: Optional[List[Text]] = ...) -> int: ... diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 8dd739ef0ce6..164f934d08d3 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -8,7 +8,6 @@ class Class: methods: Dict[str, int] file: int lineno: int - def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... class Function: @@ -16,7 +15,6 @@ class Function: name: str file: int lineno: int - def __init__(self, module: str, name: str, file: str, lineno: int) -> None: ... def readmodule(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Class]: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 52f8c92cc517..f2ef8c4e77a3 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -262,8 +262,5 @@ class ModuleScanner: def apropos(key: str) -> None: ... def ispath(x: Any) -> bool: ... def cli() -> None: ... - -def serve( - port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ... -) -> None: ... +def serve(port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ...) -> None: ... def gui() -> None: ... diff --git a/stdlib/@python2/queue.pyi b/stdlib/@python2/queue.pyi index f3d215676758..1a93635f9dc4 100644 --- a/stdlib/@python2/queue.pyi +++ b/stdlib/@python2/queue.pyi @@ -30,6 +30,6 @@ class Queue(Generic[_T]): def qsize(self) -> int: ... def _qsize(self) -> int: ... def task_done(self) -> None: ... + class PriorityQueue(Queue[_T]): ... class LifoQueue(Queue[_T]): ... - diff --git a/stdlib/@python2/readline.pyi b/stdlib/@python2/readline.pyi index 18bc6ff4418d..2335135c4d30 100644 --- a/stdlib/@python2/readline.pyi +++ b/stdlib/@python2/readline.pyi @@ -12,7 +12,6 @@ def insert_text(__string: str) -> None: ... def redisplay() -> None: ... def read_history_file(__filename: Optional[AnyPath] = ...) -> None: ... def write_history_file(__filename: Optional[AnyPath] = ...) -> None: ... - def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... @@ -21,7 +20,6 @@ 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: Optional[Callable[[], None]] = ...) -> None: ... def set_pre_input_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... def set_completer(__function: _CompleterT = ...) -> None: ... diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index ba19f7ef67ee..ddb3226ccd80 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -123,4 +123,3 @@ if sys.platform == "linux": EPOLLWRBAND: int EPOLLWRNORM: int EPOLL_RDHUP: int - diff --git a/stdlib/@python2/shutil.pyi b/stdlib/@python2/shutil.pyi index 1803f0fe55fe..b4824f48489b 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -27,30 +27,20 @@ class SpecialFileError(EnvironmentError): ... class ExecError(EnvironmentError): ... def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ... - def copyfile(src: StrPath, dst: StrPath) -> None: ... def copymode(src: StrPath, dst: StrPath) -> None: ... def copystat(src: StrPath, dst: StrPath) -> None: ... def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... - def ignore_patterns(*patterns: StrPath) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... - def copytree( - src: AnyStr, - dst: AnyStr, - symlinks: bool = ..., - ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ..., + src: AnyStr, dst: AnyStr, symlinks: bool = ..., ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ... ) -> _PathReturn: ... - -def rmtree( - path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ... -) -> None: ... +def rmtree(path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] def move(src: StrPath, dst: StrPath) -> _PathReturn: ... - def make_archive( base_name: _AnyStr, format: str, @@ -70,4 +60,3 @@ def register_archive_format( description: str = ..., ) -> None: ... def unregister_archive_format(name: str) -> None: ... - diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index bd0093cb98bf..846009faf123 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -9,7 +9,6 @@ _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: ... # base asynchat.async_chat.push() accepts bytes def push(self, msg: Text) -> None: ... # type: ignore @@ -22,12 +21,12 @@ class SMTPChannel(asynchat.async_chat): 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( diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index 8d2722bbb01d..ede9f25b778e 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -526,7 +526,6 @@ 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]: ... @@ -579,7 +578,6 @@ def create_connection( timeout: Optional[float] = ..., source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ..., ) -> socket: ... - def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... if sys.platform == "win32" and sys.version_info >= (3, 3): @@ -594,7 +592,6 @@ def getaddrinfo( 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]]: ... @@ -619,7 +616,5 @@ 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() -> Optional[float]: ... def setdefaulttimeout(timeout: Optional[float]) -> None: ... - diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 9f0bdd1b1bcf..6f76aebef2f6 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -63,7 +63,6 @@ version: str # TODO: adapt needs to get probed def adapt(obj, protocol, alternate): ... def complete_statement(sql: str) -> bool: ... - def connect( database: Union[bytes, Text], timeout: float = ..., @@ -73,7 +72,6 @@ def connect( factory: Optional[Type[Connection]] = ..., 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], Union[int, float, str, bytes]]) -> None: ... diff --git a/stdlib/@python2/sre_compile.pyi b/stdlib/@python2/sre_compile.pyi index 0c48b7c38e18..4afc2f232f8b 100644 --- a/stdlib/@python2/sre_compile.pyi +++ b/stdlib/@python2/sre_compile.pyi @@ -18,5 +18,6 @@ from typing import Any, List, Pattern, Tuple, Type, Union MAXCODE: int STRING_TYPES: Tuple[Type[str], Type[unicode]] _IsStringType = int + def isstring(obj: Any) -> _IsStringType: ... def compile(p: Union[str, bytes, SubPattern], flags: int = ...) -> Pattern[Any]: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 2ad69b546426..58b7ec5755e6 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -23,7 +23,6 @@ class SSLWantReadError(SSLError): ... class SSLWantWriteError(SSLError): ... class SSLSyscallError(SSLError): ... class SSLEOFError(SSLError): ... - class CertificateError(ValueError): ... def wrap_socket( @@ -41,7 +40,6 @@ def wrap_socket( def create_default_context( purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[Text, bytes, None] = ... ) -> SSLContext: ... - def _create_unverified_context( protocol: int = ..., *, @@ -211,6 +209,7 @@ class SSLSocket(socket.socket): def unwrap(self) -> socket.socket: ... def version(self) -> Optional[str]: ... def pending(self) -> int: ... + class SSLContext: check_hostname: bool options: int @@ -245,6 +244,7 @@ class SSLContext: server_hostname: Optional[str] = ..., ) -> 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 diff --git a/stdlib/@python2/struct.pyi b/stdlib/@python2/struct.pyi index f100e6aa0c81..3b3baf7fb94c 100644 --- a/stdlib/@python2/struct.pyi +++ b/stdlib/@python2/struct.pyi @@ -13,7 +13,6 @@ 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: diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index 3eb461578b58..bffe894fb594 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -228,7 +228,6 @@ class TarFile(Iterable[TarInfo]): def close(self) -> None: ... def is_tarfile(name: AnyPath) -> bool: ... - def filemode(mode: int) -> str: ... # undocumented class TarFileCompat: diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index f8e1fc46b10a..6197b6459ac0 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -11,14 +11,10 @@ _T = TypeVar("_T") __all__: List[str] 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: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... @@ -112,4 +108,3 @@ class Timer(Thread): self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ... ) -> None: ... def cancel(self) -> None: ... - diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index 37a088682537..0a5353fca9c6 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -31,9 +31,7 @@ class struct_time(_struct_time): def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ... def asctime(t: Union[_TimeTuple, struct_time] = ...) -> str: ... - def clock() -> float: ... - def ctime(secs: Optional[float] = ...) -> str: ... def gmtime(secs: Optional[float] = ...) -> struct_time: ... def localtime(secs: Optional[float] = ...) -> struct_time: ... @@ -45,4 +43,3 @@ def time() -> float: ... if sys.platform != "win32": def tzset() -> None: ... # Unix only - diff --git a/stdlib/@python2/timeit.pyi b/stdlib/@python2/timeit.pyi index 89ba33e31ae1..da27eefa79a5 100644 --- a/stdlib/@python2/timeit.pyi +++ b/stdlib/@python2/timeit.pyi @@ -12,10 +12,9 @@ class Timer: def print_exc(self, file: Optional[IO[str]] = ...) -> 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]: ... +def repeat(stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., repeat: int = ..., number: int = ...) -> List[float]: ... _timerFunc = Callable[[], float] diff --git a/stdlib/@python2/token.pyi b/stdlib/@python2/token.pyi index 8a469a87c639..54ddc9315db2 100644 --- a/stdlib/@python2/token.pyi +++ b/stdlib/@python2/token.pyi @@ -57,6 +57,7 @@ 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/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 6a8d52cf134c..f571f71129de 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -6,7 +6,6 @@ from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, _PT = Tuple[str, int, str, Optional[str]] def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... - def print_exception( etype: Optional[Type[BaseException]], value: Optional[BaseException], @@ -14,29 +13,17 @@ def print_exception( limit: Optional[int] = ..., file: Optional[IO[str]] = ..., ) -> None: ... - def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... - def print_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... - def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... def format_list(extracted_list: List[_PT]) -> List[str]: ... - def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... - def format_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., + etype: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType], limit: Optional[int] = ... ) -> List[str]: ... - def format_exc(limit: Optional[int] = ...) -> str: ... - def format_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ... def format_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[str]: ... - def tb_lineno(tb: TracebackType) -> int: ... - diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index d2fd7c0708d2..1d37087b6f48 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -29,6 +29,7 @@ class TurtleScreenBase(object): xscale: float = ... yscale: float = ... def __init__(self, cv: Canvas) -> None: ... + class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... @@ -87,6 +88,7 @@ class TurtleScreen(TurtleScreenBase): resetscreen = reset clearscreen = clear addshape = register_shape + class TNavigator(object): START_ORIENTATION: Dict[str, Vec2D] = ... DEFAULT_MODE: str = ... @@ -466,7 +468,6 @@ def shape(name: str) -> None: ... def shapesize() -> Tuple[float, float, float]: ... # type: ignore @overload def shapesize(stretch_wid: Optional[float] = ..., stretch_len: Optional[float] = ..., outline: Optional[float] = ...) -> None: ... - def settiltangle(angle: float) -> None: ... @overload def tiltangle(angle: None = ...) -> float: ... diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index e38bcf372a9e..efa22f5aa990 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -85,9 +85,11 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta): 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__: Optional[Type[Any]] @@ -100,6 +102,7 @@ class ParamSpec: def args(self) -> ParamSpecArgs: ... @property def kwargs(self) -> ParamSpecKwargs: ... + Concatenate: _SpecialForm = ... TypeAlias: _SpecialForm = ... TypeGuard: _SpecialForm = ... diff --git a/stdlib/@python2/unicodedata.pyi b/stdlib/@python2/unicodedata.pyi index f45ee9a66120..6f2c19d609ca 100644 --- a/stdlib/@python2/unicodedata.pyi +++ b/stdlib/@python2/unicodedata.pyi @@ -14,7 +14,6 @@ def decimal(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... def decomposition(__chr: Text) -> Text: ... def digit(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... def east_asian_width(__chr: Text) -> Text: ... - def lookup(__name: Union[Text, bytes]) -> Text: ... def mirrored(__chr: Text) -> int: ... def name(__chr: Text, __default: _T = ...) -> Union[Text, _T]: ... diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index d32bf7a4f273..fc4e3eb2f4db 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -6,5 +6,4 @@ _File = Union[Text, BinaryIO] class Error(Exception): ... def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... - def decode(in_file: _File, out_file: Optional[_File] = ..., mode: Optional[int] = ..., quiet: int = ...) -> None: ... diff --git a/stdlib/@python2/weakref.pyi b/stdlib/@python2/weakref.pyi index a107db5ea323..b1da1d24fa2d 100644 --- a/stdlib/@python2/weakref.pyi +++ b/stdlib/@python2/weakref.pyi @@ -89,4 +89,3 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ... def iterkeyrefs(self) -> Iterator[ref[_KT]]: ... def keyrefs(self) -> List[ref[_KT]]: ... - diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index 1ee0f3c563f2..9e143bb8c88f 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -6,7 +6,6 @@ class Error(Exception): ... def register( name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... ) -> None: ... - def get(using: Optional[Text] = ...) -> BaseBrowser: ... def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... def open_new(url: Text) -> bool: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index 7117caff1033..d93d00ec375f 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -165,17 +165,13 @@ class ElementTree: 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: Optional[str] = ..., method: Optional[str] = ...) -> bytes: ... def tostringlist(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> List[bytes]: ... - def dump(elem: Element) -> None: ... - def parse(source: _file_or_filename, parser: Optional[XMLParser] = ...) -> ElementTree: ... def iterparse( source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ... ) -> Iterator[Tuple[str, Any]]: ... - def XML(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Element: ... def XMLID(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ... diff --git a/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index 086f1c8e4580..9fdd4cfe8667 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -23,7 +23,6 @@ class SAXReaderNotAvailable(SAXNotSupportedException): ... default_parser_list: List[str] def make_parser(parser_list: List[str] = ...) -> XMLReader: ... - def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... def parseString(string: Union[bytes, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/@python2/zlib.pyi b/stdlib/@python2/zlib.pyi index 2eaa418909ec..6451801c3ba0 100644 --- a/stdlib/@python2/zlib.pyi +++ b/stdlib/@python2/zlib.pyi @@ -18,6 +18,7 @@ Z_HUFFMAN_ONLY: int Z_NO_FLUSH: int Z_RLE: int Z_SYNC_FLUSH: int + class error(Exception): ... class _Compress: @@ -34,12 +35,7 @@ class _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 compressobj(level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., strategy: int = ...) -> _Compress: ... def crc32(__data: Union[array[Any], bytes], __value: int = ...) -> int: ... def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... - def decompressobj(wbits: int = ...) -> _Decompress: ... From d7245f90d9c2b5b900b7e99587f85c3acf29d3bf Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 15 May 2021 00:29:14 +0300 Subject: [PATCH 6/6] isort --- stdlib/@python2/csv.pyi | 18 +++++++++++++++--- stdlib/@python2/locale.pyi | 4 ++-- stdlib/@python2/weakref.pyi | 1 - stdlib/@python2/wsgiref/simple_server.pyi | 3 +-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index fae33f84fdea..27a94a059304 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -17,9 +17,21 @@ from _csv import ( unregister_dialect as unregister_dialect, writer as writer, ) -from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, TypeVar, overload - -from typing import Dict as _DictReadMapping +from typing import ( + Any, + Dict as _DictReadMapping, + Generic, + Iterable, + Iterator, + List, + Mapping, + Optional, + Sequence, + Text, + Type, + TypeVar, + overload, +) _T = TypeVar("_T") diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 4dadf744217a..ecf161154714 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -1,9 +1,9 @@ import sys -from decimal import Decimal -from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union # workaround for mypy#2010 from __builtin__ import str as _str +from decimal import Decimal +from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union CODESET: int D_T_FMT: int diff --git a/stdlib/@python2/weakref.pyi b/stdlib/@python2/weakref.pyi index b1da1d24fa2d..0fa2791ec5cd 100644 --- a/stdlib/@python2/weakref.pyi +++ b/stdlib/@python2/weakref.pyi @@ -28,7 +28,6 @@ from _weakref import ( proxy as proxy, ref as ref, ) - from exceptions import ReferenceError as ReferenceError _S = TypeVar("_S") diff --git a/stdlib/@python2/wsgiref/simple_server.pyi b/stdlib/@python2/wsgiref/simple_server.pyi index c10ac27beaeb..9cfe0e85bef6 100644 --- a/stdlib/@python2/wsgiref/simple_server.pyi +++ b/stdlib/@python2/wsgiref/simple_server.pyi @@ -1,11 +1,10 @@ import sys +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer from typing import List, Optional, Type, TypeVar, overload from .handlers import SimpleHandler from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment -from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer - server_version: str # undocumented sys_version: str # undocumented software_version: str # undocumented