Split stdlib into Python 2 and 3 versions (#5442)

All new files in stdlib/@python2 are straight copies of the
corresponding files in stdlib.
This commit is contained in:
Sebastian Rittau
2021-05-14 21:04:12 +02:00
committed by GitHub
parent 8971c242cb
commit 5b739e0ccb
218 changed files with 18067 additions and 15 deletions

View File

@@ -44,23 +44,13 @@ To automatically check your code before committing, copy the file
### Standard library stubs
The `stdlib` directory contains stubs for modules in the
Python standard library — which
Python 3 standard library — which
includes pure Python modules, dynamically loaded extension modules,
hard-linked extension modules, and the builtins. The `VERSIONS` file lists
the versions of Python where the module is available.
The `stdlib/@python2` subdirectory contains Python 2-only stubs,
both for modules that must be kept different for Python 2 and 3, like
`builtins.pyi`, and for modules that only existed in Python 2, like
`ConfigParser.pyi`. The latter group of modules are not listed in
`VERSIONS`.
Note that if a package is present in `@python2`, any stub in the main
`stdlib` directory should be ignored when looking for Python 2 stubs. For
example, typeshed contains files `stdlib/@python2/collections.pyi` and
`stdlib/collections/abc.pyi`. A client looking for stubs for
`collections.abc` in Python 2 should not pick up the latter file, but
instead report that the module does not exist.
Stubs for Python 2 are available in the `stdlib/@python2` subdirectory.
Modules that are only available for Python 2 are not listed in `VERSIONS`.
### Third-party library stubs
@@ -72,8 +62,8 @@ contains the following:
to `True`, Python 2 defaults to `False`), and dependency on other type stub
packages.
* Stubs (i.e. `*.pyi` files) for packages and modules that are shipped in the
source distribution. Similar to standard library, if the Python 2 version of
the stubs must be kept *separate*, it can be put in a `@python` subdirectory.
source distribution. If the Python 2 version of the stubs must be kept
*separate*, they can be put in a `@python2` subdirectory.
* (Rarely) some docs specific to a given type stub package in `README` file.
When a third party stub is

View File

@@ -0,0 +1,26 @@
import sys
from typing import List
class _Feature:
def __init__(self, optionalRelease: sys._version_info, mandatoryRelease: sys._version_info, compiler_flag: int) -> None: ...
def getOptionalRelease(self) -> sys._version_info: ...
def getMandatoryRelease(self) -> sys._version_info: ...
compiler_flag: int
absolute_import: _Feature
division: _Feature
generators: _Feature
nested_scopes: _Feature
print_function: _Feature
unicode_literals: _Feature
with_statement: _Feature
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

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ...

View File

@@ -0,0 +1,35 @@
import sys
from _typeshed import SupportsLessThan
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: ...

View File

@@ -0,0 +1,82 @@
import codecs
import sys
from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
# For convenience:
_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]
# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap(object):
def size(self) -> int: ...
_MapT = Union[Dict[int, int], _EncodingMap]
def register(__search_function: Callable[[str], Any]) -> None: ...
def register_error(__errors: Union[str, Text], __handler: _Handler) -> None: ...
def lookup(__encoding: Union[str, Text]) -> codecs.CodecInfo: ...
def lookup_error(__name: Union[str, Text]) -> _Handler: ...
def decode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ...
def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ...
def charmap_build(__map: Text) -> _MapT: ...
def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
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]: ...
def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def latin_1_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
def latin_1_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def raw_unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
def raw_unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ...
def unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
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]: ...
def utf_16_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def utf_16_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
def utf_16_ex_decode(
__data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ...
) -> Tuple[Text, int, int]: ...
def utf_16_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def utf_16_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_32_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def utf_32_be_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_32_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def utf_32_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ...
def utf_32_ex_decode(
__data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ...
) -> Tuple[Text, int, int]: ...
def utf_32_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def utf_32_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_7_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def utf_7_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_8_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
if sys.platform == "win32":
def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
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]: ...

51
stdlib/@python2/_csv.pyi Normal file
View File

@@ -0,0 +1,51 @@
import sys
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Sequence, Text, Type, Union
QUOTE_ALL: int
QUOTE_MINIMAL: int
QUOTE_NONE: int
QUOTE_NONNUMERIC: int
class Error(Exception): ...
class Dialect:
delimiter: str
quotechar: Optional[str]
escapechar: Optional[str]
doublequote: bool
skipinitialspace: bool
lineterminator: str
quoting: int
strict: int
def __init__(self) -> None: ...
_DialectLike = Union[str, Dialect, Type[Dialect]]
class _reader(Iterator[List[str]]):
dialect: Dialect
line_num: int
if sys.version_info >= (3, 0):
def __next__(self) -> List[str]: ...
else:
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: ...
class _Writer(Protocol):
def write(self, s: str) -> Any: ...
def writer(csvfile: _Writer, dialect: _DialectLike = ..., **fmtparams: Any) -> _writer: ...
def reader(csvfile: Iterable[Text], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ...
def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ...
def unregister_dialect(name: str) -> None: ...
def get_dialect(name: str) -> Dialect: ...
def list_dialects() -> List[str]: ...
def field_size_limit(new_limit: int = ...) -> int: ...

542
stdlib/@python2/_curses.pyi Normal file
View File

@@ -0,0 +1,542 @@
import sys
from typing import IO, Any, BinaryIO, NamedTuple, Optional, Tuple, Union, overload
_chtype = Union[str, bytes, int]
# ACS codes are only initialized after initscr is called
ACS_BBSS: int
ACS_BLOCK: int
ACS_BOARD: int
ACS_BSBS: int
ACS_BSSB: int
ACS_BSSS: int
ACS_BTEE: int
ACS_BULLET: int
ACS_CKBOARD: int
ACS_DARROW: int
ACS_DEGREE: int
ACS_DIAMOND: int
ACS_GEQUAL: int
ACS_HLINE: int
ACS_LANTERN: int
ACS_LARROW: int
ACS_LEQUAL: int
ACS_LLCORNER: int
ACS_LRCORNER: int
ACS_LTEE: int
ACS_NEQUAL: int
ACS_PI: int
ACS_PLMINUS: int
ACS_PLUS: int
ACS_RARROW: int
ACS_RTEE: int
ACS_S1: int
ACS_S3: int
ACS_S7: int
ACS_S9: int
ACS_SBBS: int
ACS_SBSB: int
ACS_SBSS: int
ACS_SSBB: int
ACS_SSBS: int
ACS_SSSB: int
ACS_SSSS: int
ACS_STERLING: int
ACS_TTEE: int
ACS_UARROW: int
ACS_ULCORNER: int
ACS_URCORNER: int
ACS_VLINE: int
ALL_MOUSE_EVENTS: int
A_ALTCHARSET: int
A_ATTRIBUTES: int
A_BLINK: int
A_BOLD: int
A_CHARTEXT: int
A_COLOR: int
A_DIM: int
A_HORIZONTAL: int
A_INVIS: int
if sys.version_info >= (3, 7):
A_ITALIC: int
A_LEFT: int
A_LOW: int
A_NORMAL: int
A_PROTECT: int
A_REVERSE: int
A_RIGHT: int
A_STANDOUT: int
A_TOP: int
A_UNDERLINE: int
A_VERTICAL: int
BUTTON1_CLICKED: int
BUTTON1_DOUBLE_CLICKED: int
BUTTON1_PRESSED: int
BUTTON1_RELEASED: int
BUTTON1_TRIPLE_CLICKED: int
BUTTON2_CLICKED: int
BUTTON2_DOUBLE_CLICKED: int
BUTTON2_PRESSED: int
BUTTON2_RELEASED: int
BUTTON2_TRIPLE_CLICKED: int
BUTTON3_CLICKED: int
BUTTON3_DOUBLE_CLICKED: int
BUTTON3_PRESSED: int
BUTTON3_RELEASED: int
BUTTON3_TRIPLE_CLICKED: int
BUTTON4_CLICKED: int
BUTTON4_DOUBLE_CLICKED: int
BUTTON4_PRESSED: int
BUTTON4_RELEASED: int
BUTTON4_TRIPLE_CLICKED: int
BUTTON_ALT: int
BUTTON_CTRL: int
BUTTON_SHIFT: int
COLOR_BLACK: int
COLOR_BLUE: int
COLOR_CYAN: int
COLOR_GREEN: int
COLOR_MAGENTA: int
COLOR_RED: int
COLOR_WHITE: int
COLOR_YELLOW: int
ERR: int
KEY_A1: int
KEY_A3: int
KEY_B2: int
KEY_BACKSPACE: int
KEY_BEG: int
KEY_BREAK: int
KEY_BTAB: int
KEY_C1: int
KEY_C3: int
KEY_CANCEL: int
KEY_CATAB: int
KEY_CLEAR: int
KEY_CLOSE: int
KEY_COMMAND: int
KEY_COPY: int
KEY_CREATE: int
KEY_CTAB: int
KEY_DC: int
KEY_DL: int
KEY_DOWN: int
KEY_EIC: int
KEY_END: int
KEY_ENTER: int
KEY_EOL: int
KEY_EOS: int
KEY_EXIT: int
KEY_F0: int
KEY_F1: int
KEY_F10: int
KEY_F11: int
KEY_F12: int
KEY_F13: int
KEY_F14: int
KEY_F15: int
KEY_F16: int
KEY_F17: int
KEY_F18: int
KEY_F19: int
KEY_F2: int
KEY_F20: int
KEY_F21: int
KEY_F22: int
KEY_F23: int
KEY_F24: int
KEY_F25: int
KEY_F26: int
KEY_F27: int
KEY_F28: int
KEY_F29: int
KEY_F3: int
KEY_F30: int
KEY_F31: int
KEY_F32: int
KEY_F33: int
KEY_F34: int
KEY_F35: int
KEY_F36: int
KEY_F37: int
KEY_F38: int
KEY_F39: int
KEY_F4: int
KEY_F40: int
KEY_F41: int
KEY_F42: int
KEY_F43: int
KEY_F44: int
KEY_F45: int
KEY_F46: int
KEY_F47: int
KEY_F48: int
KEY_F49: int
KEY_F5: int
KEY_F50: int
KEY_F51: int
KEY_F52: int
KEY_F53: int
KEY_F54: int
KEY_F55: int
KEY_F56: int
KEY_F57: int
KEY_F58: int
KEY_F59: int
KEY_F6: int
KEY_F60: int
KEY_F61: int
KEY_F62: int
KEY_F63: int
KEY_F7: int
KEY_F8: int
KEY_F9: int
KEY_FIND: int
KEY_HELP: int
KEY_HOME: int
KEY_IC: int
KEY_IL: int
KEY_LEFT: int
KEY_LL: int
KEY_MARK: int
KEY_MAX: int
KEY_MESSAGE: int
KEY_MIN: int
KEY_MOUSE: int
KEY_MOVE: int
KEY_NEXT: int
KEY_NPAGE: int
KEY_OPEN: int
KEY_OPTIONS: int
KEY_PPAGE: int
KEY_PREVIOUS: int
KEY_PRINT: int
KEY_REDO: int
KEY_REFERENCE: int
KEY_REFRESH: int
KEY_REPLACE: int
KEY_RESET: int
KEY_RESIZE: int
KEY_RESTART: int
KEY_RESUME: int
KEY_RIGHT: int
KEY_SAVE: int
KEY_SBEG: int
KEY_SCANCEL: int
KEY_SCOMMAND: int
KEY_SCOPY: int
KEY_SCREATE: int
KEY_SDC: int
KEY_SDL: int
KEY_SELECT: int
KEY_SEND: int
KEY_SEOL: int
KEY_SEXIT: int
KEY_SF: int
KEY_SFIND: int
KEY_SHELP: int
KEY_SHOME: int
KEY_SIC: int
KEY_SLEFT: int
KEY_SMESSAGE: int
KEY_SMOVE: int
KEY_SNEXT: int
KEY_SOPTIONS: int
KEY_SPREVIOUS: int
KEY_SPRINT: int
KEY_SR: int
KEY_SREDO: int
KEY_SREPLACE: int
KEY_SRESET: int
KEY_SRIGHT: int
KEY_SRSUME: int
KEY_SSAVE: int
KEY_SSUSPEND: int
KEY_STAB: int
KEY_SUNDO: int
KEY_SUSPEND: int
KEY_UNDO: int
KEY_UP: int
OK: int
REPORT_MOUSE_POSITION: int
_C_API: Any
version: bytes
def baudrate() -> int: ...
def beep() -> None: ...
def can_change_color() -> bool: ...
def cbreak(__flag: bool = ...) -> None: ...
def color_content(__color_number: int) -> Tuple[int, int, int]: ...
# Changed in Python 3.8.8 and 3.9.2
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: ...
def def_shell_mode() -> None: ...
def delay_output(__ms: int) -> None: ...
def doupdate() -> None: ...
def echo(__flag: bool = ...) -> None: ...
def endwin() -> None: ...
def erasechar() -> bytes: ...
def filter() -> None: ...
def flash() -> None: ...
def flushinp() -> None: ...
def getmouse() -> Tuple[int, int, int, int, int]: ...
def getsyx() -> Tuple[int, int]: ...
def getwin(__file: BinaryIO) -> _CursesWindow: ...
def halfdelay(__tenths: int) -> None: ...
def has_colors() -> bool: ...
def has_ic() -> bool: ...
def has_il() -> bool: ...
def has_key(__key: int) -> bool: ...
def init_color(__color_number: int, __r: int, __g: int, __b: int) -> None: ...
def init_pair(__pair_number: int, __fg: int, __bg: int) -> None: ...
def initscr() -> _CursesWindow: ...
def intrflush(__flag: bool) -> None: ...
def is_term_resized(__nlines: int, __ncols: int) -> bool: ...
def isendwin() -> bool: ...
def keyname(__key: int) -> bytes: ...
def killchar() -> bytes: ...
def longname() -> bytes: ...
def meta(__yes: bool) -> None: ...
def mouseinterval(__interval: int) -> None: ...
def mousemask(__newmask: int) -> Tuple[int, int]: ...
def napms(__ms: int) -> int: ...
def newpad(__nlines: int, __ncols: int) -> _CursesWindow: ...
def newwin(__nlines: int, __ncols: int, __begin_y: int = ..., __begin_x: int = ...) -> _CursesWindow: ...
def nl(__flag: bool = ...) -> None: ...
def nocbreak() -> None: ...
def noecho() -> None: ...
def nonl() -> None: ...
def noqiflush() -> None: ...
def noraw() -> None: ...
def pair_content(__pair_number: int) -> Tuple[int, int]: ...
def pair_number(__attr: int) -> int: ...
def putp(__string: bytes) -> None: ...
def qiflush(__flag: bool = ...) -> None: ...
def raw(__flag: bool = ...) -> None: ...
def reset_prog_mode() -> None: ...
def reset_shell_mode() -> None: ...
def resetty() -> None: ...
def resize_term(__nlines: int, __ncols: int) -> None: ...
def resizeterm(__nlines: int, __ncols: int) -> None: ...
def savetty() -> None: ...
def setsyx(__y: int, __x: int) -> None: ...
def setupterm(term: Optional[str] = ..., fd: int = ...) -> None: ...
def start_color() -> None: ...
def termattrs() -> int: ...
def termname() -> bytes: ...
def tigetflag(__capname: str) -> int: ...
def tigetnum(__capname: str) -> int: ...
def tigetstr(__capname: str) -> bytes: ...
def tparm(
__str: bytes,
__i1: int = ...,
__i2: int = ...,
__i3: int = ...,
__i4: int = ...,
__i5: int = ...,
__i6: int = ...,
__i7: int = ...,
__i8: int = ...,
__i9: int = ...,
) -> bytes: ...
def typeahead(__fd: int) -> None: ...
def unctrl(__ch: _chtype) -> bytes: ...
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
def addch(self, y: int, x: int, ch: _chtype, attr: int = ...) -> None: ...
@overload
def addnstr(self, str: str, n: int, attr: int = ...) -> None: ...
@overload
def addnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
@overload
def addstr(self, str: str, attr: int = ...) -> None: ...
@overload
def addstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
def attroff(self, __attr: int) -> None: ...
def attron(self, __attr: int) -> None: ...
def attrset(self, __attr: int) -> None: ...
def bkgd(self, __ch: _chtype, __attr: int = ...) -> None: ...
def bkgdset(self, __ch: _chtype, __attr: int = ...) -> None: ...
def border(
self,
ls: _chtype = ...,
rs: _chtype = ...,
ts: _chtype = ...,
bs: _chtype = ...,
tl: _chtype = ...,
tr: _chtype = ...,
bl: _chtype = ...,
br: _chtype = ...,
) -> None: ...
@overload
def box(self) -> None: ...
@overload
def box(self, vertch: _chtype = ..., horch: _chtype = ...) -> None: ...
@overload
def chgat(self, attr: int) -> None: ...
@overload
def chgat(self, num: int, attr: int) -> None: ...
@overload
def chgat(self, y: int, x: int, attr: int) -> None: ...
@overload
def chgat(self, y: int, x: int, num: int, attr: int) -> None: ...
def clear(self) -> None: ...
def clearok(self, yes: int) -> None: ...
def clrtobot(self) -> None: ...
def clrtoeol(self) -> None: ...
def cursyncup(self) -> None: ...
@overload
def delch(self) -> None: ...
@overload
def delch(self, y: int, x: int) -> None: ...
def deleteln(self) -> None: ...
@overload
def derwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
@overload
def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
def echochar(self, __ch: _chtype, __attr: int = ...) -> None: ...
def enclose(self, __y: int, __x: int) -> bool: ...
def erase(self) -> None: ...
def getbegyx(self) -> Tuple[int, int]: ...
def getbkgd(self) -> Tuple[int, int]: ...
@overload
def getch(self) -> int: ...
@overload
def getch(self, y: int, x: int) -> int: ...
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
def getkey(self, y: int, x: int) -> str: ...
def getmaxyx(self) -> Tuple[int, int]: ...
def getparyx(self) -> Tuple[int, int]: ...
@overload
def getstr(self) -> _chtype: ...
@overload
def getstr(self, n: int) -> _chtype: ...
@overload
def getstr(self, y: int, x: int) -> _chtype: ...
@overload
def getstr(self, y: int, x: int, n: int) -> _chtype: ...
def getyx(self) -> Tuple[int, int]: ...
@overload
def hline(self, ch: _chtype, n: int) -> None: ...
@overload
def hline(self, y: int, x: int, ch: _chtype, n: int) -> None: ...
def idcok(self, flag: bool) -> None: ...
def idlok(self, yes: bool) -> None: ...
def immedok(self, flag: bool) -> None: ...
@overload
def inch(self) -> _chtype: ...
@overload
def inch(self, y: int, x: int) -> _chtype: ...
@overload
def insch(self, ch: _chtype, attr: int = ...) -> None: ...
@overload
def insch(self, y: int, x: int, ch: _chtype, attr: int = ...) -> None: ...
def insdelln(self, nlines: int) -> None: ...
def insertln(self) -> None: ...
@overload
def insnstr(self, str: str, n: int, attr: int = ...) -> None: ...
@overload
def insnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
@overload
def insstr(self, str: str, attr: int = ...) -> None: ...
@overload
def insstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
@overload
def instr(self, n: int = ...) -> _chtype: ...
@overload
def instr(self, y: int, x: int, n: int = ...) -> _chtype: ...
def is_linetouched(self, __line: int) -> bool: ...
def is_wintouched(self) -> bool: ...
def keypad(self, yes: bool) -> None: ...
def leaveok(self, yes: bool) -> None: ...
def move(self, new_y: int, new_x: int) -> None: ...
def mvderwin(self, y: int, x: int) -> None: ...
def mvwin(self, new_y: int, new_x: int) -> None: ...
def nodelay(self, yes: bool) -> None: ...
def notimeout(self, yes: bool) -> None: ...
def noutrefresh(self) -> None: ...
@overload
def overlay(self, destwin: _CursesWindow) -> None: ...
@overload
def overlay(
self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
) -> None: ...
@overload
def overwrite(self, destwin: _CursesWindow) -> None: ...
@overload
def overwrite(
self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
) -> None: ...
def putwin(self, __file: IO[Any]) -> None: ...
def redrawln(self, __beg: int, __num: int) -> None: ...
def redrawwin(self) -> None: ...
@overload
def refresh(self) -> None: ...
@overload
def refresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ...
def resize(self, nlines: int, ncols: int) -> None: ...
def scroll(self, lines: int = ...) -> None: ...
def scrollok(self, flag: bool) -> None: ...
def setscrreg(self, __top: int, __bottom: int) -> None: ...
def standend(self) -> None: ...
def standout(self) -> None: ...
@overload
def subpad(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
@overload
def subpad(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
@overload
def subwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
@overload
def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
def syncdown(self) -> None: ...
def syncok(self, flag: bool) -> None: ...
def syncup(self) -> None: ...
def timeout(self, delay: int) -> None: ...
def touchline(self, start: int, count: int, changed: bool = ...) -> None: ...
def touchwin(self) -> None: ...
def untouchwin(self) -> None: ...
@overload
def vline(self, ch: _chtype, n: int) -> None: ...
@overload
def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ...
if sys.version_info >= (3, 8):
class _ncurses_version(NamedTuple):
major: int
minor: int
patch: int
ncurses_version: _ncurses_version
window = _CursesWindow # undocumented

View File

@@ -0,0 +1,188 @@
import sys
from types import FrameType, TracebackType
from typing import Any, Callable, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union
# TODO recursive type
_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]]
_PF = Callable[[FrameType, str, Any], None]
_T = TypeVar("_T")
__all__: List[str]
def active_count() -> 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):
def __getattribute__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
class Thread:
name: str
ident: 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 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 isDaemon(self) -> bool: ...
def setDaemon(self, daemonic: bool) -> None: ...
class _DummyThread(Thread): ...
class Lock:
def __init__(self) -> None: ...
def __enter__(self) -> bool: ...
def __exit__(
self, exc_type: 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 release(self) -> None: ...
def locked(self) -> bool: ...
class _RLock:
def __init__(self) -> None: ...
def __enter__(self) -> bool: ...
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 release(self) -> None: ...
RLock = _RLock
class Condition:
def __init__(self, lock: Union[Lock, _RLock, None] = ...) -> None: ...
def __enter__(self) -> bool: ...
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 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: ...
class Semaphore:
def __init__(self, value: int = ...) -> None: ...
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: ...
class BoundedSemaphore(Semaphore): ...
class Event:
def __init__(self) -> None: ...
def is_set(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):
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): ...

View File

@@ -0,0 +1,14 @@
import sys
from typing import Any, Callable, Iterable, List, Optional, TypeVar
_T = TypeVar("_T")
def heapify(__heap: List[Any]) -> None: ...
def heappop(__heap: List[_T]) -> _T: ...
def heappush(__heap: List[_T], __item: _T) -> None: ...
def heappushpop(__heap: List[_T], __item: _T) -> _T: ...
def heapreplace(__heap: List[_T], __item: _T) -> _T: ...
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]: ...

View File

@@ -0,0 +1,8 @@
from typing import Tuple
class ParserBase:
def __init__(self) -> None: ...
def error(self, message: str) -> None: ...
def reset(self) -> None: ...
def getpos(self) -> Tuple[int, int]: ...
def unknown_decl(self, data: str) -> None: ...

49
stdlib/@python2/_msi.pyi Normal file
View File

@@ -0,0 +1,49 @@
import sys
from typing import List, Optional, Union
if sys.platform == "win32":
# Actual typename View, not exposed by the implementation
class _View:
def Execute(self, params: Optional[_Record] = ...) -> None: ...
def GetColumnInfo(self, kind: int) -> _Record: ...
def Fetch(self) -> _Record: ...
def Modify(self, mode: int, record: _Record) -> None: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
# Actual typename Summary, not exposed by the implementation
class _Summary:
def GetProperty(self, propid: int) -> Optional[Union[str, bytes]]: ...
def GetPropertyCount(self) -> int: ...
def SetProperty(self, propid: int, value: Union[str, bytes]) -> None: ...
def Persist(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
# Actual typename Database, not exposed by the implementation
class _Database:
def OpenView(self, sql: str) -> _View: ...
def Commit(self) -> None: ...
def GetSummaryInformation(self, updateCount: int) -> _Summary: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
# Actual typename Record, not exposed by the implementation
class _Record:
def GetFieldCount(self) -> int: ...
def GetInteger(self, field: int) -> int: ...
def GetString(self, field: int) -> str: ...
def SetString(self, field: int, str: str) -> None: ...
def SetStream(self, field: int, stream: str) -> None: ...
def SetInteger(self, field: int, int: int) -> None: ...
def ClearData(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
def UuidCreate() -> str: ...
def FCICreate(cabname: str, files: List[str]) -> None: ...
def OpenDatabase(name: str, flags: int) -> _Database: ...
def CreateRecord(count: int) -> _Record: ...

View File

@@ -0,0 +1,33 @@
from typing import Dict, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union
_T = TypeVar("_T")
_K = TypeVar("_K")
_V = TypeVar("_V")
__all__: List[str]
_UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented
_COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented
_INITPRE: str # undocumented
def _find_executable(executable: str, path: Optional[str] = ...) -> Optional[str]: ... # undocumented
def _read_output(commandstring: str) -> Optional[str]: ... # undocumented
def _find_build_tool(toolname: str) -> str: ... # undocumented
_SYSTEM_VERSION: Optional[str] # undocumented
def _get_system_version() -> str: ... # undocumented
def _remove_original_values(_config_vars: Dict[str, str]) -> None: ... # undocumented
def _save_modified_value(_config_vars: Dict[str, str], cv: str, newvalue: str) -> None: ... # undocumented
def _supports_universal_builds() -> bool: ... # undocumented
def _find_appropriate_compiler(_config_vars: Dict[str, str]) -> Dict[str, str]: ... # undocumented
def _remove_universal_flags(_config_vars: Dict[str, str]) -> Dict[str, str]: ... # undocumented
def _remove_unsupported_archs(_config_vars: Dict[str, str]) -> Dict[str, str]: ... # undocumented
def _override_all_archs(_config_vars: Dict[str, str]) -> Dict[str, str]: ... # undocumented
def _check_for_unavailable_sdk(_config_vars: Dict[str, str]) -> Dict[str, str]: ... # undocumented
def compiler_fixup(compiler_so: Iterable[str], cc_args: Sequence[str]) -> List[str]: ...
def customize_config_vars(_config_vars: Dict[str, str]) -> Dict[str, str]: ...
def customize_compiler(_config_vars: Dict[str, str]) -> Dict[str, str]: ...
def get_platform_osx(
_config_vars: Dict[str, str], osname: _T, release: _K, machine: _V
) -> Tuple[Union[str, _T], Union[str, _K], Union[str, _V]]: ...

View File

@@ -0,0 +1,15 @@
import sys
from typing import Tuple
# Actually Tuple[(int,) * 625]
_State = Tuple[int, ...]
class Random(object):
def __init__(self, seed: object = ...) -> None: ...
def seed(self, __n: object = ...) -> None: ...
def getstate(self) -> _State: ...
def setstate(self, __state: _State) -> None: ...
def random(self) -> float: ...
def getrandbits(self, __k: int) -> int: ...
if sys.version_info < (3,):
def jumpahead(self, i: int) -> None: ...

View File

@@ -0,0 +1,41 @@
import sys
from threading import Thread
from types import TracebackType
from typing import Any, Callable, Dict, NoReturn, Optional, Tuple, Type
error = RuntimeError
def _count() -> int: ...
_dangling: Any
class LockType:
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...
def locked(self) -> bool: ...
def __enter__(self) -> bool: ...
def __exit__(
self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
) -> None: ...
def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> int: ...
def interrupt_main() -> None: ...
def exit() -> NoReturn: ...
def allocate_lock() -> LockType: ...
def get_ident() -> int: ...
def stack_size(size: int = ...) -> int: ...
TIMEOUT_MAX: float
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]

View File

@@ -0,0 +1,95 @@
from typing import Any
from typing_extensions import Literal
# _tkinter is meant to be only used internally by tkinter, but some tkinter
# functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl
# object that hasn't been converted to a string.
#
# There are not many ways to get Tcl_Objs from tkinter, and I'm not sure if the
# only existing ways are supposed to return Tcl_Objs as opposed to returning
# strings. Here's one of these things that return Tcl_Objs:
#
# >>> import tkinter
# >>> text = tkinter.Text()
# >>> text.tag_add('foo', '1.0', 'end')
# >>> text.tag_ranges('foo')
# (<textindex object: '1.0'>, <textindex object: '2.0'>)
class Tcl_Obj:
string: str # str(tclobj) returns this
typename: str
class TclError(Exception): ...
# This class allows running Tcl code. Tkinter uses it internally a lot, and
# it's often handy to drop a piece of Tcl code into a tkinter program. Example:
#
# >>> import tkinter, _tkinter
# >>> tkapp = tkinter.Tk().tk
# >>> isinstance(tkapp, _tkinter.TkappType)
# True
# >>> tkapp.call('set', 'foo', (1,2,3))
# (1, 2, 3)
# >>> tkapp.eval('return $foo')
# '1 2 3'
# >>>
#
# call args can be pretty much anything. Also, call(some_tuple) is same as call(*some_tuple).
#
# eval always returns str because _tkinter_tkapp_eval_impl in _tkinter.c calls
# Tkapp_UnicodeResult, and it returns a string when it succeeds.
class TkappType:
# Please keep in sync with tkinter.Tk
def call(self, __command: Any, *args: Any) -> Any: ...
def eval(self, __script: str) -> str: ...
adderrorinfo: Any
createcommand: Any
createfilehandler: Any
createtimerhandler: Any
deletecommand: Any
deletefilehandler: Any
dooneevent: Any
evalfile: Any
exprboolean: Any
exprdouble: Any
exprlong: Any
exprstring: Any
getboolean: Any
getdouble: Any
getint: Any
getvar: Any
globalgetvar: Any
globalsetvar: Any
globalunsetvar: Any
interpaddr: Any
loadtk: Any
mainloop: Any
quit: Any
record: Any
setvar: Any
split: Any
splitlist: Any
unsetvar: Any
wantobjects: Any
willdispatch: Any
# These should be kept in sync with tkinter.tix constants, except ALL_EVENTS which doesn't match TCL_ALL_EVENTS
ALL_EVENTS: Literal[-3]
FILE_EVENTS: Literal[8]
IDLE_EVENTS: Literal[32]
TIMER_EVENTS: Literal[16]
WINDOW_EVENTS: Literal[4]
DONT_WAIT: Literal[2]
EXCEPTION: Literal[8]
READABLE: Literal[2]
WRITABLE: Literal[4]
TCL_VERSION: str
TK_VERSION: str
# TODO: figure out what these are (with e.g. help()) and get rid of Any
TkttType: Any
_flatten: Any
create: Any
getbusywaitinterval: Any
setbusywaitinterval: Any

View File

@@ -0,0 +1,171 @@
# Utility types for typeshed
# This module contains various common types to be used by typeshed. The
# module and its types do not exist at runtime. You can use this module
# outside of typeshed, but no API stability guarantees are made. To use
# it in implementation (.py) files, the following construct must be used:
#
# from typing import TYPE_CHECKING
# if TYPE_CHECKING:
# from _typeshed import ...
#
# If on Python versions < 3.10 and "from __future__ import annotations"
# is not used, types from this module must be quoted.
import array
import mmap
import sys
from typing import AbstractSet, Any, Container, Iterable, Protocol, Text, Tuple, TypeVar, Union
from typing_extensions import Literal, final
_KT = TypeVar("_KT")
_KT_co = TypeVar("_KT_co", covariant=True)
_KT_contra = TypeVar("_KT_contra", contravariant=True)
_VT = TypeVar("_VT")
_VT_co = TypeVar("_VT_co", covariant=True)
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
class SupportsLessThan(Protocol):
def __lt__(self, __other: Any) -> bool: ...
SupportsLessThanT = TypeVar("SupportsLessThanT", bound=SupportsLessThan) # noqa: Y001
class SupportsDivMod(Protocol[_T_contra, _T_co]):
def __divmod__(self, __other: _T_contra) -> _T_co: ...
class SupportsRDivMod(Protocol[_T_contra, _T_co]):
def __rdivmod__(self, __other: _T_contra) -> _T_co: ...
# Mapping-like protocols
class SupportsItems(Protocol[_KT_co, _VT_co]):
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]: ...
def __getitem__(self, __k: _KT) -> _VT_co: ...
class SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]):
def __getitem__(self, __k: _KT_contra) -> _VT_co: ...
class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]):
def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ...
def __delitem__(self, __v: _KT_contra) -> None: ...
# 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]
OpenTextModeUpdating = Literal[
"r+",
"+r",
"rt+",
"r+t",
"+rt",
"tr+",
"t+r",
"+tr",
"w+",
"+w",
"wt+",
"w+t",
"+wt",
"tw+",
"t+w",
"+tw",
"a+",
"+a",
"at+",
"a+t",
"+at",
"ta+",
"t+a",
"+ta",
"x+",
"+x",
"xt+",
"x+t",
"+xt",
"tx+",
"t+x",
"+tx",
]
OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
OpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading]
OpenBinaryModeUpdating = Literal[
"rb+",
"r+b",
"+rb",
"br+",
"b+r",
"+br",
"wb+",
"w+b",
"+wb",
"bw+",
"b+w",
"+bw",
"ab+",
"a+b",
"+ab",
"ba+",
"b+a",
"+ba",
"xb+",
"x+b",
"+xb",
"bx+",
"b+x",
"+bx",
]
OpenBinaryModeWriting = Literal["wb", "bw", "ab", "ba", "xb", "bx"]
OpenBinaryModeReading = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"]
OpenBinaryMode = Union[OpenBinaryModeUpdating, OpenBinaryModeReading, OpenBinaryModeWriting]
class HasFileno(Protocol):
def fileno(self) -> int: ...
FileDescriptor = int
FileDescriptorLike = Union[int, HasFileno]
class SupportsRead(Protocol[_T_co]):
def read(self, __length: int = ...) -> _T_co: ...
class SupportsReadline(Protocol[_T_co]):
def readline(self, __length: int = ...) -> _T_co: ...
class SupportsNoArgReadline(Protocol[_T_co]):
def readline(self) -> _T_co: ...
class SupportsWrite(Protocol[_T_contra]):
def write(self, __s: _T_contra) -> Any: ...
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]: ...

View File

@@ -0,0 +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: ...

View File

@@ -0,0 +1,35 @@
# Types to support PEP 3333 (WSGI)
#
# This module doesn't exist at runtime and neither do the types defined in this
# file. They are provided for type checking purposes.
from sys import _OptExcInfo
from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Text, Tuple
class StartResponse(Protocol):
def __call__(
self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_OptExcInfo] = ...
) -> Callable[[bytes], Any]: ...
WSGIEnvironment = Dict[Text, Any]
WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]]
# WSGI input streams per PEP 3333
class InputStream(Protocol):
def read(self, size: int = ...) -> bytes: ...
def readline(self, size: int = ...) -> bytes: ...
def readlines(self, hint: int = ...) -> List[bytes]: ...
def __iter__(self) -> Iterable[bytes]: ...
# WSGI error streams per PEP 3333
class ErrorStream(Protocol):
def flush(self) -> None: ...
def write(self, s: str) -> None: ...
def writelines(self, seq: List[str]) -> None: ...
class _Readable(Protocol):
def read(self, size: int = ...) -> bytes: ...
# Optional file wrapper in wsgi.file_wrapper
class FileWrapper(Protocol):
def __call__(self, file: _Readable, block_size: int = ...) -> Iterable[bytes]: ...

View File

@@ -0,0 +1,10 @@
# Stub-only types. This module does not exist at runtime.
from typing import Any, Optional
from typing_extensions import Protocol
# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects
class DOMImplementation(Protocol):
def hasFeature(self, feature: str, version: Optional[str]) -> bool: ...
def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Optional[Any]) -> Any: ...
def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str) -> Any: ...

View File

@@ -0,0 +1,67 @@
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]
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: ...

View File

@@ -0,0 +1,34 @@
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")
class CallableProxyType(Generic[_C]): # "weakcallableproxy"
def __getattr__(self, attr: str) -> Any: ...
class ProxyType(Generic[_T]): # "weakproxy"
def __getattr__(self, attr: str) -> Any: ...
class ReferenceType(Generic[_T]):
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: ...
def getweakrefs(object: Any) -> List[Any]: ...
@overload
def proxy(object: _C, callback: Optional[Callable[[_C], Any]] = ...) -> CallableProxyType[_C]: ...
# Return CallableProxyType if object is callable, ProxyType otherwise
@overload
def proxy(object: _T, callback: Optional[Callable[[_T], Any]] = ...) -> Any: ...

View File

@@ -0,0 +1,47 @@
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])
class WeakSet(MutableSet[_T], Generic[_T]):
def __init__(self, data: Optional[Iterable[_T]] = ...) -> None: ...
def add(self, item: _T) -> None: ...
def clear(self) -> None: ...
def discard(self, item: _T) -> None: ...
def copy(self: _SelfT) -> _SelfT: ...
def pop(self) -> _T: ...
def remove(self, item: _T) -> None: ...
def update(self, other: Iterable[_T]) -> None: ...
def __contains__(self, item: object) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __ior__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ...
def difference(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
def __sub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
def difference_update(self, other: Iterable[_T]) -> None: ...
def __isub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
def intersection(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
def __and__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
def intersection_update(self, other: Iterable[_T]) -> None: ...
def __iand__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ...
def issubset(self, other: Iterable[_T]) -> bool: ...
def __le__(self, other: Iterable[_T]) -> bool: ...
def __lt__(self, other: Iterable[_T]) -> bool: ...
def issuperset(self, other: Iterable[_T]) -> bool: ...
def __ge__(self, other: Iterable[_T]) -> bool: ...
def __gt__(self, other: Iterable[_T]) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def symmetric_difference(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ...
def __xor__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ...
def symmetric_difference_update(self, other: Iterable[Any]) -> None: ...
def __ixor__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _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: ...

88
stdlib/@python2/aifc.pyi Normal file
View File

@@ -0,0 +1,88 @@
import sys
from types import TracebackType
from typing import IO, Any, List, NamedTuple, Optional, Text, Tuple, Type, Union, overload
from typing_extensions import Literal
class Error(Exception): ...
class _aifc_params(NamedTuple):
nchannels: int
sampwidth: int
framerate: int
nframes: int
comptype: bytes
compname: bytes
_File = Union[Text, IO[bytes]]
_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: ...
def close(self) -> None: ...
def tell(self) -> int: ...
def getnchannels(self) -> int: ...
def getnframes(self) -> int: ...
def getsampwidth(self) -> int: ...
def getframerate(self) -> int: ...
def getcomptype(self) -> bytes: ...
def getcompname(self) -> bytes: ...
def getparams(self) -> _aifc_params: ...
def getmarkers(self) -> Optional[List[_Marker]]: ...
def getmark(self, id: int) -> _Marker: ...
def setpos(self, pos: int) -> None: ...
def readframes(self, nframes: int) -> bytes: ...
class Aifc_write:
def __init__(self, f: _File) -> None: ...
def __del__(self) -> None: ...
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: ...
def setnchannels(self, nchannels: int) -> None: ...
def getnchannels(self) -> int: ...
def setsampwidth(self, sampwidth: int) -> None: ...
def getsampwidth(self) -> int: ...
def setframerate(self, framerate: int) -> None: ...
def getframerate(self) -> int: ...
def setnframes(self, nframes: int) -> None: ...
def getnframes(self) -> int: ...
def setcomptype(self, comptype: bytes, compname: bytes) -> None: ...
def getcomptype(self) -> bytes: ...
def getcompname(self) -> bytes: ...
def setparams(self, params: Tuple[int, int, int, int, bytes, bytes]) -> None: ...
def getparams(self) -> _aifc_params: ...
def setmark(self, id: int, pos: int, name: bytes) -> None: ...
def getmark(self, id: int) -> _Marker: ...
def getmarkers(self) -> Optional[List[_Marker]]: ...
def tell(self) -> int: ...
def writeframesraw(self, data: Any) -> None: ... # Actual type for data is Buffer Protocol
def writeframes(self, data: Any) -> None: ...
def close(self) -> None: ...
@overload
def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
@overload
def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload
def open(f: _File, mode: 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: ...

View File

@@ -0,0 +1,4 @@
import sys
if sys.version_info >= (3, 0):
def geohash(latitude: float, longitude: float, datedow: bytes) -> None: ...

View File

@@ -0,0 +1,487 @@
import sys
from typing import (
IO,
Any,
Callable,
Dict,
Generator,
Iterable,
List,
NoReturn,
Optional,
Pattern,
Protocol,
Sequence,
Text,
Tuple,
Type,
TypeVar,
Union,
overload,
)
_T = TypeVar("_T")
_ActionT = TypeVar("_ActionT", bound=Action)
_N = TypeVar("_N")
if sys.version_info >= (3,):
_Text = str
else:
_Text = Union[str, unicode]
ONE_OR_MORE: str
OPTIONAL: str
PARSER: str
REMAINDER: str
SUPPRESS: str
ZERO_OR_MORE: str
_UNRECOGNIZED_ARGS_ATTR: str # undocumented
class ArgumentError(Exception):
argument_name: Optional[str]
message: str
def __init__(self, argument: Optional[Action], message: str) -> None: ...
# undocumented
class _AttributeHolder:
def _get_kwargs(self) -> List[Tuple[str, Any]]: ...
def _get_args(self) -> List[Any]: ...
# undocumented
class _ActionsContainer:
description: Optional[_Text]
prefix_chars: _Text
argument_default: Any
conflict_handler: _Text
_registries: Dict[_Text, Dict[Any, Any]]
_actions: List[Action]
_option_string_actions: Dict[_Text, Action]
_action_groups: List[_ArgumentGroup]
_mutually_exclusive_groups: List[_MutuallyExclusiveGroup]
_defaults: Dict[str, Any]
_negative_number_matcher: Pattern[str]
_has_negative_number_optionals: List[bool]
def __init__(
self, description: Optional[Text], prefix_chars: Text, argument_default: Any, conflict_handler: Text
) -> None: ...
def register(self, registry_name: Text, value: Any, object: Any) -> None: ...
def _registry_get(self, registry_name: Text, value: Any, default: Any = ...) -> Any: ...
def set_defaults(self, **kwargs: Any) -> None: ...
def get_default(self, dest: Text) -> Any: ...
def add_argument(
self,
*name_or_flags: Text,
action: Union[Text, Type[Action]] = ...,
nargs: Union[int, Text] = ...,
const: Any = ...,
default: Any = ...,
type: Union[Callable[[Text], _T], Callable[[str], _T], FileType] = ...,
choices: Iterable[_T] = ...,
required: bool = ...,
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
dest: Optional[Text] = ...,
version: Text = ...,
**kwargs: Any,
) -> Action: ...
def add_argument_group(self, *args: Any, **kwargs: Any) -> _ArgumentGroup: ...
def add_mutually_exclusive_group(self, **kwargs: Any) -> _MutuallyExclusiveGroup: ...
def _add_action(self, action: _ActionT) -> _ActionT: ...
def _remove_action(self, action: Action) -> None: ...
def _add_container_actions(self, container: _ActionsContainer) -> None: ...
def _get_positional_kwargs(self, dest: Text, **kwargs: Any) -> Dict[str, Any]: ...
def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ...
def _pop_action_class(self, kwargs: Any, default: Optional[Type[Action]] = ...) -> Type[Action]: ...
def _get_handler(self) -> Callable[[Action, Iterable[Tuple[Text, Action]]], Any]: ...
def _check_conflict(self, action: Action) -> None: ...
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[Tuple[Text, Action]]) -> NoReturn: ...
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[Tuple[Text, Action]]) -> None: ...
class _FormatterClass(Protocol):
def __call__(self, prog: str) -> HelpFormatter: ...
class ArgumentParser(_AttributeHolder, _ActionsContainer):
prog: _Text
usage: Optional[_Text]
epilog: Optional[_Text]
formatter_class: _FormatterClass
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: ...
# The type-ignores in these overloads should be temporary. See:
# https://github.com/python/typeshed/pull/2643#issuecomment-442280277
@overload
def parse_args(self, args: Optional[Sequence[Text]] = ...) -> Namespace: ...
@overload
def parse_args(self, args: Optional[Sequence[Text]], namespace: None) -> Namespace: ... # type: ignore
@overload
def parse_args(self, args: Optional[Sequence[Text]], namespace: _N) -> _N: ...
@overload
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 print_usage(self, file: Optional[IO[str]] = ...) -> None: ...
def print_help(self, file: Optional[IO[str]] = ...) -> None: ...
def format_usage(self) -> str: ...
def format_help(self) -> str: ...
def parse_known_args(
self, args: Optional[Sequence[Text]] = ..., namespace: Optional[Namespace] = ...
) -> Tuple[Namespace, List[str]]: ...
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]: ...
def _parse_known_args(self, arg_strings: List[Text], namespace: Namespace) -> Tuple[Namespace, List[str]]: ...
def _read_args_from_files(self, arg_strings: List[Text]) -> List[Text]: ...
def _match_argument(self, action: Action, arg_strings_pattern: Text) -> int: ...
def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: Text) -> List[int]: ...
def _parse_optional(self, arg_string: Text) -> Optional[Tuple[Optional[Action], Text, Optional[Text]]]: ...
def _get_option_tuples(self, option_string: Text) -> List[Tuple[Action, Text, Optional[Text]]]: ...
def _get_nargs_pattern(self, action: Action) -> _Text: ...
def _get_values(self, action: Action, arg_strings: List[Text]) -> Any: ...
def _get_value(self, action: Action, arg_string: Text) -> Any: ...
def _check_value(self, action: Action, value: Any) -> None: ...
def _get_formatter(self) -> HelpFormatter: ...
def _print_message(self, message: str, file: Optional[IO[str]] = ...) -> None: ...
class HelpFormatter:
# undocumented
_prog: _Text
_indent_increment: int
_max_help_position: int
_width: int
_current_indent: int
_level: int
_action_max_length: int
_root_section: Any
_current_section: Any
_whitespace_matcher: Pattern[str]
_long_break_matcher: Pattern[str]
_Section: Type[Any] # Nested class
def __init__(
self, prog: Text, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ...
) -> None: ...
def _indent(self) -> None: ...
def _dedent(self) -> None: ...
def _add_item(self, func: Callable[..., _Text], args: Iterable[Any]) -> None: ...
def start_section(self, heading: Optional[Text]) -> None: ...
def end_section(self) -> None: ...
def add_text(self, text: Optional[Text]) -> None: ...
def add_usage(
self, usage: Optional[Text], actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[Text] = ...
) -> None: ...
def add_argument(self, action: Action) -> None: ...
def add_arguments(self, actions: Iterable[Action]) -> None: ...
def format_help(self) -> _Text: ...
def _join_parts(self, part_strings: Iterable[Text]) -> _Text: ...
def _format_usage(
self, usage: Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[Text]
) -> _Text: ...
def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_ArgumentGroup]) -> _Text: ...
def _format_text(self, text: Text) -> _Text: ...
def _format_action(self, action: Action) -> _Text: ...
def _format_action_invocation(self, action: Action) -> _Text: ...
def _metavar_formatter(self, action: Action, default_metavar: Text) -> Callable[[int], Tuple[_Text, ...]]: ...
def _format_args(self, action: Action, default_metavar: Text) -> _Text: ...
def _expand_help(self, action: Action) -> _Text: ...
def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ...
def _split_lines(self, text: Text, width: int) -> List[_Text]: ...
def _fill_text(self, text: Text, width: int, indent: Text) -> _Text: ...
def _get_help_string(self, action: Action) -> Optional[_Text]: ...
def _get_default_metavar_for_optional(self, action: Action) -> _Text: ...
def _get_default_metavar_for_positional(self, action: Action) -> _Text: ...
class RawDescriptionHelpFormatter(HelpFormatter): ...
class RawTextHelpFormatter(RawDescriptionHelpFormatter): ...
class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
if sys.version_info >= (3,):
class MetavarTypeHelpFormatter(HelpFormatter): ...
class Action(_AttributeHolder):
option_strings: Sequence[_Text]
dest: _Text
nargs: Optional[Union[int, _Text]]
const: Any
default: Any
type: Union[Callable[[str], Any], FileType, None]
choices: Optional[Iterable[Any]]
required: bool
help: Optional[_Text]
metavar: Optional[Union[_Text, Tuple[_Text, ...]]]
def __init__(
self,
option_strings: Sequence[Text],
dest: Text,
nargs: Optional[Union[int, Text]] = ...,
const: Optional[_T] = ...,
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: ...
def __call__(
self,
parser: ArgumentParser,
namespace: Namespace,
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: ...
def __setattr__(self, name: Text, value: Any) -> None: ...
def __contains__(self, key: str) -> bool: ...
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 __call__(self, string: Text) -> IO[Any]: ...
# undocumented
class _ArgumentGroup(_ActionsContainer):
title: Optional[_Text]
_group_actions: List[Action]
def __init__(
self, container: _ActionsContainer, title: Optional[Text] = ..., description: Optional[Text] = ..., **kwargs: Any
) -> None: ...
# undocumented
class _MutuallyExclusiveGroup(_ArgumentGroup):
required: bool
_container: _ActionsContainer
def __init__(self, container: _ActionsContainer, required: bool = ...) -> None: ...
# undocumented
class _StoreAction(Action): ...
# undocumented
class _StoreConstAction(Action):
def __init__(
self,
option_strings: Sequence[Text],
dest: Text,
const: Any,
default: Any = ...,
required: bool = ...,
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
) -> None: ...
# undocumented
class _StoreTrueAction(_StoreConstAction):
def __init__(
self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Optional[Text] = ...
) -> None: ...
# undocumented
class _StoreFalseAction(_StoreConstAction):
def __init__(
self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Optional[Text] = ...
) -> None: ...
# undocumented
class _AppendAction(Action): ...
# undocumented
class _AppendConstAction(Action):
def __init__(
self,
option_strings: Sequence[Text],
dest: Text,
const: Any,
default: Any = ...,
required: bool = ...,
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
) -> None: ...
# undocumented
class _CountAction(Action):
def __init__(
self, option_strings: Sequence[Text], dest: Text, default: Any = ..., required: bool = ..., help: Optional[Text] = ...
) -> None: ...
# undocumented
class _HelpAction(Action):
def __init__(
self, option_strings: Sequence[Text], dest: Text = ..., default: Text = ..., help: Optional[Text] = ...
) -> None: ...
# undocumented
class _VersionAction(Action):
version: Optional[_Text]
def __init__(
self,
option_strings: Sequence[Text],
version: Optional[Text] = ...,
dest: Text = ...,
default: Text = ...,
help: Text = ...,
) -> None: ...
# undocumented
class _SubParsersAction(Action):
_ChoicesPseudoAction: Type[Any] # nested class
_prog_prefix: _Text
_parser_class: Type[ArgumentParser]
_name_parser_map: Dict[_Text, ArgumentParser]
choices: Dict[_Text, ArgumentParser]
_choices_actions: List[Action]
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]: ...
# undocumented
class ArgumentTypeError(Exception): ...
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]: ...

80
stdlib/@python2/array.pyi Normal file
View File

@@ -0,0 +1,80 @@
import sys
from typing import Any, BinaryIO, Generic, Iterable, List, MutableSequence, Text, Tuple, TypeVar, Union, overload
from typing_extensions import Literal
_IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
_FloatTypeCode = Literal["f", "d"]
_UnicodeTypeCode = Literal["u"]
_TypeCode = 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
@overload
def __init__(self: array[int], typecode: _IntTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ...
@overload
def __init__(self: array[float], typecode: _FloatTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ...
@overload
def __init__(self: array[Text], typecode: _UnicodeTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ...
@overload
def __init__(self, typecode: str, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ...
def append(self, __v: _T) -> None: ...
def buffer_info(self) -> Tuple[int, int]: ...
def byteswap(self) -> None: ...
def count(self, __v: Any) -> int: ...
def extend(self, __bb: Iterable[_T]) -> None: ...
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 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 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 __len__(self) -> int: ...
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
def __getitem__(self, s: slice) -> array[_T]: ...
@overload # type: ignore # Overrides MutableSequence
def __setitem__(self, i: int, o: _T) -> None: ...
@overload
def __setitem__(self, s: slice, o: array[_T]) -> None: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...
def __add__(self, x: array[_T]) -> array[_T]: ...
def __ge__(self, other: array[_T]) -> bool: ...
def __gt__(self, other: array[_T]) -> bool: ...
def __iadd__(self, x: array[_T]) -> array[_T]: ... # type: ignore # Overrides MutableSequence
def __imul__(self, n: int) -> array[_T]: ...
def __le__(self, other: array[_T]) -> bool: ...
def __lt__(self, other: array[_T]) -> bool: ...
def __mul__(self, n: int) -> array[_T]: ...
def __rmul__(self, n: int) -> array[_T]: ...
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

View File

@@ -0,0 +1,39 @@
import asyncore
import socket
import sys
from abc import abstractmethod
from typing import Optional, Sequence, Tuple, Union
class simple_producer:
def __init__(self, data: bytes, buffer_size: int = ...) -> None: ...
def more(self) -> bytes: ...
class async_chat(asyncore.dispatcher):
ac_in_buffer_size: int
ac_out_buffer_size: int
def __init__(self, sock: Optional[socket.socket] = ..., map: Optional[asyncore._maptype] = ...) -> None: ...
@abstractmethod
def collect_incoming_data(self, data: bytes) -> None: ...
@abstractmethod
def found_terminator(self) -> None: ...
def set_terminator(self, term: Union[bytes, int, None]) -> None: ...
def get_terminator(self) -> Union[bytes, int, None]: ...
def handle_read(self) -> None: ...
def handle_write(self) -> None: ...
def handle_close(self) -> None: ...
def push(self, data: bytes) -> None: ...
def push_with_producer(self, producer: simple_producer) -> None: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def close_when_done(self) -> None: ...
def initiate_send(self) -> None: ...
def discard_buffers(self) -> None: ...
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]: ...

View File

@@ -0,0 +1,119 @@
import sys
from _typeshed import FileDescriptorLike
from socket import SocketType
from typing import Any, Dict, Optional, Tuple, Union, overload
# cyclic dependence with asynchat
_maptype = Dict[int, Any]
socket_map: _maptype = ... # Undocumented
class ExitNow(Exception): ...
def read(obj: Any) -> None: ...
def write(obj: Any) -> None: ...
def readwrite(obj: Any, flags: int) -> None: ...
def poll(timeout: float = ..., map: Optional[_maptype] = ...) -> None: ...
def poll2(timeout: float = ..., map: Optional[_maptype] = ...) -> None: ...
poll3 = poll2
def loop(timeout: float = ..., use_poll: bool = ..., map: Optional[_maptype] = ..., count: Optional[int] = ...) -> None: ...
# Not really subclass of socket.socket; it's only delegation.
# It is not covariant to it.
class dispatcher:
debug: bool
connected: bool
accepting: bool
connecting: bool
closing: bool
ignore_log_types: frozenset[str]
socket: Optional[SocketType]
def __init__(self, sock: Optional[SocketType] = ..., map: Optional[_maptype] = ...) -> None: ...
def add_channel(self, map: Optional[_maptype] = ...) -> None: ...
def del_channel(self, map: Optional[_maptype] = ...) -> None: ...
def create_socket(self, family: int = ..., type: int = ...) -> None: ...
def set_socket(self, sock: SocketType, map: Optional[_maptype] = ...) -> None: ...
def set_reuse_addr(self) -> None: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def listen(self, num: int) -> None: ...
def bind(self, addr: Union[Tuple[Any, ...], str]) -> None: ...
def connect(self, address: Union[Tuple[Any, ...], str]) -> None: ...
def accept(self) -> Optional[Tuple[SocketType, Any]]: ...
def send(self, data: bytes) -> int: ...
def recv(self, buffer_size: int) -> bytes: ...
def close(self) -> None: ...
def log(self, message: Any) -> None: ...
def log_info(self, message: Any, type: str = ...) -> None: ...
def handle_read_event(self) -> None: ...
def handle_connect_event(self) -> None: ...
def handle_write_event(self) -> None: ...
def handle_expt_event(self) -> None: ...
def handle_error(self) -> None: ...
def handle_expt(self) -> None: ...
def handle_read(self) -> None: ...
def handle_write(self) -> None: ...
def handle_connect(self) -> None: ...
def handle_accept(self) -> None: ...
def handle_close(self) -> None: ...
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: ...
def initiate_send(self) -> None: ...
def handle_write(self) -> None: ...
# incompatible signature:
# def send(self, data: bytes) -> Optional[int]: ...
def compact_traceback() -> Tuple[Tuple[str, str, str], type, type, str]: ...
def close_all(map: Optional[_maptype] = ..., ignore_all: bool = ...) -> None: ...
if sys.platform != "win32":
class file_wrapper:
fd: int
def __init__(self, fd: int) -> None: ...
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
def send(self, data: bytes, flags: int = ...) -> int: ...
@overload
def getsockopt(self, level: int, optname: int, buflen: None = ...) -> int: ...
@overload
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
def read(self, bufsize: int, flags: int = ...) -> bytes: ...
def write(self, data: bytes, flags: int = ...) -> int: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
class file_dispatcher(dispatcher):
def __init__(self, fd: FileDescriptorLike, map: Optional[_maptype] = ...) -> None: ...
def set_file(self, fd: int) -> None: ...

View File

@@ -0,0 +1,42 @@
from typing import Optional, Tuple
AdpcmState = Tuple[int, int]
RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]]
class error(Exception): ...
def add(__fragment1: bytes, __fragment2: bytes, __width: int) -> bytes: ...
def adpcm2lin(__fragment: bytes, __width: int, __state: Optional[AdpcmState]) -> Tuple[bytes, AdpcmState]: ...
def alaw2lin(__fragment: bytes, __width: int) -> bytes: ...
def avg(__fragment: bytes, __width: int) -> int: ...
def avgpp(__fragment: bytes, __width: int) -> int: ...
def bias(__fragment: bytes, __width: int, __bias: int) -> bytes: ...
def byteswap(__fragment: bytes, __width: int) -> bytes: ...
def cross(__fragment: bytes, __width: int) -> int: ...
def findfactor(__fragment: bytes, __reference: bytes) -> float: ...
def findfit(__fragment: bytes, __reference: bytes) -> Tuple[int, float]: ...
def findmax(__fragment: bytes, __length: int) -> int: ...
def getsample(__fragment: bytes, __width: int, __index: int) -> int: ...
def lin2adpcm(__fragment: bytes, __width: int, __state: Optional[AdpcmState]) -> Tuple[bytes, AdpcmState]: ...
def lin2alaw(__fragment: bytes, __width: int) -> bytes: ...
def lin2lin(__fragment: bytes, __width: int, __newwidth: int) -> bytes: ...
def lin2ulaw(__fragment: bytes, __width: int) -> bytes: ...
def max(__fragment: bytes, __width: int) -> int: ...
def maxpp(__fragment: bytes, __width: int) -> int: ...
def minmax(__fragment: bytes, __width: int) -> Tuple[int, int]: ...
def mul(__fragment: bytes, __width: int, __factor: float) -> bytes: ...
def ratecv(
__fragment: bytes,
__width: int,
__nchannels: int,
__inrate: int,
__outrate: int,
__state: Optional[RatecvState],
__weightA: int = ...,
__weightB: int = ...,
) -> Tuple[bytes, RatecvState]: ...
def reverse(__fragment: bytes, __width: int) -> bytes: ...
def rms(__fragment: bytes, __width: int) -> int: ...
def tomono(__fragment: bytes, __width: int, __lfactor: float, __rfactor: float) -> bytes: ...
def tostereo(__fragment: bytes, __width: int, __lfactor: float, __rfactor: float) -> bytes: ...
def ulaw2lin(__fragment: bytes, __width: int) -> bytes: ...

View File

@@ -0,0 +1,41 @@
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]
def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ...
def b64decode(s: _decodable, altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ...
def standard_b64encode(s: _encodable) -> bytes: ...
def standard_b64decode(s: _decodable) -> bytes: ...
def urlsafe_b64encode(s: _encodable) -> bytes: ...
def urlsafe_b64decode(s: _decodable) -> bytes: ...
def b32encode(s: _encodable) -> bytes: ...
def b32decode(s: _decodable, casefold: bool = ..., map01: Optional[bytes] = ...) -> 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: ...

98
stdlib/@python2/bdb.pyi Normal file
View File

@@ -0,0 +1,98 @@
from types import CodeType, FrameType, TracebackType
from typing import IO, Any, Callable, Dict, Iterable, List, Mapping, Optional, Set, SupportsInt, Tuple, Type, TypeVar, Union
_T = TypeVar("_T")
_TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type
_ExcInfo = Tuple[Type[BaseException], BaseException, FrameType]
GENERATOR_AND_COROUTINE_FLAGS: int = ...
class BdbQuit(Exception): ...
class Bdb:
skip: Optional[Set[str]]
breaks: Dict[str, List[int]]
fncache: Dict[str, str]
frame_returning: Optional[FrameType]
botframe: Optional[FrameType]
quitting: bool
stopframe: Optional[FrameType]
returnframe: Optional[FrameType]
stoplineno: int
def __init__(self, skip: Optional[Iterable[str]] = ...) -> None: ...
def canonic(self, filename: str) -> str: ...
def reset(self) -> None: ...
def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ...
def dispatch_line(self, frame: FrameType) -> _TraceDispatch: ...
def dispatch_call(self, frame: FrameType, arg: None) -> _TraceDispatch: ...
def dispatch_return(self, frame: FrameType, arg: Any) -> _TraceDispatch: ...
def dispatch_exception(self, frame: FrameType, arg: _ExcInfo) -> _TraceDispatch: ...
def is_skipped_module(self, module_name: str) -> bool: ...
def stop_here(self, frame: FrameType) -> bool: ...
def break_here(self, frame: FrameType) -> bool: ...
def do_clear(self, arg: Any) -> Optional[bool]: ...
def break_anywhere(self, frame: FrameType) -> bool: ...
def user_call(self, frame: FrameType, argument_list: None) -> None: ...
def user_line(self, frame: FrameType) -> None: ...
def user_return(self, frame: FrameType, return_value: Any) -> None: ...
def user_exception(self, frame: FrameType, exc_info: _ExcInfo) -> None: ...
def set_until(self, frame: FrameType, lineno: Optional[int] = ...) -> None: ...
def set_step(self) -> None: ...
def set_next(self, frame: FrameType) -> None: ...
def set_return(self, frame: FrameType) -> None: ...
def set_trace(self, frame: Optional[FrameType] = ...) -> None: ...
def set_continue(self) -> None: ...
def set_quit(self) -> None: ...
def set_break(
self, filename: str, lineno: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ...
) -> None: ...
def clear_break(self, filename: str, lineno: int) -> None: ...
def clear_bpbynumber(self, arg: SupportsInt) -> None: ...
def clear_all_file_breaks(self, filename: str) -> None: ...
def clear_all_breaks(self) -> None: ...
def get_bpbynumber(self, arg: SupportsInt) -> Breakpoint: ...
def get_break(self, filename: str, lineno: int) -> bool: ...
def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ...
def get_file_breaks(self, filename: str) -> List[Breakpoint]: ...
def get_all_breaks(self) -> List[Breakpoint]: ...
def get_stack(self, f: Optional[FrameType], t: Optional[TracebackType]) -> Tuple[List[Tuple[FrameType, int]], int]: ...
def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ...
def run(
self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...
) -> None: ...
def runeval(self, expr: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ...
def runctx(
self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]]
) -> None: ...
def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ...
class Breakpoint:
next: int = ...
bplist: Dict[Tuple[str, int], List[Breakpoint]] = ...
bpbynumber: List[Optional[Breakpoint]] = ...
funcname: Optional[str]
func_first_executable_line: Optional[int]
file: str
line: int
temporary: bool
cond: Optional[str]
enabled: bool
ignore: int
hits: int
number: int
def __init__(
self, file: str, line: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ...
) -> None: ...
def deleteMe(self) -> None: ...
def enable(self) -> None: ...
def disable(self) -> None: ...
def bpprint(self, out: Optional[IO[str]] = ...) -> None: ...
def bpformat(self) -> str: ...
def __str__(self) -> str: ...
def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ...
def effective(file: str, line: int, frame: FrameType) -> Union[Tuple[Breakpoint, bool], Tuple[None, None]]: ...
def set_trace() -> None: ...

View File

@@ -0,0 +1,50 @@
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
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 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 a2b_qp(data: _Ascii, header: bool = ...) -> bytes: ...
def b2a_qp(data: _Bytes, quotetabs: bool = ..., istext: bool = ..., header: bool = ...) -> bytes: ...
def a2b_hqx(__data: _Ascii) -> bytes: ...
def rledecode_hqx(__data: _Bytes) -> bytes: ...
def rlecode_hqx(__data: _Bytes) -> bytes: ...
def b2a_hqx(__data: _Bytes) -> bytes: ...
def crc_hqx(__data: _Bytes, __crc: int) -> int: ...
def crc32(__data: _Bytes, __crc: int = ...) -> int: ...
def b2a_hex(__data: _Bytes) -> bytes: ...
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: ...
class Error(ValueError): ...
class Incomplete(Exception): ...

View File

@@ -0,0 +1,42 @@
from typing import IO, Any, Tuple, Union
class Error(Exception): ...
REASONABLY_LARGE: int
LINELEN: int
RUNCHAR: bytes
class FInfo:
def __init__(self) -> None: ...
Type: str
Creator: str
Flags: int
_FileInfoTuple = Tuple[str, FInfo, int, int]
_FileHandleUnion = Union[str, IO[bytes]]
def getfileinfo(name: str) -> _FileInfoTuple: ...
class openrsrc:
def __init__(self, *args: Any) -> None: ...
def read(self, *args: Any) -> bytes: ...
def write(self, *args: Any) -> None: ...
def close(self) -> None: ...
class BinHex:
def __init__(self, name_finfo_dlen_rlen: _FileInfoTuple, ofp: _FileHandleUnion) -> None: ...
def write(self, data: bytes) -> None: ...
def close_data(self) -> None: ...
def write_rsrc(self, data: bytes) -> None: ...
def close(self) -> None: ...
def binhex(inp: str, out: str) -> None: ...
class HexBin:
def __init__(self, ifp: _FileHandleUnion) -> None: ...
def read(self, *n: int) -> bytes: ...
def close_data(self) -> None: ...
def read_rsrc(self, *n: int) -> bytes: ...
def close(self) -> None: ...
def hexbin(inp: str, out: str) -> None: ...

View File

@@ -0,0 +1,4 @@
from _bisect import *
bisect = bisect_right
insort = insort_right

78
stdlib/@python2/bz2.pyi Normal file
View File

@@ -0,0 +1,78 @@
import io
import sys
from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer
from typing import IO, Any, Iterable, List, Optional, TextIO, TypeVar, Union, overload
from typing_extensions import Literal, SupportsIndex
_PathOrFile = Union[AnyPath, IO[bytes]]
_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 read(self, size: Optional[int] = ...) -> bytes: ...
def read1(self, size: int = ...) -> bytes: ...
def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore
def readinto(self, b: WriteableBuffer) -> int: ...
def readlines(self, size: SupportsIndex = ...) -> List[bytes]: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def write(self, data: ReadableBuffer) -> int: ...
def writelines(self, seq: Iterable[ReadableBuffer]) -> None: ...
class BZ2Compressor(object):
def __init__(self, compresslevel: int = ...) -> None: ...
def compress(self, __data: bytes) -> bytes: ...
def flush(self) -> bytes: ...
class BZ2Decompressor(object):
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: ...

View File

@@ -0,0 +1,33 @@
import sys
from _typeshed import AnyPath
from types import CodeType
from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union
def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
def runctx(
statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ...
) -> None: ...
_SelfT = TypeVar("_SelfT", bound=Profile)
_T = TypeVar("_T")
_Label = Tuple[str, int, str]
class Profile:
stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented
def __init__(
self, timer: Callable[[], float] = ..., timeunit: float = ..., subcalls: bool = ..., builtins: bool = ...
) -> None: ...
def enable(self) -> None: ...
def disable(self) -> None: ...
def print_stats(self, sort: Union[str, int] = ...) -> None: ...
def dump_stats(self, file: AnyPath) -> None: ...
def create_stats(self) -> None: ...
def snapshot_stats(self) -> None: ...
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

View File

@@ -0,0 +1,124 @@
import datetime
import sys
from time import struct_time
from typing import Any, Iterable, List, Optional, Sequence, Tuple, Union
_LocaleType = Tuple[Optional[str], Optional[str]]
class IllegalMonthError(ValueError):
def __init__(self, month: int) -> None: ...
def __str__(self) -> str: ...
class IllegalWeekdayError(ValueError):
def __init__(self, weekday: int) -> None: ...
def __str__(self) -> str: ...
def isleap(year: int) -> bool: ...
def leapdays(y1: int, y2: int) -> int: ...
def weekday(year: int, month: int, day: int) -> int: ...
def monthrange(year: int, month: int) -> Tuple[int, int]: ...
class Calendar:
firstweekday: int
def __init__(self, firstweekday: int = ...) -> None: ...
def getfirstweekday(self) -> int: ...
def setfirstweekday(self, firstweekday: int) -> None: ...
def iterweekdays(self) -> Iterable[int]: ...
def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ...
def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ...
def itermonthdays(self, year: int, month: int) -> Iterable[int]: ...
def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ...
def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ...
def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ...
def yeardatescalendar(self, year: int, width: int = ...) -> List[List[int]]: ...
def yeardays2calendar(self, year: int, width: int = ...) -> List[List[Tuple[int, int]]]: ...
def yeardayscalendar(self, year: int, width: int = ...) -> List[List[int]]: ...
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: ...
def formatweek(self, theweek: int, width: int) -> str: ...
def formatweekday(self, day: int, width: int) -> str: ...
def formatweekheader(self, width: int) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
def prmonth(self, theyear: int, themonth: int, w: int = ..., l: int = ...) -> None: ...
def formatmonth(self, theyear: int, themonth: int, w: int = ..., l: int = ...) -> str: ...
def formatyear(self, theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> str: ...
def pryear(self, theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> None: ...
def firstweekday() -> int: ...
def monthcalendar(year: int, month: int) -> List[List[int]]: ...
def prweek(theweek: int, width: int) -> None: ...
def week(theweek: int, width: int) -> str: ...
def weekheader(width: int) -> str: ...
def prmonth(theyear: int, themonth: int, w: int = ..., l: int = ...) -> None: ...
def month(theyear: int, themonth: int, w: int = ..., l: int = ...) -> str: ...
def calendar(theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> str: ...
def prcal(theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> None: ...
class HTMLCalendar(Calendar):
def formatday(self, day: int, weekday: int) -> str: ...
def formatweek(self, theweek: int) -> str: ...
def formatweekday(self, day: int) -> str: ...
def formatweekheader(self) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
def formatyear(self, theyear: int, width: int = ...) -> str: ...
def formatyearpage(self, theyear: int, width: int = ..., css: 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 LocaleTextCalendar(TextCalendar):
def __init__(self, firstweekday: int = ..., locale: Optional[_LocaleType] = ...) -> None: ...
def formatweekday(self, day: int, width: int) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
class LocaleHTMLCalendar(HTMLCalendar):
def __init__(self, firstweekday: int = ..., locale: Optional[_LocaleType] = ...) -> None: ...
def formatweekday(self, day: int) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
c: TextCalendar
def setfirstweekday(firstweekday: int) -> None: ...
def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
def timegm(tuple: Union[Tuple[int, ...], struct_time]) -> int: ...
# Data attributes
day_name: Sequence[str]
day_abbr: Sequence[str]
month_name: Sequence[str]
month_abbr: Sequence[str]
# Below constants are not in docs or __all__, but enough people have used them
# they are now effectively public.
MONDAY: int
TUESDAY: int
WEDNESDAY: int
THURSDAY: int
FRIDAY: int
SATURDAY: int
SUNDAY: int

33
stdlib/@python2/cgitb.pyi Normal file
View File

@@ -0,0 +1,33 @@
from _typeshed import AnyPath
from types import FrameType, TracebackType
from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type
_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
def reset() -> str: ... # undocumented
def small(text: str) -> str: ... # undocumented
def strong(text: str) -> str: ... # undocumented
def grey(text: str) -> str: ... # undocumented
def lookup(name: str, frame: FrameType, locals: Dict[str, Any]) -> Tuple[Optional[str], Any]: ... # undocumented
def scanvars(
reader: Callable[[], bytes], frame: FrameType, locals: Dict[str, Any]
) -> List[Tuple[str, Optional[str], Any]]: ... # undocumented
def html(einfo: _ExcInfo, context: int = ...) -> str: ...
def text(einfo: _ExcInfo, context: int = ...) -> str: ...
class Hook: # undocumented
def __init__(
self,
display: int = ...,
logdir: Optional[AnyPath] = ...,
context: int = ...,
file: Optional[IO[str]] = ...,
format: str = ...,
) -> None: ...
def __call__(
self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType]
) -> None: ...
def handle(self, info: Optional[_ExcInfo] = ...) -> None: ...
def handler(info: Optional[_ExcInfo] = ...) -> None: ...
def enable(display: int = ..., logdir: Optional[AnyPath] = ..., context: int = ..., format: str = ...) -> None: ...

20
stdlib/@python2/chunk.pyi Normal file
View File

@@ -0,0 +1,20 @@
from typing import IO
class Chunk:
closed: bool
align: bool
file: IO[bytes]
chunkname: bytes
chunksize: int
size_read: int
offset: int
seekable: bool
def __init__(self, file: IO[bytes], align: bool = ..., bigendian: bool = ..., inclheader: bool = ...) -> None: ...
def getname(self) -> bytes: ...
def getsize(self) -> int: ...
def close(self) -> None: ...
def isatty(self) -> bool: ...
def seek(self, pos: int, whence: int = ...) -> None: ...
def tell(self) -> int: ...
def read(self, size: int = ...) -> bytes: ...
def skip(self) -> None: ...

42
stdlib/@python2/cmath.pyi Normal file
View File

@@ -0,0 +1,42 @@
import sys
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: ...
def acosh(__z: _C) -> complex: ...
def asin(__z: _C) -> complex: ...
def asinh(__z: _C) -> complex: ...
def atan(__z: _C) -> complex: ...
def atanh(__z: _C) -> complex: ...
def cos(__z: _C) -> complex: ...
def cosh(__z: _C) -> complex: ...
def exp(__z: _C) -> complex: ...
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: ...
def log10(__z: _C) -> complex: ...
def phase(__z: _C) -> float: ...
def polar(__z: _C) -> Tuple[float, float]: ...
def rect(__r: float, __phi: float) -> complex: ...
def sin(__z: _C) -> complex: ...
def sinh(__z: _C) -> complex: ...
def sqrt(__z: _C) -> complex: ...
def tan(__z: _C) -> complex: ...
def tanh(__z: _C) -> complex: ...
if sys.version_info >= (3,):
def isfinite(__z: _C) -> bool: ...

39
stdlib/@python2/cmd.pyi Normal file
View File

@@ -0,0 +1,39 @@
from typing import IO, Any, Callable, List, Optional, Tuple
class Cmd:
prompt: str
identchars: str
ruler: str
lastcmd: str
intro: Optional[Any]
doc_leader: str
doc_header: str
misc_header: str
undoc_header: str
nohelp: str
use_rawinput: bool
stdin: IO[str]
stdout: IO[str]
cmdqueue: List[str]
completekey: str
def __init__(self, completekey: str = ..., stdin: Optional[IO[str]] = ..., stdout: Optional[IO[str]] = ...) -> None: ...
old_completer: Optional[Callable[[str, int], Optional[str]]]
def cmdloop(self, intro: Optional[Any] = ...) -> None: ...
def precmd(self, line: str) -> str: ...
def postcmd(self, stop: bool, line: str) -> bool: ...
def preloop(self) -> None: ...
def postloop(self) -> None: ...
def parseline(self, line: str) -> Tuple[Optional[str], Optional[str], str]: ...
def onecmd(self, line: str) -> bool: ...
def emptyline(self) -> bool: ...
def default(self, line: str) -> bool: ...
def completedefault(self, *ignored: Any) -> List[str]: ...
def completenames(self, text: str, *ignored: Any) -> List[str]: ...
completion_matches: Optional[List[str]]
def complete(self, text: str, state: int) -> Optional[List[str]]: ...
def get_names(self) -> List[str]: ...
# Only the first element of args matters.
def complete_help(self, *args: Any) -> List[str]: ...
def do_help(self, arg: str) -> Optional[bool]: ...
def print_topics(self, header: str, cmds: Optional[List[str]], cmdlen: Any, maxcol: int) -> None: ...
def columnize(self, list: Optional[List[str]], displaywidth: int = ...) -> None: ...

36
stdlib/@python2/code.pyi Normal file
View File

@@ -0,0 +1,36 @@
import sys
from types import CodeType
from typing import Any, Callable, Mapping, Optional
class InteractiveInterpreter:
def __init__(self, locals: Optional[Mapping[str, Any]] = ...) -> None: ...
def runsource(self, source: str, filename: str = ..., symbol: str = ...) -> bool: ...
def runcode(self, code: CodeType) -> None: ...
def showsyntaxerror(self, filename: Optional[str] = ...) -> None: ...
def showtraceback(self) -> None: ...
def write(self, data: str) -> None: ...
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 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 compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ...

304
stdlib/@python2/codecs.pyi Normal file
View File

@@ -0,0 +1,304 @@
import sys
import types
from abc import abstractmethod
from typing import (
IO,
Any,
BinaryIO,
Callable,
Generator,
Iterable,
Iterator,
List,
Optional,
Protocol,
Text,
TextIO,
Tuple,
Type,
TypeVar,
Union,
overload,
)
from typing_extensions import Literal
# TODO: this only satisfies the most common interface, where
# bytes (py2 str) is the raw form and str (py2 unicode) is the cooked form.
# In the long run, both should become template parameters maybe?
# There *are* bytes->bytes and str->str encodings in the standard library.
# They are much more common in Python 2 than in Python 3.
_Decoded = Text
_Encoded = bytes
class _Encoder(Protocol):
def __call__(self, input: _Decoded, errors: str = ...) -> Tuple[_Encoded, int]: ... # signature of Codec().encode
class _Decoder(Protocol):
def __call__(self, input: _Encoded, errors: str = ...) -> Tuple[_Decoded, int]: ... # signature of Codec().decode
class _StreamReader(Protocol):
def __call__(self, stream: IO[_Encoded], errors: str = ...) -> StreamReader: ...
class _StreamWriter(Protocol):
def __call__(self, stream: IO[_Encoded], errors: str = ...) -> StreamWriter: ...
class _IncrementalEncoder(Protocol):
def __call__(self, errors: str = ...) -> IncrementalEncoder: ...
class _IncrementalDecoder(Protocol):
def __call__(self, errors: str = ...) -> IncrementalDecoder: ...
# The type ignore on `encode` and `decode` is to avoid issues with overlapping overloads, for more details, see #300
# mypy and pytype disagree about where the type ignore can and cannot go, so alias the long type
_BytesToBytesEncodingT = Literal[
"base64",
"base_64",
"base64_codec",
"bz2",
"bz2_codec",
"hex",
"hex_codec",
"quopri",
"quotedprintable",
"quoted_printable",
"quopri_codec",
"uu",
"uu_codec",
"zip",
"zlib",
"zlib_codec",
]
@overload
def encode(obj: bytes, encoding: _BytesToBytesEncodingT, errors: str = ...) -> bytes: ...
@overload
def encode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = ...) -> str: ... # type: ignore
@overload
def encode(obj: _Decoded, encoding: str = ..., errors: str = ...) -> _Encoded: ...
@overload
def decode(obj: bytes, encoding: _BytesToBytesEncodingT, errors: str = ...) -> bytes: ... # type: ignore
@overload
def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = ...) -> Text: ...
@overload
def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ...
def lookup(__encoding: str) -> CodecInfo: ...
def utf_16_be_decode(
__data: _Encoded, __errors: Optional[str] = ..., __final: bool = ...
) -> Tuple[_Decoded, int]: ... # undocumented
def utf_16_be_encode(__str: _Decoded, __errors: Optional[str] = ...) -> Tuple[_Encoded, int]: ... # undocumented
class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
@property
def encode(self) -> _Encoder: ...
@property
def decode(self) -> _Decoder: ...
@property
def streamreader(self) -> _StreamReader: ...
@property
def streamwriter(self) -> _StreamWriter: ...
@property
def incrementalencoder(self) -> _IncrementalEncoder: ...
@property
def incrementaldecoder(self) -> _IncrementalDecoder: ...
name: str
def __new__(
cls,
encode: _Encoder,
decode: _Decoder,
streamreader: Optional[_StreamReader] = ...,
streamwriter: Optional[_StreamWriter] = ...,
incrementalencoder: Optional[_IncrementalEncoder] = ...,
incrementaldecoder: Optional[_IncrementalDecoder] = ...,
name: Optional[str] = ...,
*,
_is_text_encoding: Optional[bool] = ...,
) -> CodecInfo: ...
def getencoder(encoding: str) -> _Encoder: ...
def getdecoder(encoding: str) -> _Decoder: ...
def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
def getreader(encoding: str) -> _StreamReader: ...
def getwriter(encoding: str) -> _StreamWriter: ...
def register(__search_function: Callable[[str], Optional[CodecInfo]]) -> None: ...
def open(
filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., buffering: int = ...
) -> StreamReaderWriter: ...
def EncodedFile(
file: IO[_Encoded], data_encoding: str, file_encoding: Optional[str] = ..., errors: str = ...
) -> StreamRecoder: ...
def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ...
def iterdecode(iterator: Iterable[_Encoded], encoding: str, errors: str = ...) -> Generator[_Decoded, None, None]: ...
BOM: bytes
BOM_BE: bytes
BOM_LE: bytes
BOM_UTF8: bytes
BOM_UTF16: bytes
BOM_UTF16_BE: bytes
BOM_UTF16_LE: bytes
BOM_UTF32: bytes
BOM_UTF32_BE: bytes
BOM_UTF32_LE: bytes
# It is expected that different actions be taken depending on which of the
# three subclasses of `UnicodeError` is actually ...ed. However, the Union
# is still needed for at least one of the cases.
def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[Union[str, bytes], int]]) -> None: ...
def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[Union[str, bytes], int]]: ...
def strict_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def replace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def ignore_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def backslashreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
class Codec:
# These are sort of @abstractmethod but sort of not.
# The StreamReader and StreamWriter subclasses only implement one.
def encode(self, input: _Decoded, errors: str = ...) -> Tuple[_Encoded, int]: ...
def decode(self, input: _Encoded, errors: str = ...) -> Tuple[_Decoded, int]: ...
class IncrementalEncoder:
errors: str
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ...
def reset(self) -> None: ...
# documentation says int but str is needed for the subclass.
def getstate(self) -> Union[int, _Decoded]: ...
def setstate(self, state: Union[int, _Decoded]) -> None: ...
class IncrementalDecoder:
errors: str
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ...
def reset(self) -> None: ...
def getstate(self) -> Tuple[_Encoded, int]: ...
def setstate(self, state: Tuple[_Encoded, int]) -> None: ...
# These are not documented but used in encodings/*.py implementations.
class BufferedIncrementalEncoder(IncrementalEncoder):
buffer: str
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def _buffer_encode(self, input: _Decoded, errors: str, final: bool) -> _Encoded: ...
def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ...
class BufferedIncrementalDecoder(IncrementalDecoder):
buffer: bytes
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def _buffer_decode(self, input: _Encoded, errors: str, final: bool) -> Tuple[_Decoded, int]: ...
def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ...
_SW = TypeVar("_SW", bound=StreamWriter)
# TODO: it is not possible to specify the requirement that all other
# attributes and methods are passed-through from the stream.
class StreamWriter(Codec):
errors: str
def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ...
def write(self, object: _Decoded) -> None: ...
def writelines(self, list: Iterable[_Decoded]) -> None: ...
def reset(self) -> None: ...
def __enter__(self: _SW) -> _SW: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
_SR = TypeVar("_SR", bound=StreamReader)
class StreamReader(Codec):
errors: str
def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ...
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _Decoded: ...
def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> _Decoded: ...
def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[_Decoded]: ...
def reset(self) -> None: ...
def __enter__(self: _SR) -> _SR: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __iter__(self) -> Iterator[_Decoded]: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
_T = TypeVar("_T", bound=StreamReaderWriter)
# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing
# and delegates attributes to the underlying binary stream with __getattr__.
class StreamReaderWriter(TextIO):
def __init__(self, stream: IO[_Encoded], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ...
def read(self, size: int = ...) -> _Decoded: ...
def readline(self, size: 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 __iter__(self: _T) -> _T: ...
# This actually returns None, but that's incompatible with the supertype
def write(self, data: _Decoded) -> int: ...
def writelines(self, list: Iterable[_Decoded]) -> None: ...
def reset(self) -> None: ...
# Same as write()
def seek(self, offset: int, whence: int = ...) -> int: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __getattr__(self, name: str) -> Any: ...
# These methods don't actually exist directly, but they are needed to satisfy the TextIO
# interface. At runtime, they are delegated through __getattr__.
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def writable(self) -> bool: ...
_SRT = TypeVar("_SRT", bound=StreamRecoder)
class StreamRecoder(BinaryIO):
def __init__(
self,
stream: IO[_Encoded],
encode: _Encoder,
decode: _Decoder,
Reader: _StreamReader,
Writer: _StreamWriter,
errors: str = ...,
) -> None: ...
def read(self, size: int = ...) -> bytes: ...
def readline(self, size: 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 __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
def reset(self) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __enter__(self: _SRT) -> _SRT: ...
def __exit__(
self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO
# interface. At runtime, they are delegated through __getattr__.
def seek(self, offset: int, whence: int = ...) -> int: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def writable(self) -> bool: ...

View File

@@ -0,0 +1,14 @@
from types import CodeType
from typing import Optional
def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ...
class Compile:
flags: int
def __init__(self) -> None: ...
def __call__(self, source: str, filename: str, symbol: str) -> CodeType: ...
class CommandCompiler:
compiler: Compile
def __init__(self) -> None: ...
def __call__(self, source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ...

View File

@@ -0,0 +1,13 @@
from typing import Tuple
def rgb_to_yiq(r: float, g: float, b: float) -> Tuple[float, float, float]: ...
def yiq_to_rgb(y: float, i: float, q: float) -> Tuple[float, float, float]: ...
def rgb_to_hls(r: float, g: float, b: float) -> Tuple[float, float, float]: ...
def hls_to_rgb(h: float, l: float, s: float) -> Tuple[float, float, float]: ...
def rgb_to_hsv(r: float, g: float, b: float) -> Tuple[float, float, float]: ...
def hsv_to_rgb(h: float, s: float, v: float) -> Tuple[float, float, float]: ...
# TODO undocumented
ONE_SIXTH: float
ONE_THIRD: float
TWO_THIRD: float

View File

@@ -0,0 +1,115 @@
import sys
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]])
_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]]: ...
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: ...
_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]: ...

14
stdlib/@python2/copy.pyi Normal file
View File

@@ -0,0 +1,14 @@
from typing import Any, Dict, Optional, TypeVar
_T = TypeVar("_T")
# None in CPython but non-None in Jython
PyStringMap: Any
# Note: memo and _nil are internal kwargs.
def deepcopy(x: _T, memo: Optional[Dict[int, Any]] = ..., _nil: Any = ...) -> _T: ...
def copy(x: _T) -> _T: ...
class Error(Exception): ...
error = Error

View File

@@ -0,0 +1,16 @@
from typing import Any, Callable, Hashable, List, Optional, SupportsInt, Tuple, TypeVar, Union
_TypeT = TypeVar("_TypeT", bound=type)
_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]]
__all__: List[str]
def pickle(
ob_type: _TypeT,
pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]],
constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ...,
) -> None: ...
def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ...
def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ...
def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ...
def clear_extension_cache() -> None: ...

22
stdlib/@python2/crypt.pyi Normal file
View File

@@ -0,0 +1,22 @@
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: ...

110
stdlib/@python2/csv.pyi Normal file
View File

@@ -0,0 +1,110 @@
import sys
from _csv import (
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Dialect as Dialect,
Error as Error,
_DialectLike,
_reader,
_writer,
field_size_limit as field_size_limit,
get_dialect as get_dialect,
list_dialects as list_dialects,
reader as reader,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
writer as writer,
)
from 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
_T = TypeVar("_T")
class excel(Dialect):
delimiter: str
quotechar: str
doublequote: bool
skipinitialspace: bool
lineterminator: str
quoting: int
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]
restval: Optional[str]
reader: _reader
dialect: _DialectLike
line_num: int
@overload
def __init__(
self,
f: Iterable[Text],
fieldnames: Sequence[_T],
restkey: Optional[str] = ...,
restval: Optional[str] = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
) -> None: ...
@overload
def __init__(
self: DictReader[str],
f: Iterable[Text],
fieldnames: Optional[Sequence[str]] = ...,
restkey: Optional[str] = ...,
restval: Optional[str] = ...,
dialect: _DialectLike = ...,
*args: Any,
**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]: ...
class DictWriter(Generic[_T]):
fieldnames: Sequence[_T]
restval: Optional[Any]
extrasaction: str
writer: _writer
def __init__(
self,
f: Any,
fieldnames: Sequence[_T],
restval: Optional[Any] = ...,
extrasaction: str = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
) -> 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: ...
class Sniffer(object):
preferred: List[str]
def __init__(self) -> None: ...
def sniff(self, sample: str, delimiters: Optional[str] = ...) -> Type[Dialect]: ...
def has_header(self, sample: str) -> bool: ...

View File

@@ -0,0 +1,319 @@
import sys
from array import array
from typing import (
Any,
Callable,
ClassVar,
Generic,
Iterable,
Iterator,
List,
Mapping,
Optional,
Sequence,
Text,
Tuple,
Type,
TypeVar,
Union as _UnionT,
overload,
)
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T")
_DLLT = TypeVar("_DLLT", bound=CDLL)
_CT = TypeVar("_CT", bound=_CData)
RTLD_GLOBAL: int = ...
RTLD_LOCAL: int = ...
DEFAULT_MODE: int = ...
class CDLL(object):
_func_flags_: ClassVar[int] = ...
_func_restype_: ClassVar[_CData] = ...
_name: str = ...
_handle: int = ...
_FuncPtr: Type[_FuncPointer] = ...
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: ...
if sys.platform == "win32":
class OleDLL(CDLL): ...
class WinDLL(CDLL): ...
class PyDLL(CDLL): ...
class LibraryLoader(Generic[_DLLT]):
def __init__(self, dlltype: Type[_DLLT]) -> None: ...
def __getattr__(self, name: str) -> _DLLT: ...
def __getitem__(self, name: str) -> _DLLT: ...
def LoadLibrary(self, name: str) -> _DLLT: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
cdll: LibraryLoader[CDLL] = ...
if sys.platform == "win32":
windll: LibraryLoader[WinDLL] = ...
oledll: LibraryLoader[OleDLL] = ...
pydll: LibraryLoader[PyDLL] = ...
pythonapi: PyDLL = ...
# Anything that implements the read-write buffer interface.
# The buffer interface is defined purely on the C level, so we cannot define a normal Protocol
# for it. Instead we have to list the most common stdlib buffer classes in a Union.
_WritableBuffer = _UnionT[bytearray, memoryview, array[Any], _CData]
# Same as _WritableBuffer, but also includes read-only buffer types (like bytes).
_ReadOnlyBuffer = _UnionT[_WritableBuffer, bytes]
class _CDataMeta(type):
# By default mypy complains about the following two methods, because strictly speaking cls
# might not be a Type[_CT]. However this can never actually happen, because the only class that
# uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here.
def __mul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore
def __rmul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore
class _CData(metaclass=_CDataMeta):
_b_base: int = ...
_b_needsfree_: bool = ...
_objects: Optional[Mapping[Any, int]] = ...
@classmethod
def from_buffer(cls: Type[_CT], source: _WritableBuffer, offset: int = ...) -> _CT: ...
@classmethod
def from_buffer_copy(cls: Type[_CT], source: _ReadOnlyBuffer, offset: int = ...) -> _CT: ...
@classmethod
def from_address(cls: Type[_CT], address: int) -> _CT: ...
@classmethod
def from_param(cls: Type[_CT], obj: Any) -> _UnionT[_CT, _CArgObject]: ...
@classmethod
def in_dll(cls: Type[_CT], library: CDLL, name: str) -> _CT: ...
class _CanCastTo(_CData): ...
class _PointerLike(_CanCastTo): ...
_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData]
_PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]]
class _FuncPointer(_PointerLike, _CData):
restype: _UnionT[Type[_CData], Callable[[int], Any], None] = ...
argtypes: Sequence[Type[_CData]] = ...
errcheck: _ECT = ...
@overload
def __init__(self, address: int) -> None: ...
@overload
def __init__(self, callable: Callable[..., Any]) -> None: ...
@overload
def __init__(self, func_spec: Tuple[_UnionT[str, int], CDLL], paramflags: Tuple[_PF, ...] = ...) -> None: ...
@overload
def __init__(self, vtlb_index: int, name: str, paramflags: Tuple[_PF, ...] = ..., iid: pointer[c_int] = ...) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class _NamedFuncPointer(_FuncPointer):
__name__: str
class ArgumentError(Exception): ...
def CFUNCTYPE(
restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ...
) -> Type[_FuncPointer]: ...
if sys.platform == "win32":
def WINFUNCTYPE(
restype: Optional[Type[_CData]], *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ...
) -> Type[_FuncPointer]: ...
def PYFUNCTYPE(restype: Optional[Type[_CData]], *argtypes: Type[_CData]) -> Type[_FuncPointer]: ...
class _CArgObject: ...
# Any type that can be implicitly converted to c_void_p when passed as a C function argument.
# (bytes is not included here, see below.)
_CVoidPLike = _UnionT[_PointerLike, Array[Any], _CArgObject, int]
# Same as above, but including types known to be read-only (i. e. bytes).
# This distinction is not strictly necessary (ctypes doesn't differentiate between const
# and non-const pointers), but it catches errors like memmove(b'foo', buf, 4)
# when memmove(buf, b'foo', 4) was intended.
_CVoidConstPLike = _UnionT[_CVoidPLike, bytes]
def addressof(obj: _CData) -> int: ...
def alignment(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
_CastT = TypeVar("_CastT", bound=_CanCastTo)
def cast(obj: _UnionT[_CData, _CArgObject, int], typ: Type[_CastT]) -> _CastT: ...
def create_string_buffer(init: _UnionT[int, bytes], size: Optional[int] = ...) -> Array[c_char]: ...
c_buffer = create_string_buffer
def create_unicode_buffer(init: _UnionT[int, Text], size: Optional[int] = ...) -> Array[c_wchar]: ...
if sys.platform == "win32":
def DllCanUnloadNow() -> int: ...
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented
def FormatError(code: int) -> str: ...
def GetLastError() -> int: ...
def get_errno() -> int: ...
if sys.platform == "win32":
def get_last_error() -> int: ...
def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> None: ...
def memset(dst: _CVoidPLike, c: int, count: int) -> None: ...
def POINTER(type: Type[_CT]) -> Type[pointer[_CT]]: ...
# The real ctypes.pointer is a function, not a class. The stub version of pointer behaves like
# ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer,
# it can be instantiated directly (to mimic the behavior of the real pointer function).
class pointer(Generic[_CT], _PointerLike, _CData):
_type_: ClassVar[Type[_CT]] = ...
contents: _CT = ...
def __init__(self, arg: _CT = ...) -> None: ...
@overload
def __getitem__(self, i: int) -> _CT: ...
@overload
def __getitem__(self, s: slice) -> List[_CT]: ...
@overload
def __setitem__(self, i: int, o: _CT) -> None: ...
@overload
def __setitem__(self, s: slice, o: Iterable[_CT]) -> None: ...
def resize(obj: _CData, size: int) -> None: ...
if sys.version_info < (3,):
def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ...
def set_errno(value: int) -> int: ...
if sys.platform == "win32":
def set_last_error(value: int) -> int: ...
def sizeof(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ...
if sys.platform == "win32":
def WinError(code: Optional[int] = ..., descr: Optional[str] = ...) -> OSError: ...
def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ...
class _SimpleCData(Generic[_T], _CData):
value: _T = ...
def __init__(self, value: _T = ...) -> None: ...
class c_byte(_SimpleCData[int]): ...
class c_char(_SimpleCData[bytes]):
def __init__(self, value: _UnionT[int, bytes] = ...) -> None: ...
class c_char_p(_PointerLike, _SimpleCData[Optional[bytes]]):
def __init__(self, value: Optional[_UnionT[int, bytes]] = ...) -> None: ...
class c_double(_SimpleCData[float]): ...
class c_longdouble(_SimpleCData[float]): ...
class c_float(_SimpleCData[float]): ...
class c_int(_SimpleCData[int]): ...
class c_int8(_SimpleCData[int]): ...
class c_int16(_SimpleCData[int]): ...
class c_int32(_SimpleCData[int]): ...
class c_int64(_SimpleCData[int]): ...
class c_long(_SimpleCData[int]): ...
class c_longlong(_SimpleCData[int]): ...
class c_short(_SimpleCData[int]): ...
class c_size_t(_SimpleCData[int]): ...
class c_ssize_t(_SimpleCData[int]): ...
class c_ubyte(_SimpleCData[int]): ...
class c_uint(_SimpleCData[int]): ...
class c_uint8(_SimpleCData[int]): ...
class c_uint16(_SimpleCData[int]): ...
class c_uint32(_SimpleCData[int]): ...
class c_uint64(_SimpleCData[int]): ...
class c_ulong(_SimpleCData[int]): ...
class c_ulonglong(_SimpleCData[int]): ...
class c_ushort(_SimpleCData[int]): ...
class c_void_p(_PointerLike, _SimpleCData[Optional[int]]): ...
class c_wchar(_SimpleCData[Text]): ...
class c_wchar_p(_PointerLike, _SimpleCData[Optional[Text]]):
def __init__(self, value: Optional[_UnionT[int, Text]] = ...) -> None: ...
class c_bool(_SimpleCData[bool]):
def __init__(self, value: bool = ...) -> None: ...
if sys.platform == "win32":
class HRESULT(_SimpleCData[int]): ... # TODO undocumented
class py_object(_CanCastTo, _SimpleCData[_T]): ...
class _CField:
offset: int = ...
size: int = ...
class _StructUnionMeta(_CDataMeta):
_fields_: Sequence[_UnionT[Tuple[str, Type[_CData]], Tuple[str, Type[_CData], int]]] = ...
_pack_: int = ...
_anonymous_: Sequence[str] = ...
def __getattr__(self, name: str) -> _CField: ...
class _StructUnionBase(_CData, metaclass=_StructUnionMeta):
def __init__(self, *args: Any, **kw: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
class Union(_StructUnionBase): ...
class Structure(_StructUnionBase): ...
class BigEndianStructure(Structure): ...
class LittleEndianStructure(Structure): ...
class Array(Generic[_CT], _CData):
_length_: ClassVar[int] = ...
_type_: ClassVar[Type[_CT]] = ...
raw: bytes = ... # Note: only available if _CT == c_char
value: Any = ... # Note: bytes if _CT == c_char, Text if _CT == c_wchar, unavailable otherwise
# TODO These methods cannot be annotated correctly at the moment.
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
# here, because of a special feature of ctypes.
# By default, when accessing an element of an Array[_CT], the returned object has type _CT.
# However, when _CT is a "simple type" like c_int, ctypes automatically "unboxes" the object
# and converts it to the corresponding Python primitive. For example, when accessing an element
# of an Array[c_int], a Python int object is returned, not a c_int.
# This behavior does *not* apply to subclasses of "simple types".
# If MyInt is a subclass of c_int, then accessing an element of an Array[MyInt] returns
# a MyInt, not an int.
# This special behavior is not easy to model in a stub, so for now all places where
# the array element type would belong are annotated with Any instead.
def __init__(self, *args: Any) -> None: ...
@overload
def __getitem__(self, i: int) -> Any: ...
@overload
def __getitem__(self, s: slice) -> List[Any]: ...
@overload
def __setitem__(self, i: int, o: Any) -> None: ...
@overload
def __setitem__(self, s: slice, o: Iterable[Any]) -> None: ...
def __iter__(self) -> Iterator[Any]: ...
# Can't inherit from Sized because the metaclass conflict between
# Sized and _CData prevents using _CDataMeta.
def __len__(self) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

View File

@@ -0,0 +1,7 @@
import sys
from typing import Optional
def find_library(name: str) -> Optional[str]: ...
if sys.platform == "win32":
def find_msvcrt() -> Optional[str]: ...

View File

@@ -0,0 +1,234 @@
from ctypes import (
Array,
Structure,
_SimpleCData,
c_byte,
c_char,
c_char_p,
c_double,
c_float,
c_int,
c_long,
c_longlong,
c_short,
c_uint,
c_ulong,
c_ulonglong,
c_ushort,
c_void_p,
c_wchar,
c_wchar_p,
pointer,
)
BYTE = c_byte
WORD = c_ushort
DWORD = c_ulong
CHAR = c_char
WCHAR = c_wchar
UINT = c_uint
INT = c_int
DOUBLE = c_double
FLOAT = c_float
BOOLEAN = BYTE
BOOL = c_long
class VARIANT_BOOL(_SimpleCData[bool]): ...
ULONG = c_ulong
LONG = c_long
USHORT = c_ushort
SHORT = c_short
LARGE_INTEGER = c_longlong
_LARGE_INTEGER = c_longlong
ULARGE_INTEGER = c_ulonglong
_ULARGE_INTEGER = c_ulonglong
OLESTR = c_wchar_p
LPOLESTR = c_wchar_p
LPCOLESTR = c_wchar_p
LPWSTR = c_wchar_p
LPCWSTR = c_wchar_p
LPSTR = c_char_p
LPCSTR = c_char_p
LPVOID = c_void_p
LPCVOID = c_void_p
# These two types are pointer-sized unsigned and signed ints, respectively.
# At runtime, they are either c_[u]long or c_[u]longlong, depending on the host's pointer size
# (they are not really separate classes).
class WPARAM(_SimpleCData[int]): ...
class LPARAM(_SimpleCData[int]): ...
ATOM = WORD
LANGID = WORD
COLORREF = DWORD
LGRPID = DWORD
LCTYPE = DWORD
LCID = DWORD
HANDLE = c_void_p
HACCEL = HANDLE
HBITMAP = HANDLE
HBRUSH = HANDLE
HCOLORSPACE = HANDLE
HDC = HANDLE
HDESK = HANDLE
HDWP = HANDLE
HENHMETAFILE = HANDLE
HFONT = HANDLE
HGDIOBJ = HANDLE
HGLOBAL = HANDLE
HHOOK = HANDLE
HICON = HANDLE
HINSTANCE = HANDLE
HKEY = HANDLE
HKL = HANDLE
HLOCAL = HANDLE
HMENU = HANDLE
HMETAFILE = HANDLE
HMODULE = HANDLE
HMONITOR = HANDLE
HPALETTE = HANDLE
HPEN = HANDLE
HRGN = HANDLE
HRSRC = HANDLE
HSTR = HANDLE
HTASK = HANDLE
HWINSTA = HANDLE
HWND = HANDLE
SC_HANDLE = HANDLE
SERVICE_STATUS_HANDLE = HANDLE
class RECT(Structure):
left: LONG
top: LONG
right: LONG
bottom: LONG
RECTL = RECT
_RECTL = RECT
tagRECT = RECT
class _SMALL_RECT(Structure):
Left: SHORT
Top: SHORT
Right: SHORT
Bottom: SHORT
SMALL_RECT = _SMALL_RECT
class _COORD(Structure):
X: SHORT
Y: SHORT
class POINT(Structure):
x: LONG
y: LONG
POINTL = POINT
_POINTL = POINT
tagPOINT = POINT
class SIZE(Structure):
cx: LONG
cy: LONG
SIZEL = SIZE
tagSIZE = SIZE
def RGB(red: int, green: int, blue: int) -> int: ...
class FILETIME(Structure):
dwLowDateTime: DWORD
dwHighDateTime: DWORD
_FILETIME = FILETIME
class MSG(Structure):
hWnd: HWND
message: UINT
wParam: WPARAM
lParam: LPARAM
time: DWORD
pt: POINT
tagMSG = MSG
MAX_PATH: int
class WIN32_FIND_DATAA(Structure):
dwFileAttributes: DWORD
ftCreationTime: FILETIME
ftLastAccessTime: FILETIME
ftLastWriteTime: FILETIME
nFileSizeHigh: DWORD
nFileSizeLow: DWORD
dwReserved0: DWORD
dwReserved1: DWORD
cFileName: Array[CHAR]
cAlternateFileName: Array[CHAR]
class WIN32_FIND_DATAW(Structure):
dwFileAttributes: DWORD
ftCreationTime: FILETIME
ftLastAccessTime: FILETIME
ftLastWriteTime: FILETIME
nFileSizeHigh: DWORD
nFileSizeLow: DWORD
dwReserved0: DWORD
dwReserved1: DWORD
cFileName: Array[WCHAR]
cAlternateFileName: Array[WCHAR]
# These pointer type definitions use pointer[...] instead of POINTER(...), to allow them
# to be used in type annotations.
PBOOL = pointer[BOOL]
LPBOOL = pointer[BOOL]
PBOOLEAN = pointer[BOOLEAN]
PBYTE = pointer[BYTE]
LPBYTE = pointer[BYTE]
PCHAR = pointer[CHAR]
LPCOLORREF = pointer[COLORREF]
PDWORD = pointer[DWORD]
LPDWORD = pointer[DWORD]
PFILETIME = pointer[FILETIME]
LPFILETIME = pointer[FILETIME]
PFLOAT = pointer[FLOAT]
PHANDLE = pointer[HANDLE]
LPHANDLE = pointer[HANDLE]
PHKEY = pointer[HKEY]
LPHKL = pointer[HKL]
PINT = pointer[INT]
LPINT = pointer[INT]
PLARGE_INTEGER = pointer[LARGE_INTEGER]
PLCID = pointer[LCID]
PLONG = pointer[LONG]
LPLONG = pointer[LONG]
PMSG = pointer[MSG]
LPMSG = pointer[MSG]
PPOINT = pointer[POINT]
LPPOINT = pointer[POINT]
PPOINTL = pointer[POINTL]
PRECT = pointer[RECT]
LPRECT = pointer[RECT]
PRECTL = pointer[RECTL]
LPRECTL = pointer[RECTL]
LPSC_HANDLE = pointer[SC_HANDLE]
PSHORT = pointer[SHORT]
PSIZE = pointer[SIZE]
LPSIZE = pointer[SIZE]
PSIZEL = pointer[SIZEL]
LPSIZEL = pointer[SIZEL]
PSMALL_RECT = pointer[SMALL_RECT]
PUINT = pointer[UINT]
LPUINT = pointer[UINT]
PULARGE_INTEGER = pointer[ULARGE_INTEGER]
PULONG = pointer[ULONG]
PUSHORT = pointer[USHORT]
PWCHAR = pointer[WCHAR]
PWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA]
LPWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA]
PWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW]
LPWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW]
PWORD = pointer[WORD]
LPWORD = pointer[WORD]

View File

@@ -0,0 +1,15 @@
from _curses import * # noqa: F403
from _curses import _CursesWindow as _CursesWindow
from typing import Any, Callable, TypeVar
_T = TypeVar("_T")
# available after calling `curses.initscr()`
LINES: int
COLS: int
# available after calling `curses.start_color()`
COLORS: int
COLOR_PAIRS: int
def wrapper(__func: Callable[..., _T], *arg: Any, **kwds: Any) -> _T: ...

View File

@@ -0,0 +1,62 @@
from typing import List, TypeVar, Union
_CharT = TypeVar("_CharT", str, int)
NUL: int
SOH: int
STX: int
ETX: int
EOT: int
ENQ: int
ACK: int
BEL: int
BS: int
TAB: int
HT: int
LF: int
NL: int
VT: int
FF: int
CR: int
SO: int
SI: int
DLE: int
DC1: int
DC2: int
DC3: int
DC4: int
NAK: int
SYN: int
ETB: int
CAN: int
EM: int
SUB: int
ESC: int
FS: int
GS: int
RS: int
US: int
SP: int
DEL: int
controlnames: List[int]
def isalnum(c: Union[str, int]) -> bool: ...
def isalpha(c: Union[str, int]) -> bool: ...
def isascii(c: Union[str, int]) -> bool: ...
def isblank(c: Union[str, int]) -> bool: ...
def iscntrl(c: Union[str, int]) -> bool: ...
def isdigit(c: Union[str, int]) -> bool: ...
def isgraph(c: Union[str, int]) -> bool: ...
def islower(c: Union[str, int]) -> bool: ...
def isprint(c: Union[str, int]) -> bool: ...
def ispunct(c: Union[str, int]) -> bool: ...
def isspace(c: Union[str, int]) -> bool: ...
def isupper(c: Union[str, int]) -> bool: ...
def isxdigit(c: Union[str, int]) -> bool: ...
def isctrl(c: Union[str, int]) -> bool: ...
def ismeta(c: Union[str, int]) -> bool: ...
def ascii(c: _CharT) -> _CharT: ...
def ctrl(c: _CharT) -> _CharT: ...
def alt(c: _CharT) -> _CharT: ...
def unctrl(c: Union[str, int]) -> str: ...

View File

@@ -0,0 +1,20 @@
from _curses import _CursesWindow
class _Curses_Panel: # type is <class '_curses_panel.curses panel'> (note the space in the class name)
def above(self) -> _Curses_Panel: ...
def below(self) -> _Curses_Panel: ...
def bottom(self) -> None: ...
def hidden(self) -> bool: ...
def hide(self) -> None: ...
def move(self, y: int, x: int) -> None: ...
def replace(self, win: _CursesWindow) -> None: ...
def set_userptr(self, obj: object) -> None: ...
def show(self) -> None: ...
def top(self) -> None: ...
def userptr(self) -> object: ...
def window(self) -> _CursesWindow: ...
def bottom_panel() -> _Curses_Panel: ...
def new_panel(__win: _CursesWindow) -> _Curses_Panel: ...
def top_panel() -> _Curses_Panel: ...
def update_panels() -> _Curses_Panel: ...

View File

@@ -0,0 +1,11 @@
from _curses import _CursesWindow
from typing import Callable, Optional, Union
def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ...
class Textbox:
stripspaces: bool
def __init__(self, win: _CursesWindow, insert_mode: bool = ...) -> None: ...
def edit(self, validate: Optional[Callable[[int], int]] = ...) -> str: ...
def do_command(self, ch: Union[str, int]) -> None: ...
def gather(self) -> str: ...

View File

@@ -0,0 +1,385 @@
import sys
from time import struct_time
from typing import AnyStr, ClassVar, NamedTuple, Optional, SupportsAbs, Tuple, Type, TypeVar, Union, overload
_S = TypeVar("_S")
if sys.version_info >= (3,):
_Text = str
else:
_Text = Union[str, unicode]
MINYEAR: int
MAXYEAR: int
class tzinfo:
def tzname(self, dt: Optional[datetime]) -> Optional[str]: ...
def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
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:
min: ClassVar[date]
max: ClassVar[date]
resolution: ClassVar[timedelta]
def __new__(cls: Type[_S], year: int, month: int, day: int) -> _S: ...
@classmethod
def fromtimestamp(cls: Type[_S], __timestamp: float) -> _S: ...
@classmethod
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
def month(self) -> int: ...
@property
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 isoformat(self) -> str: ...
def timetuple(self) -> struct_time: ...
def toordinal(self) -> int: ...
def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ...
def __le__(self, other: date) -> bool: ...
def __lt__(self, other: date) -> bool: ...
def __ge__(self, other: date) -> bool: ...
def __gt__(self, other: date) -> bool: ...
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
def __sub__(self, other: date) -> timedelta: ...
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]: ...
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: ...
@property
def hour(self) -> int: ...
@property
def minute(self) -> int: ...
@property
def second(self) -> int: ...
@property
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 strftime(self, fmt: _Text) -> str: ...
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]: ...
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
class timedelta(SupportsAbs[timedelta]):
min: ClassVar[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: ...
@property
def days(self) -> int: ...
@property
def seconds(self) -> int: ...
@property
def microseconds(self) -> int: ...
def total_seconds(self) -> float: ...
def __add__(self, other: timedelta) -> timedelta: ...
def __radd__(self, other: timedelta) -> timedelta: ...
def __sub__(self, other: timedelta) -> timedelta: ...
def __rsub__(self, other: timedelta) -> timedelta: ...
def __neg__(self) -> timedelta: ...
def __pos__(self) -> timedelta: ...
def __abs__(self) -> timedelta: ...
def __mul__(self, other: float) -> timedelta: ...
def __rmul__(self, other: float) -> timedelta: ...
@overload
def __floordiv__(self, other: timedelta) -> int: ...
@overload
def __floordiv__(self, other: int) -> timedelta: ...
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: ...
def __gt__(self, other: timedelta) -> bool: ...
def __hash__(self) -> int: ...
class datetime(date):
min: ClassVar[datetime]
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: ...
@property
def year(self) -> int: ...
@property
def month(self) -> int: ...
@property
def day(self) -> int: ...
@property
def hour(self) -> int: ...
@property
def minute(self) -> int: ...
@property
def second(self) -> int: ...
@property
def microsecond(self) -> int: ...
@property
def tzinfo(self) -> 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
def utcfromtimestamp(cls: Type[_S], t: float) -> _S: ...
@classmethod
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: ...
@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: ...
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 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 ctime(self) -> 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]: ...
def tzname(self) -> Optional[str]: ...
def dst(self) -> Optional[timedelta]: ...
def __le__(self, other: datetime) -> bool: ... # type: ignore
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: ...
@overload # type: ignore
def __sub__(self, other: datetime) -> timedelta: ...
@overload
def __sub__(self, other: timedelta) -> datetime: ...
def __hash__(self) -> int: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
if sys.version_info >= (3, 9):
def isocalendar(self) -> _IsoCalendarDate: ...
else:
def isocalendar(self) -> Tuple[int, int, int]: ...

View File

@@ -0,0 +1,26 @@
from types import TracebackType
from typing import Iterator, MutableMapping, Optional, Tuple, Type, Union
from typing_extensions import Literal
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
class _Database(MutableMapping[_KeyType, bytes]):
def close(self) -> None: ...
def __getitem__(self, key: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __iter__(self) -> Iterator[bytes]: ...
def __len__(self) -> int: ...
def __del__(self) -> None: ...
def __enter__(self) -> _Database: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
class _error(Exception): ...
error = Tuple[Type[_error], Type[OSError]]
def whichdb(filename: str) -> str: ...
def open(file: str, flag: Literal["r", "w", "c", "n"] = ..., mode: int = ...) -> _Database: ...

View File

@@ -0,0 +1,25 @@
from types import TracebackType
from typing import Iterator, MutableMapping, Optional, Type, Union
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
error = OSError
class _Database(MutableMapping[_KeyType, bytes]):
def __init__(self, filebasename: str, mode: str, flag: str = ...) -> None: ...
def sync(self) -> None: ...
def iterkeys(self) -> Iterator[bytes]: ... # undocumented
def close(self) -> None: ...
def __getitem__(self, key: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __iter__(self) -> Iterator[bytes]: ...
def __len__(self) -> int: ...
def __del__(self) -> None: ...
def __enter__(self) -> _Database: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ...

View File

@@ -0,0 +1,35 @@
from types import TracebackType
from typing import List, Optional, Type, TypeVar, Union, overload
_T = TypeVar("_T")
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
class error(OSError): ...
# Actual typename gdbm, not exposed by the implementation
class _gdbm:
def firstkey(self) -> Optional[bytes]: ...
def nextkey(self, key: _KeyType) -> Optional[bytes]: ...
def reorganize(self) -> None: ...
def sync(self) -> None: ...
def close(self) -> None: ...
def __getitem__(self, item: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __len__(self) -> int: ...
def __enter__(self) -> _gdbm: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
@overload
def get(self, k: _KeyType) -> Optional[bytes]: ...
@overload
def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ...
def keys(self) -> List[bytes]: ...
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _gdbm: ...

View File

@@ -0,0 +1,34 @@
from types import TracebackType
from typing import List, Optional, Type, TypeVar, Union, overload
_T = TypeVar("_T")
_KeyType = Union[str, bytes]
_ValueType = Union[str, bytes]
class error(OSError): ...
library: str = ...
# Actual typename dbm, not exposed by the implementation
class _dbm:
def close(self) -> None: ...
def __getitem__(self, item: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __len__(self) -> int: ...
def __del__(self) -> None: ...
def __enter__(self) -> _dbm: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
@overload
def get(self, k: _KeyType) -> Optional[bytes]: ...
@overload
def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ...
def keys(self) -> List[bytes]: ...
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
def open(__filename: str, __flags: str = ..., __mode: int = ...) -> _dbm: ...

339
stdlib/@python2/decimal.pyi Normal file
View File

@@ -0,0 +1,339 @@
import numbers
import sys
from types import TracebackType
from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, overload
_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]
_DecimalT = TypeVar("_DecimalT", bound=Decimal)
class DecimalTuple(NamedTuple):
sign: int
digits: Tuple[int, ...]
exponent: int
ROUND_DOWN: str
ROUND_HALF_UP: str
ROUND_HALF_EVEN: str
ROUND_CEILING: str
ROUND_FLOOR: str
ROUND_UP: str
ROUND_HALF_DOWN: str
ROUND_05UP: str
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]: ...
class Clamped(DecimalException): ...
class InvalidOperation(DecimalException): ...
class ConversionSyntax(InvalidOperation): ...
class DivisionByZero(DecimalException, ZeroDivisionError): ...
class DivisionImpossible(InvalidOperation): ...
class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
class Inexact(DecimalException): ...
class InvalidContext(InvalidOperation): ...
class Rounded(DecimalException): ...
class Subnormal(DecimalException): ...
class Overflow(Inexact, Rounded): ...
class Underflow(Inexact, Rounded, Subnormal): ...
if sys.version_info >= (3,):
class FloatOperation(DecimalException, TypeError): ...
def setcontext(__context: Context) -> None: ...
def getcontext() -> Context: ...
def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ...
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 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 remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __trunc__(self) -> int: ...
@property
def real(self) -> Decimal: ...
@property
def imag(self) -> Decimal: ...
def conjugate(self) -> Decimal: ...
def __complex__(self) -> complex: ...
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: ...
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: ...
def sqrt(self, context: Optional[Context] = ...) -> Decimal: ...
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 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 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 exp(self, context: Optional[Context] = ...) -> Decimal: ...
def is_canonical(self) -> bool: ...
def is_finite(self) -> bool: ...
def is_infinite(self) -> bool: ...
def is_nan(self) -> bool: ...
def is_normal(self, context: Optional[Context] = ...) -> bool: ...
def is_qnan(self) -> bool: ...
def is_signed(self) -> bool: ...
def is_snan(self) -> bool: ...
def is_subnormal(self, context: Optional[Context] = ...) -> bool: ...
def is_zero(self) -> bool: ...
def ln(self, context: Optional[Context] = ...) -> Decimal: ...
def log10(self, context: Optional[Context] = ...) -> Decimal: ...
def logb(self, context: Optional[Context] = ...) -> Decimal: ...
def logical_and(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def logical_invert(self, context: Optional[Context] = ...) -> Decimal: ...
def logical_or(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def logical_xor(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def max_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def min_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def next_minus(self, context: Optional[Context] = ...) -> Decimal: ...
def next_plus(self, context: Optional[Context] = ...) -> Decimal: ...
def next_toward(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def number_class(self, context: Optional[Context] = ...) -> str: ...
def radix(self) -> Decimal: ...
def rotate(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def scaleb(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def shift(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __reduce__(self) -> Tuple[Type[Decimal], Tuple[str]]: ...
def __copy__(self) -> Decimal: ...
def __deepcopy__(self, memo: Any) -> Decimal: ...
def __format__(self, specifier: str, context: Optional[Context] = ...) -> str: ...
class _ContextManager(object):
new_context: Context
saved_context: Context
def __init__(self, new_context: Context) -> None: ...
def __enter__(self) -> Context: ...
def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ...
_TrapType = Type[DecimalException]
class Context(object):
prec: int
rounding: str
Emin: int
Emax: int
capitals: int
if sys.version_info >= (3,):
clamp: int
else:
_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 clear_flags(self) -> None: ...
if sys.version_info >= (3,):
def clear_traps(self) -> None: ...
def copy(self) -> Context: ...
def __copy__(self) -> Context: ...
__hash__: Any = ...
def Etiny(self) -> int: ...
def Etop(self) -> int: ...
def create_decimal(self, __num: _DecimalNew = ...) -> Decimal: ...
def create_decimal_from_float(self, __f: float) -> Decimal: ...
def abs(self, __x: _Decimal) -> Decimal: ...
def add(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def canonical(self, __x: Decimal) -> Decimal: ...
def compare(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def compare_signal(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def compare_total(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def compare_total_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def copy_abs(self, __x: _Decimal) -> Decimal: ...
def copy_decimal(self, __x: _Decimal) -> Decimal: ...
def copy_negate(self, __x: _Decimal) -> Decimal: ...
def copy_sign(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def divide(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def divide_int(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def divmod(self, __x: _Decimal, __y: _Decimal) -> Tuple[Decimal, Decimal]: ...
def exp(self, __x: _Decimal) -> Decimal: ...
def fma(self, __x: _Decimal, __y: _Decimal, __z: _Decimal) -> Decimal: ...
def is_canonical(self, __x: _Decimal) -> bool: ...
def is_finite(self, __x: _Decimal) -> bool: ...
def is_infinite(self, __x: _Decimal) -> bool: ...
def is_nan(self, __x: _Decimal) -> bool: ...
def is_normal(self, __x: _Decimal) -> bool: ...
def is_qnan(self, __x: _Decimal) -> bool: ...
def is_signed(self, __x: _Decimal) -> bool: ...
def is_snan(self, __x: _Decimal) -> bool: ...
def is_subnormal(self, __x: _Decimal) -> bool: ...
def is_zero(self, __x: _Decimal) -> bool: ...
def ln(self, __x: _Decimal) -> Decimal: ...
def log10(self, __x: _Decimal) -> Decimal: ...
def logb(self, __x: _Decimal) -> Decimal: ...
def logical_and(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def logical_invert(self, __x: _Decimal) -> Decimal: ...
def logical_or(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def logical_xor(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def max(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def max_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def min(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def min_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def minus(self, __x: _Decimal) -> Decimal: ...
def multiply(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def next_minus(self, __x: _Decimal) -> Decimal: ...
def next_plus(self, __x: _Decimal) -> Decimal: ...
def next_toward(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def normalize(self, __x: _Decimal) -> Decimal: ...
def number_class(self, __x: _Decimal) -> str: ...
def plus(self, __x: _Decimal) -> Decimal: ...
def power(self, a: _Decimal, b: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ...
def quantize(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def radix(self) -> Decimal: ...
def remainder(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def remainder_near(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def rotate(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def same_quantum(self, __x: _Decimal, __y: _Decimal) -> bool: ...
def scaleb(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def shift(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def sqrt(self, __x: _Decimal) -> Decimal: ...
def subtract(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def to_eng_string(self, __x: _Decimal) -> str: ...
def to_sci_string(self, __x: _Decimal) -> str: ...
def to_integral_exact(self, __x: _Decimal) -> Decimal: ...
def to_integral_value(self, __x: _Decimal) -> Decimal: ...
def to_integral(self, __x: _Decimal) -> Decimal: ...
DefaultContext: Context
BasicContext: Context
ExtendedContext: Context

153
stdlib/@python2/difflib.pyi Normal file
View File

@@ -0,0 +1,153 @@
import sys
from typing import (
Any,
AnyStr,
Callable,
Generic,
Iterable,
Iterator,
List,
NamedTuple,
Optional,
Sequence,
Text,
Tuple,
TypeVar,
Union,
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)
_JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]]
class Match(NamedTuple):
a: int
b: int
size: int
class SequenceMatcher(Generic[_T]):
def __init__(
self, isjunk: Optional[Callable[[_T], bool]] = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ...
) -> None: ...
def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ...
def set_seq1(self, a: Sequence[_T]) -> None: ...
def set_seq2(self, b: Sequence[_T]) -> None: ...
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
word: AnyStr, possibilities: Iterable[AnyStr], n: int = ..., cutoff: float = ...
) -> List[AnyStr]: ...
@overload
def get_close_matches(
word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = ..., cutoff: float = ...
) -> List[Sequence[_T]]: ...
class Differ:
def __init__(self, linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ...) -> None: ...
def compare(self, a: Sequence[_StrType], b: Sequence[_StrType]) -> Iterator[_StrType]: ...
def IS_LINE_JUNK(line: _StrType, pat: Any = ...) -> bool: ... # pat is undocumented
def IS_CHARACTER_JUNK(ch: _StrType, ws: _StrType = ...) -> bool: ... # ws is undocumented
def unified_diff(
a: Sequence[_StrType],
b: Sequence[_StrType],
fromfile: _StrType = ...,
tofile: _StrType = ...,
fromfiledate: _StrType = ...,
tofiledate: _StrType = ...,
n: int = ...,
lineterm: _StrType = ...,
) -> Iterator[_StrType]: ...
def context_diff(
a: Sequence[_StrType],
b: Sequence[_StrType],
fromfile: _StrType = ...,
tofile: _StrType = ...,
fromfiledate: _StrType = ...,
tofiledate: _StrType = ...,
n: int = ...,
lineterm: _StrType = ...,
) -> Iterator[_StrType]: ...
def ndiff(
a: Sequence[_StrType], b: Sequence[_StrType], linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ...
) -> Iterator[_StrType]: ...
class HtmlDiff(object):
def __init__(
self,
tabsize: int = ...,
wrapcolumn: Optional[int] = ...,
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_table(
self,
fromlines: Sequence[_StrType],
tolines: Sequence[_StrType],
fromdesc: _StrType = ...,
todesc: _StrType = ...,
context: bool = ...,
numlines: int = ...,
) -> _StrType: ...
def restore(delta: Iterable[_StrType], which: int) -> Iterator[_StrType]: ...
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]: ...

83
stdlib/@python2/dis.pyi Normal file
View File

@@ -0,0 +1,83 @@
import sys
import types
from opcode import (
EXTENDED_ARG as EXTENDED_ARG,
HAVE_ARGUMENT as HAVE_ARGUMENT,
cmp_op as cmp_op,
hascompare as hascompare,
hasconst as hasconst,
hasfree as hasfree,
hasjabs as hasjabs,
hasjrel as hasjrel,
haslocal as haslocal,
hasname as hasname,
opmap as opmap,
opname as opname,
)
from typing import 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: ...

224
stdlib/@python2/doctest.pyi Normal file
View File

@@ -0,0 +1,224 @@
import sys
import types
import unittest
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple, Type, Union
class TestResults(NamedTuple):
failed: int
attempted: int
OPTIONFLAGS_BY_NAME: Dict[str, int]
def register_optionflag(name: str) -> int: ...
DONT_ACCEPT_TRUE_FOR_1: int
DONT_ACCEPT_BLANKLINE: int
NORMALIZE_WHITESPACE: int
ELLIPSIS: int
SKIP: int
IGNORE_EXCEPTION_DETAIL: int
COMPARISON_FLAGS: int
REPORT_UDIFF: int
REPORT_CDIFF: int
REPORT_NDIFF: int
REPORT_ONLY_FIRST_FAILURE: int
if sys.version_info >= (3, 4):
FAIL_FAST: int
REPORTING_FLAGS: int
BLANKLINE_MARKER: str
ELLIPSIS_MARKER: str
class Example:
source: str
want: str
exc_msg: Optional[str]
lineno: int
indent: int
options: Dict[int, bool]
def __init__(
self,
source: str,
want: str,
exc_msg: Optional[str] = ...,
lineno: int = ...,
indent: int = ...,
options: Optional[Dict[int, bool]] = ...,
) -> None: ...
def __hash__(self) -> int: ...
class DocTest:
examples: List[Example]
globs: Dict[str, Any]
name: str
filename: Optional[str]
lineno: Optional[int]
docstring: Optional[str]
def __init__(
self,
examples: List[Example],
globs: Dict[str, Any],
name: str,
filename: Optional[str],
lineno: Optional[int],
docstring: Optional[str],
) -> None: ...
def __hash__(self) -> int: ...
def __lt__(self, other: DocTest) -> bool: ...
class DocTestParser:
def parse(self, string: str, name: str = ...) -> List[Union[str, Example]]: ...
def get_doctest(
self, string: str, globs: Dict[str, Any], name: str, filename: Optional[str], lineno: Optional[int]
) -> DocTest: ...
def get_examples(self, string: str, name: str = ...) -> List[Example]: ...
class DocTestFinder:
def __init__(
self, verbose: bool = ..., parser: DocTestParser = ..., recurse: bool = ..., exclude_empty: bool = ...
) -> None: ...
def find(
self,
obj: object,
name: Optional[str] = ...,
module: Union[None, bool, types.ModuleType] = ...,
globs: Optional[Dict[str, Any]] = ...,
extraglobs: Optional[Dict[str, Any]] = ...,
) -> List[DocTest]: ...
_Out = Callable[[str], Any]
_ExcInfo = Tuple[Type[BaseException], BaseException, types.TracebackType]
class DocTestRunner:
DIVIDER: str
optionflags: int
original_optionflags: int
tries: int
failures: int
test: DocTest
def __init__(self, checker: Optional[OutputChecker] = ..., verbose: Optional[bool] = ..., optionflags: int = ...) -> None: ...
def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ...
def report_success(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ...
def report_failure(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ...
def report_unexpected_exception(self, out: _Out, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ...
def run(
self, test: DocTest, compileflags: Optional[int] = ..., out: Optional[_Out] = ..., clear_globs: bool = ...
) -> TestResults: ...
def summarize(self, verbose: Optional[bool] = ...) -> TestResults: ...
def merge(self, other: DocTestRunner) -> None: ...
class OutputChecker:
def check_output(self, want: str, got: str, optionflags: int) -> bool: ...
def output_difference(self, example: Example, got: str, optionflags: int) -> str: ...
class DocTestFailure(Exception):
test: DocTest
example: Example
got: str
def __init__(self, test: DocTest, example: Example, got: str) -> None: ...
class UnexpectedException(Exception):
test: DocTest
example: Example
exc_info: _ExcInfo
def __init__(self, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ...
class DebugRunner(DocTestRunner): ...
master: Optional[DocTestRunner]
def testmod(
m: Optional[types.ModuleType] = ...,
name: Optional[str] = ...,
globs: Optional[Dict[str, Any]] = ...,
verbose: Optional[bool] = ...,
report: bool = ...,
optionflags: int = ...,
extraglobs: Optional[Dict[str, Any]] = ...,
raise_on_error: bool = ...,
exclude_empty: bool = ...,
) -> TestResults: ...
def testfile(
filename: str,
module_relative: bool = ...,
name: Optional[str] = ...,
package: Union[None, str, types.ModuleType] = ...,
globs: Optional[Dict[str, Any]] = ...,
verbose: Optional[bool] = ...,
report: bool = ...,
optionflags: int = ...,
extraglobs: Optional[Dict[str, Any]] = ...,
raise_on_error: bool = ...,
parser: DocTestParser = ...,
encoding: Optional[str] = ...,
) -> TestResults: ...
def run_docstring_examples(
f: object,
globs: Dict[str, Any],
verbose: bool = ...,
name: str = ...,
compileflags: Optional[int] = ...,
optionflags: int = ...,
) -> None: ...
def set_unittest_reportflags(flags: int) -> int: ...
class DocTestCase(unittest.TestCase):
def __init__(
self,
test: DocTest,
optionflags: int = ...,
setUp: Optional[Callable[[DocTest], Any]] = ...,
tearDown: Optional[Callable[[DocTest], Any]] = ...,
checker: Optional[OutputChecker] = ...,
) -> None: ...
def setUp(self) -> None: ...
def tearDown(self) -> None: ...
def runTest(self) -> None: ...
def format_failure(self, err: str) -> str: ...
def debug(self) -> None: ...
def id(self) -> str: ...
def __hash__(self) -> int: ...
def shortDescription(self) -> str: ...
class SkipDocTestCase(DocTestCase):
def __init__(self, module: types.ModuleType) -> None: ...
def setUp(self) -> None: ...
def test_skip(self) -> None: ...
def shortDescription(self) -> str: ...
if sys.version_info >= (3, 4):
class _DocTestSuite(unittest.TestSuite): ...
else:
_DocTestSuite = unittest.TestSuite
def DocTestSuite(
module: Union[None, str, types.ModuleType] = ...,
globs: Optional[Dict[str, Any]] = ...,
extraglobs: Optional[Dict[str, Any]] = ...,
test_finder: Optional[DocTestFinder] = ...,
**options: Any,
) -> _DocTestSuite: ...
class DocFileCase(DocTestCase):
def id(self) -> str: ...
def format_failure(self, err: str) -> str: ...
def DocFileTest(
path: str,
module_relative: bool = ...,
package: Union[None, str, types.ModuleType] = ...,
globs: Optional[Dict[str, Any]] = ...,
parser: DocTestParser = ...,
encoding: Optional[str] = ...,
**options: Any,
) -> DocFileCase: ...
def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ...
def script_from_examples(s: str) -> str: ...
def testsource(module: Union[None, str, types.ModuleType], name: str) -> str: ...
def debug_src(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ...
def debug_script(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ...
def debug(module: Union[None, str, types.ModuleType], name: str, pm: bool = ...) -> None: ...

View File

@@ -0,0 +1,2 @@
from _dummy_threading import *
from _dummy_threading import __all__ as __all__

View File

@@ -0,0 +1,25 @@
import sys
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: ...

137
stdlib/@python2/errno.pyi Normal file
View File

@@ -0,0 +1,137 @@
from typing import Mapping
errorcode: Mapping[int, str]
EPERM: int
ENOENT: int
ESRCH: int
EINTR: int
EIO: int
ENXIO: int
E2BIG: int
ENOEXEC: int
EBADF: int
ECHILD: int
EAGAIN: int
ENOMEM: int
EACCES: int
EFAULT: int
ENOTBLK: int
EBUSY: int
EEXIST: int
EXDEV: int
ENODEV: int
ENOTDIR: int
EISDIR: int
EINVAL: int
ENFILE: int
EMFILE: int
ENOTTY: int
ETXTBSY: int
EFBIG: int
ENOSPC: int
ESPIPE: int
EROFS: int
EMLINK: int
EPIPE: int
EDOM: int
ERANGE: int
EDEADLCK: int
ENAMETOOLONG: int
ENOLCK: int
ENOSYS: int
ENOTEMPTY: int
ELOOP: int
EWOULDBLOCK: int
ENOMSG: int
EIDRM: int
ECHRNG: int
EL2NSYNC: int
EL3HLT: int
EL3RST: int
ELNRNG: int
EUNATCH: int
ENOCSI: int
EL2HLT: int
EBADE: int
EBADR: int
EXFULL: int
ENOANO: int
EBADRQC: int
EBADSLT: int
EDEADLOCK: int
EBFONT: int
ENOSTR: int
ENODATA: int
ETIME: int
ENOSR: int
ENONET: int
ENOPKG: int
EREMOTE: int
ENOLINK: int
EADV: int
ESRMNT: int
ECOMM: int
EPROTO: int
EMULTIHOP: int
EDOTDOT: int
EBADMSG: int
EOVERFLOW: int
ENOTUNIQ: int
EBADFD: int
EREMCHG: int
ELIBACC: int
ELIBBAD: int
ELIBSCN: int
ELIBMAX: int
ELIBEXEC: int
EILSEQ: int
ERESTART: int
ESTRPIPE: int
EUSERS: int
ENOTSOCK: int
EDESTADDRREQ: int
EMSGSIZE: int
EPROTOTYPE: int
ENOPROTOOPT: int
EPROTONOSUPPORT: int
ESOCKTNOSUPPORT: int
ENOTSUP: int
EOPNOTSUPP: int
EPFNOSUPPORT: int
EAFNOSUPPORT: int
EADDRINUSE: int
EADDRNOTAVAIL: int
ENETDOWN: int
ENETUNREACH: int
ENETRESET: int
ECONNABORTED: int
ECONNRESET: int
ENOBUFS: int
EISCONN: int
ENOTCONN: int
ESHUTDOWN: int
ETOOMANYREFS: int
ETIMEDOUT: int
ECONNREFUSED: int
EHOSTDOWN: int
EHOSTUNREACH: int
EALREADY: int
EINPROGRESS: int
ESTALE: int
EUCLEAN: int
ENOTNAM: int
ENAVAIL: int
EISNAM: int
EREMOTEIO: int
EDQUOT: int
ECANCELED: int # undocumented
EKEYEXPIRED: int # undocumented
EKEYREJECTED: int # undocumented
EKEYREVOKED: int # undocumented
EMEDIUMTYPE: int # undocumented
ENOKEY: int # undocumented
ENOMEDIUM: int # undocumented
ENOTRECOVERABLE: int # undocumented
EOWNERDEAD: int # undocumented
ERFKILL: int # undocumented

View File

@@ -0,0 +1,73 @@
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]]: ...
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: ...
left: AnyStr
right: AnyStr
hide: Sequence[AnyStr]
ignore: Sequence[AnyStr]
# These properties are created at runtime by __getattr__
subdirs: Dict[AnyStr, dircmp[AnyStr]]
same_files: List[AnyStr]
diff_files: List[AnyStr]
funny_files: List[AnyStr]
common_dirs: List[AnyStr]
common_files: List[AnyStr]
common_funny: List[AnyStr]
common: List[AnyStr]
left_only: List[AnyStr]
right_only: List[AnyStr]
left_list: List[AnyStr]
right_list: List[AnyStr]
def report(self) -> None: ...
def report_partial_closure(self) -> None: ...
def report_full_closure(self) -> None: ...
methodmap: Dict[str, Callable[[], None]]
def phase0(self) -> None: ...
def phase1(self) -> None: ...
def phase2(self) -> None: ...
def phase3(self) -> None: ...
def phase4(self) -> None: ...
def phase4_closure(self) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
if sys.version_info >= (3,):
def clear_cache() -> None: ...

View File

@@ -0,0 +1,78 @@
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 close() -> None: ...
def nextfile() -> None: ...
def filename() -> str: ...
def lineno() -> int: ...
def filelineno() -> int: ...
def fileno() -> int: ...
def isfirstline() -> bool: ...
def isstdin() -> bool: ...
class FileInput(Iterable[AnyStr], Generic[AnyStr]):
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: ...
def nextfile(self) -> None: ...
def readline(self) -> AnyStr: ...
def filename(self) -> str: ...
def lineno(self) -> int: ...
def filelineno(self) -> int: ...
def fileno(self) -> int: ...
def isfirstline(self) -> bool: ...
def isstdin(self) -> bool: ...
def hook_compressed(filename: 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]]: ...

View File

@@ -0,0 +1,103 @@
from typing import IO, Any, Iterable, List, Optional, Tuple
AS_IS: None
_FontType = Tuple[str, bool, bool, bool]
_StylesType = Tuple[Any, ...]
class NullFormatter:
writer: Optional[NullWriter]
def __init__(self, writer: Optional[NullWriter] = ...) -> None: ...
def end_paragraph(self, blankline: int) -> None: ...
def add_line_break(self) -> None: ...
def add_hor_rule(self, *args: Any, **kw: Any) -> None: ...
def add_label_data(self, format: str, counter: int, blankline: Optional[int] = ...) -> None: ...
def add_flowing_data(self, data: str) -> None: ...
def add_literal_data(self, data: str) -> None: ...
def flush_softspace(self) -> None: ...
def push_alignment(self, align: Optional[str]) -> None: ...
def pop_alignment(self) -> None: ...
def push_font(self, x: _FontType) -> None: ...
def pop_font(self) -> None: ...
def push_margin(self, margin: int) -> None: ...
def pop_margin(self) -> None: ...
def set_spacing(self, spacing: Optional[str]) -> None: ...
def push_style(self, *styles: _StylesType) -> None: ...
def pop_style(self, n: int = ...) -> None: ...
def assert_line_data(self, flag: int = ...) -> None: ...
class AbstractFormatter:
writer: NullWriter
align: Optional[str]
align_stack: List[Optional[str]]
font_stack: List[_FontType]
margin_stack: List[int]
spacing: Optional[str]
style_stack: Any
nospace: int
softspace: int
para_end: int
parskip: int
hard_break: int
have_label: int
def __init__(self, writer: NullWriter) -> None: ...
def end_paragraph(self, blankline: int) -> None: ...
def add_line_break(self) -> None: ...
def add_hor_rule(self, *args: Any, **kw: Any) -> None: ...
def add_label_data(self, format: str, counter: int, blankline: Optional[int] = ...) -> None: ...
def format_counter(self, format: Iterable[str], counter: int) -> str: ...
def format_letter(self, case: str, counter: int) -> str: ...
def format_roman(self, case: str, counter: int) -> str: ...
def add_flowing_data(self, data: str) -> None: ...
def add_literal_data(self, data: str) -> None: ...
def flush_softspace(self) -> None: ...
def push_alignment(self, align: Optional[str]) -> None: ...
def pop_alignment(self) -> None: ...
def push_font(self, font: _FontType) -> None: ...
def pop_font(self) -> None: ...
def push_margin(self, margin: int) -> None: ...
def pop_margin(self) -> None: ...
def set_spacing(self, spacing: Optional[str]) -> None: ...
def push_style(self, *styles: _StylesType) -> None: ...
def pop_style(self, n: int = ...) -> None: ...
def assert_line_data(self, flag: int = ...) -> None: ...
class NullWriter:
def __init__(self) -> None: ...
def flush(self) -> None: ...
def new_alignment(self, align: Optional[str]) -> None: ...
def new_font(self, font: _FontType) -> None: ...
def new_margin(self, margin: int, level: int) -> None: ...
def new_spacing(self, spacing: Optional[str]) -> None: ...
def new_styles(self, styles: Tuple[Any, ...]) -> None: ...
def send_paragraph(self, blankline: int) -> None: ...
def send_line_break(self) -> None: ...
def send_hor_rule(self, *args: Any, **kw: Any) -> None: ...
def send_label_data(self, data: str) -> None: ...
def send_flowing_data(self, data: str) -> None: ...
def send_literal_data(self, data: str) -> None: ...
class AbstractWriter(NullWriter):
def new_alignment(self, align: Optional[str]) -> None: ...
def new_font(self, font: _FontType) -> None: ...
def new_margin(self, margin: int, level: int) -> None: ...
def new_spacing(self, spacing: Optional[str]) -> None: ...
def new_styles(self, styles: Tuple[Any, ...]) -> None: ...
def send_paragraph(self, blankline: int) -> None: ...
def send_line_break(self) -> None: ...
def send_hor_rule(self, *args: Any, **kw: Any) -> None: ...
def send_label_data(self, data: str) -> None: ...
def send_flowing_data(self, data: str) -> None: ...
def send_literal_data(self, data: str) -> None: ...
class DumbWriter(NullWriter):
file: IO[str]
maxcol: int
def __init__(self, file: Optional[IO[str]] = ..., maxcol: int = ...) -> None: ...
def reset(self) -> None: ...
def send_paragraph(self, blankline: int) -> None: ...
def send_line_break(self) -> None: ...
def send_hor_rule(self, *args: Any, **kw: Any) -> None: ...
def send_literal_data(self, data: str) -> None: ...
def send_flowing_data(self, data: str) -> None: ...
def test(file: Optional[str] = ...) -> None: ...

View File

@@ -0,0 +1,164 @@
import sys
from decimal import Decimal
from numbers import Integral, Rational, Real
from typing import Optional, Tuple, Type, TypeVar, Union, overload
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: ...
class Fraction(Rational):
@overload
def __new__(
cls: Type[_T],
numerator: Union[int, Rational] = ...,
denominator: Optional[Union[int, Rational]] = ...,
*,
_normalize: bool = ...,
) -> _T: ...
@overload
def __new__(cls: Type[_T], __value: Union[float, Decimal, str], *, _normalize: bool = ...) -> _T: ...
@classmethod
def from_float(cls, f: float) -> Fraction: ...
@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
def denominator(self) -> int: ...
@overload
def __add__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __add__(self, other: float) -> float: ...
@overload
def __add__(self, other: complex) -> complex: ...
@overload
def __radd__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __radd__(self, other: float) -> float: ...
@overload
def __radd__(self, other: complex) -> complex: ...
@overload
def __sub__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __sub__(self, other: float) -> float: ...
@overload
def __sub__(self, other: complex) -> complex: ...
@overload
def __rsub__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __rsub__(self, other: float) -> float: ...
@overload
def __rsub__(self, other: complex) -> complex: ...
@overload
def __mul__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __mul__(self, other: float) -> float: ...
@overload
def __mul__(self, other: complex) -> complex: ...
@overload
def __rmul__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __rmul__(self, other: float) -> float: ...
@overload
def __rmul__(self, other: complex) -> complex: ...
@overload
def __truediv__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __truediv__(self, other: float) -> float: ...
@overload
def __truediv__(self, other: complex) -> complex: ...
@overload
def __rtruediv__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
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 __floordiv__(self, other: Union[int, Fraction]) -> int: ...
@overload
def __floordiv__(self, other: float) -> float: ...
@overload
def __rfloordiv__(self, other: Union[int, Fraction]) -> int: ...
@overload
def __rfloordiv__(self, other: float) -> float: ...
@overload
def __mod__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __mod__(self, other: float) -> float: ...
@overload
def __rmod__(self, other: Union[int, Fraction]) -> Fraction: ...
@overload
def __rmod__(self, other: float) -> float: ...
@overload
def __divmod__(self, other: Union[int, Fraction]) -> Tuple[int, Fraction]: ...
@overload
def __divmod__(self, other: float) -> Tuple[float, Fraction]: ...
@overload
def __rdivmod__(self, other: Union[int, Fraction]) -> Tuple[int, Fraction]: ...
@overload
def __rdivmod__(self, other: float) -> Tuple[float, Fraction]: ...
@overload
def __pow__(self, other: int) -> Fraction: ...
@overload
def __pow__(self, other: Union[float, Fraction]) -> float: ...
@overload
def __pow__(self, other: complex) -> complex: ...
@overload
def __rpow__(self, other: Union[int, float, Fraction]) -> float: ...
@overload
def __rpow__(self, other: complex) -> complex: ...
def __pos__(self) -> Fraction: ...
def __neg__(self) -> Fraction: ...
def __abs__(self) -> Fraction: ...
def __trunc__(self) -> int: ...
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: ...
# Not actually defined within fractions.py, but provides more useful
# overrides
@property
def real(self) -> Fraction: ...
@property
def imag(self) -> Literal[0]: ...
def conjugate(self) -> Fraction: ...

161
stdlib/@python2/ftplib.pyi Normal file
View File

@@ -0,0 +1,161 @@
import sys
from _typeshed import SupportsRead, SupportsReadline
from socket import socket
from ssl import SSLContext
from types import TracebackType
from typing import Any, BinaryIO, Callable, Dict, Iterable, Iterator, List, Optional, Text, TextIO, Tuple, Type, TypeVar, Union
from typing_extensions import Literal
_T = TypeVar("_T")
_IntOrStr = Union[int, Text]
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): ...
class error_perm(Error): ...
class error_proto(Error): ...
all_errors: Tuple[Type[Exception], ...]
class FTP:
debugging: int
# Note: This is technically the type that's passed in as the host argument. But to make it easier in Python 2 we
# accept Text but return str.
host: str
port: int
maxline: int
sock: Optional[socket]
welcome: Optional[str]
passiveserver: int
timeout: int
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]
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: ...
def set_pasv(self, val: Union[bool, int]) -> None: ...
def sanitize(self, s: Text) -> str: ...
def putline(self, line: Text) -> None: ...
def putcmd(self, line: Text) -> None: ...
def getline(self) -> str: ...
def getmultiline(self) -> str: ...
def getresp(self) -> str: ...
def voidresp(self) -> str: ...
def abort(self) -> str: ...
def sendcmd(self, cmd: Text) -> str: ...
def voidcmd(self, cmd: Text) -> str: ...
def sendport(self, host: Text, port: int) -> str: ...
def sendeprt(self, host: Text, port: int) -> str: ...
def makeport(self) -> socket: ...
def makepasv(self) -> Tuple[str, int]: ...
def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ...) -> str: ...
# In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers.
def ntransfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> Tuple[socket, int]: ...
def transfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> socket: ...
def retrbinary(
self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: Optional[_IntOrStr] = ...
) -> str: ...
def storbinary(
self,
cmd: Text,
fp: SupportsRead[bytes],
blocksize: int = ...,
callback: Optional[Callable[[bytes], Any]] = ...,
rest: Optional[_IntOrStr] = ...,
) -> str: ...
def retrlines(self, cmd: Text, callback: Optional[Callable[[str], Any]] = ...) -> str: ...
def storlines(self, cmd: Text, fp: SupportsReadline[bytes], callback: Optional[Callable[[bytes], Any]] = ...) -> str: ...
def acct(self, password: Text) -> str: ...
def nlst(self, *args: Text) -> List[str]: ...
# Technically only the last arg can be a Callable but ...
def dir(self, *args: 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: ...
def size(self, filename: Text) -> Optional[int]: ...
def mkd(self, dirname: Text) -> str: ...
def rmd(self, dirname: Text) -> str: ...
def pwd(self) -> str: ...
def quit(self) -> str: ...
def close(self) -> None: ...
class FTP_TLS(FTP):
def __init__(
self,
host: Text = ...,
user: Text = ...,
passwd: Text = ...,
acct: Text = ...,
keyfile: Optional[str] = ...,
certfile: Optional[str] = ...,
context: Optional[SSLContext] = ...,
timeout: float = ...,
source_address: Optional[Tuple[str, int]] = ...,
) -> None: ...
ssl_version: int
keyfile: Optional[str]
certfile: Optional[str]
context: SSLContext
def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ..., secure: bool = ...) -> str: ...
def auth(self) -> str: ...
def prot_p(self) -> str: ...
def prot_c(self) -> str: ...
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
def parse229(resp: str, peer: Any) -> Tuple[str, int]: ... # undocumented
def parse257(resp: str) -> str: ... # undocumented
def ftpcp(
source: FTP, sourcename: str, target: FTP, targetname: str = ..., type: Literal["A", "I"] = ...
) -> None: ... # undocumented

View File

@@ -0,0 +1,32 @@
import os
import sys
from _typeshed import AnyPath, BytesPath, StrPath, SupportsLessThanT
from typing import List, Sequence, Tuple, Union, overload
from typing_extensions import Literal
# All overloads can return empty string. Ideally, Literal[""] would be a valid
# Iterable[T], so that Union[List[T], Literal[""]] could be used as a return
# type. But because this only works when T is str, we need Sequence[T] instead.
@overload
def commonprefix(m: Sequence[StrPath]) -> str: ... # type: ignore
@overload
def commonprefix(m: Sequence[BytesPath]) -> Union[bytes, Literal[""]]: ... # type: ignore
@overload
def commonprefix(m: Sequence[List[SupportsLessThanT]]) -> Sequence[SupportsLessThanT]: ...
@overload
def commonprefix(m: Sequence[Tuple[SupportsLessThanT, ...]]) -> Sequence[SupportsLessThanT]: ...
def exists(path: AnyPath) -> bool: ...
def getsize(filename: AnyPath) -> int: ...
def isfile(path: AnyPath) -> bool: ...
def isdir(s: AnyPath) -> bool: ...
# These return float if os.stat_float_times() == True,
# but int is a subclass of float.
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: ...

11
stdlib/@python2/grp.pyi Normal file
View File

@@ -0,0 +1,11 @@
from typing import List, NamedTuple, Optional
class struct_group(NamedTuple):
gr_name: str
gr_passwd: Optional[str]
gr_gid: int
gr_mem: List[str]
def getgrall() -> List[struct_group]: ...
def getgrgid(id: int) -> struct_group: ...
def getgrnam(name: str) -> struct_group: ...

44
stdlib/@python2/hmac.pyi Normal file
View File

@@ -0,0 +1,44 @@
import sys
from _typeshed import ReadableBuffer
from types import ModuleType
from typing import Any, AnyStr, Callable, Optional, Union, overload
# TODO more precise type for object of hashlib
_Hash = Any
_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: ...
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: ...
def hexdigest(self) -> str: ...
def copy(self) -> HMAC: ...
@overload
def compare_digest(__a: ReadableBuffer, __b: ReadableBuffer) -> bool: ...
@overload
def compare_digest(__a: AnyStr, __b: AnyStr) -> bool: ...
if sys.version_info >= (3, 7):
def digest(key: bytes, msg: ReadableBuffer, digest: str) -> bytes: ...

View File

@@ -0,0 +1,4 @@
from typing import AnyStr
def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...
def unescape(s: AnyStr) -> AnyStr: ...

View File

@@ -0,0 +1,6 @@
from typing import Dict
name2codepoint: Dict[str, int]
html5: Dict[str, str]
codepoint2name: Dict[int, str]
entitydefs: Dict[str, str]

View File

@@ -0,0 +1,30 @@
from _markupbase import ParserBase
from typing import List, Optional, Tuple
class HTMLParser(ParserBase):
def __init__(self, *, convert_charrefs: bool = ...) -> None: ...
def feed(self, data: str) -> None: ...
def close(self) -> None: ...
def reset(self) -> None: ...
def getpos(self) -> Tuple[int, int]: ...
def get_starttag_text(self) -> Optional[str]: ...
def handle_starttag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: ...
def handle_endtag(self, tag: str) -> None: ...
def handle_startendtag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: ...
def handle_data(self, data: str) -> None: ...
def handle_entityref(self, name: str) -> None: ...
def handle_charref(self, name: str) -> None: ...
def handle_comment(self, data: str) -> None: ...
def handle_decl(self, decl: str) -> None: ...
def handle_pi(self, data: str) -> None: ...
def unknown_decl(self, data: str) -> None: ...
CDATA_CONTENT_ELEMENTS: Tuple[str, ...]
def check_for_whole_start_tag(self, i: int) -> int: ... # undocumented
def clear_cdata_mode(self) -> None: ... # undocumented
def goahead(self, end: bool) -> None: ... # undocumented
def parse_bogus_comment(self, i: int, report: bool = ...) -> int: ... # undocumented
def parse_endtag(self, i: int) -> int: ... # undocumented
def parse_html_declaration(self, i: int) -> int: ... # undocumented
def parse_pi(self, i: int) -> int: ... # undocumented
def parse_starttag(self, i: int) -> int: ... # undocumented
def set_cdata_mode(self, elem: str) -> None: ... # undocumented

172
stdlib/@python2/imaplib.pyi Normal file
View File

@@ -0,0 +1,172 @@
import subprocess
import sys
import time
from socket import socket as _socket
from ssl import SSLContext, SSLSocket
from types import TracebackType
from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Text, Tuple, Type, Union
from typing_extensions import Literal
# TODO: Commands should use their actual return types, not this type alias.
# E.g. Tuple[Literal["OK"], List[bytes]]
_CommandResults = Tuple[str, List[Any]]
_AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]]
class IMAP4:
error: Type[Exception] = ...
abort: Type[Exception] = ...
readonly: Type[Exception] = ...
mustquote: Pattern[Text] = ...
debug: int = ...
state: str = ...
literal: Optional[Text] = ...
tagged_commands: Dict[bytes, Optional[List[bytes]]]
untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]]
continuation_response: str = ...
is_readonly: bool = ...
tagnum: int = ...
tagpre: str = ...
tagre: Pattern[Text] = ...
welcome: bytes = ...
capabilities: Tuple[str] = ...
PROTOCOL_VERSION: str = ...
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 = ...
sock: _socket = ...
file: Union[IO[Text], IO[bytes]] = ...
def read(self, size: int) -> bytes: ...
def readline(self) -> bytes: ...
def send(self, data: bytes) -> None: ...
def shutdown(self) -> None: ...
def socket(self) -> _socket: ...
def recent(self) -> _CommandResults: ...
def response(self, code: str) -> _CommandResults: ...
def append(self, mailbox: str, flags: str, date_time: str, message: str) -> str: ...
def authenticate(self, mechanism: str, authobject: Callable[[bytes], Optional[bytes]]) -> Tuple[str, str]: ...
def capability(self) -> _CommandResults: ...
def check(self) -> _CommandResults: ...
def close(self) -> _CommandResults: ...
def copy(self, message_set: str, new_mailbox: str) -> _CommandResults: ...
def create(self, mailbox: str) -> _CommandResults: ...
def delete(self, mailbox: str) -> _CommandResults: ...
def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ...
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: ...
def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ...
def getquota(self, root: str) -> _CommandResults: ...
def getquotaroot(self, mailbox: str) -> _CommandResults: ...
def list(self, directory: str = ..., pattern: str = ...) -> Tuple[str, _AnyResponseData]: ...
def login(self, user: str, password: str) -> Tuple[Literal["OK"], List[bytes]]: ...
def login_cram_md5(self, user: str, password: str) -> _CommandResults: ...
def logout(self) -> Tuple[str, _AnyResponseData]: ...
def lsub(self, directory: str = ..., pattern: str = ...) -> _CommandResults: ...
def myrights(self, mailbox: str) -> _CommandResults: ...
def namespace(self) -> _CommandResults: ...
def noop(self) -> Tuple[str, List[bytes]]: ...
def partial(self, message_num: str, message_part: str, start: str, length: str) -> _CommandResults: ...
def proxyauth(self, user: str) -> _CommandResults: ...
def rename(self, oldmailbox: str, newmailbox: str) -> _CommandResults: ...
def search(self, charset: Optional[str], *criteria: str) -> _CommandResults: ...
def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[Optional[bytes]]]: ...
def setacl(self, mailbox: str, who: str, what: str) -> _CommandResults: ...
def setannotation(self, *args: str) -> _CommandResults: ...
def setquota(self, root: str, limits: str) -> _CommandResults: ...
def sort(self, sort_criteria: str, charset: str, *search_criteria: str) -> _CommandResults: ...
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: ...
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 read(self, size: int) -> bytes: ...
def readline(self) -> bytes: ...
def send(self, data: bytes) -> None: ...
def shutdown(self) -> None: ...
def socket(self) -> _socket: ...
def ssl(self) -> SSLSocket: ...
class IMAP4_stream(IMAP4):
command: str = ...
def __init__(self, command: str) -> None: ...
host: str = ...
port: int = ...
sock: _socket = ...
file: IO[Any] = ...
process: subprocess.Popen[bytes] = ...
writefile: IO[Any] = ...
readfile: IO[Any] = ...
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: ...
def shutdown(self) -> None: ...
class _Authenticator:
mech: Callable[[bytes], bytes] = ...
def __init__(self, mechinst: Callable[[bytes], bytes]) -> None: ...
def process(self, data: str) -> str: ...
def encode(self, inp: bytes) -> str: ...
def decode(self, inp: str) -> bytes: ...
def Internaldate2tuple(resp: str) -> time.struct_time: ...
def Int2AP(num: int) -> str: ...
def ParseFlags(resp: str) -> Tuple[str]: ...
def Time2Internaldate(date_time: Union[float, time.struct_time, str]) -> str: ...

View File

@@ -0,0 +1,20 @@
import os
import sys
from typing import Any, BinaryIO, Callable, List, Optional, Protocol, Text, Union, overload
class _ReadableBinary(Protocol):
def tell(self) -> int: ...
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]
@overload
def what(file: _File, h: None = ...) -> Optional[str]: ...
@overload
def what(file: Any, h: bytes) -> Optional[str]: ...
tests: List[Callable[[bytes, Optional[BinaryIO]], Optional[str]]]

View File

@@ -0,0 +1,152 @@
import sys
from typing import Any, Container, Generic, Iterable, Iterator, Optional, SupportsInt, Tuple, TypeVar, overload
# Undocumented length constants
IPV4LENGTH: int
IPV6LENGTH: int
_A = TypeVar("_A", IPv4Address, IPv6Address)
_N = TypeVar("_N", IPv4Network, IPv6Network)
_T = TypeVar("_T")
def ip_address(address: object) -> Any: ... # morally Union[IPv4Address, IPv6Address]
def ip_network(address: object, strict: bool = ...) -> Any: ... # morally Union[IPv4Network, IPv6Network]
def ip_interface(address: object) -> Any: ... # morally Union[IPv4Interface, IPv6Interface]
class _IPAddressBase:
def __eq__(self, other: Any) -> bool: ...
def __ge__(self: _T, other: _T) -> bool: ...
def __gt__(self: _T, other: _T) -> bool: ...
def __le__(self: _T, other: _T) -> bool: ...
def __lt__(self: _T, other: _T) -> bool: ...
def __ne__(self, other: Any) -> bool: ...
@property
def compressed(self) -> str: ...
@property
def exploded(self) -> str: ...
@property
def reverse_pointer(self) -> str: ...
@property
def version(self) -> int: ...
class _BaseAddress(_IPAddressBase, SupportsInt):
def __init__(self, address: object) -> None: ...
def __add__(self: _T, other: int) -> _T: ...
def __hash__(self) -> int: ...
def __int__(self) -> int: ...
def __sub__(self: _T, other: int) -> _T: ...
@property
def is_global(self) -> bool: ...
@property
def is_link_local(self) -> bool: ...
@property
def is_loopback(self) -> bool: ...
@property
def is_multicast(self) -> bool: ...
@property
def is_private(self) -> bool: ...
@property
def is_reserved(self) -> bool: ...
@property
def is_unspecified(self) -> bool: ...
@property
def max_prefixlen(self) -> int: ...
@property
def packed(self) -> bytes: ...
class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
network_address: _A
netmask: _A
def __init__(self, address: object, strict: bool = ...) -> None: ...
def __contains__(self, other: Any) -> bool: ...
def __getitem__(self, n: int) -> _A: ...
def __iter__(self) -> Iterator[_A]: ...
def address_exclude(self: _T, other: _T) -> Iterator[_T]: ...
@property
def broadcast_address(self) -> _A: ...
def compare_networks(self: _T, other: _T) -> int: ...
def hosts(self) -> Iterator[_A]: ...
@property
def is_global(self) -> bool: ...
@property
def is_link_local(self) -> bool: ...
@property
def is_loopback(self) -> bool: ...
@property
def is_multicast(self) -> bool: ...
@property
def is_private(self) -> bool: ...
@property
def is_reserved(self) -> bool: ...
@property
def is_unspecified(self) -> bool: ...
@property
def max_prefixlen(self) -> int: ...
@property
def num_addresses(self) -> int: ...
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
def with_hostmask(self) -> str: ...
@property
def with_netmask(self) -> str: ...
@property
def with_prefixlen(self) -> str: ...
@property
def hostmask(self) -> _A: ...
class _BaseInterface(_BaseAddress, Generic[_A, _N]):
hostmask: _A
netmask: _A
network: _N
@property
def ip(self) -> _A: ...
@property
def with_hostmask(self) -> str: ...
@property
def with_netmask(self) -> str: ...
@property
def with_prefixlen(self) -> str: ...
class IPv4Address(_BaseAddress): ...
class IPv4Network(_BaseNetwork[IPv4Address]): ...
class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): ...
class IPv6Address(_BaseAddress):
@property
def ipv4_mapped(self) -> Optional[IPv4Address]: ...
@property
def is_site_local(self) -> bool: ...
@property
def sixtofour(self) -> Optional[IPv4Address]: ...
@property
def teredo(self) -> Optional[Tuple[IPv4Address, IPv4Address]]: ...
class IPv6Network(_BaseNetwork[IPv6Address]):
@property
def is_site_local(self) -> bool: ...
class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]): ...
def v4_int_to_packed(address: int) -> bytes: ...
def v6_int_to_packed(address: int) -> bytes: ...
@overload
def summarize_address_range(first: IPv4Address, last: IPv4Address) -> Iterator[IPv4Network]: ...
@overload
def summarize_address_range(first: IPv6Address, last: IPv6Address) -> Iterator[IPv6Network]: ...
def collapse_addresses(addresses: Iterable[_N]) -> Iterator[_N]: ...
@overload
def get_mixed_type_key(obj: _A) -> Tuple[int, _A]: ...
@overload
def get_mixed_type_key(obj: IPv4Network) -> Tuple[int, IPv4Address, IPv4Address]: ...
@overload
def get_mixed_type_key(obj: IPv6Network) -> Tuple[int, IPv6Address, IPv6Address]: ...
class AddressValueError(ValueError): ...
class NetmaskValueError(ValueError): ...

View File

@@ -0,0 +1,10 @@
import sys
from typing import Sequence, Text
def iskeyword(s: Text) -> bool: ...
kwlist: Sequence[str]
if sys.version_info >= (3, 9):
def issoftkeyword(s: str) -> bool: ...
softkwlist: Sequence[str]

View File

View File

@@ -0,0 +1,20 @@
from _typeshed import StrPath
from lib2to3.pgen2.grammar import Grammar
from lib2to3.pytree import _NL, _Convert
from logging import Logger
from typing import IO, Any, Iterable, Optional, Text
class Driver:
grammar: Grammar
logger: Logger
convert: _Convert
def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ..., logger: Optional[Logger] = ...) -> None: ...
def parse_tokens(self, tokens: Iterable[Any], debug: bool = ...) -> _NL: ...
def parse_stream_raw(self, stream: IO[Text], debug: bool = ...) -> _NL: ...
def parse_stream(self, stream: IO[Text], debug: bool = ...) -> _NL: ...
def parse_file(self, filename: StrPath, encoding: Optional[Text] = ..., debug: bool = ...) -> _NL: ...
def parse_string(self, text: Text, debug: bool = ...) -> _NL: ...
def load_grammar(
gt: Text = ..., gp: Optional[Text] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ...
) -> Grammar: ...

View File

@@ -0,0 +1,26 @@
from _typeshed import StrPath
from typing import Dict, List, Optional, Text, Tuple, TypeVar
_P = TypeVar("_P")
_Label = Tuple[int, Optional[Text]]
_DFA = List[List[Tuple[int, int]]]
_DFAS = Tuple[_DFA, Dict[int, int]]
class Grammar:
symbol2number: Dict[Text, int]
number2symbol: Dict[int, Text]
states: List[_DFA]
dfas: Dict[int, _DFAS]
labels: List[_Label]
keywords: Dict[Text, int]
tokens: Dict[int, int]
symbol2label: Dict[Text, int]
start: int
def __init__(self) -> None: ...
def dump(self, filename: StrPath) -> None: ...
def load(self, filename: StrPath) -> None: ...
def copy(self: _P) -> _P: ...
def report(self) -> None: ...
opmap_raw: Text
opmap: Dict[Text, Text]

View File

@@ -0,0 +1,7 @@
from typing import Dict, Match, Text
simple_escapes: Dict[Text, Text]
def escape(m: Match[str]) -> Text: ...
def evalString(s: Text) -> Text: ...
def test() -> None: ...

View File

@@ -0,0 +1,26 @@
from lib2to3.pgen2.grammar import _DFAS, Grammar
from lib2to3.pytree import _NL, _Convert, _RawNode
from typing import Any, List, Optional, Sequence, Set, Text, Tuple
_Context = Sequence[Any]
class ParseError(Exception):
msg: Text
type: int
value: Optional[Text]
context: _Context
def __init__(self, msg: Text, type: int, value: Optional[Text], context: _Context) -> None: ...
class Parser:
grammar: Grammar
convert: _Convert
stack: List[Tuple[_DFAS, int, _RawNode]]
rootnode: Optional[_NL]
used_names: Set[Text]
def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ...) -> None: ...
def setup(self, start: Optional[int] = ...) -> None: ...
def addtoken(self, type: int, value: Optional[Text], context: _Context) -> bool: ...
def classify(self, type: int, value: Optional[Text], context: _Context) -> int: ...
def shift(self, type: int, value: Optional[Text], newstate: int, context: _Context) -> None: ...
def push(self, type: int, newdfa: _DFAS, newstate: int, context: _Context) -> None: ...
def pop(self) -> None: ...

View File

@@ -0,0 +1,46 @@
from _typeshed import StrPath
from lib2to3.pgen2 import grammar
from lib2to3.pgen2.tokenize import _TokenInfo
from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Optional, Text, Tuple
class PgenGrammar(grammar.Grammar): ...
class ParserGenerator:
filename: StrPath
stream: IO[Text]
generator: Iterator[_TokenInfo]
first: Dict[Text, Dict[Text, int]]
def __init__(self, filename: StrPath, stream: Optional[IO[Text]] = ...) -> None: ...
def make_grammar(self) -> PgenGrammar: ...
def make_first(self, c: PgenGrammar, name: Text) -> Dict[int, int]: ...
def make_label(self, c: PgenGrammar, label: Text) -> int: ...
def addfirstsets(self) -> None: ...
def calcfirst(self, name: Text) -> None: ...
def parse(self) -> Tuple[Dict[Text, List[DFAState]], Text]: ...
def make_dfa(self, start: NFAState, finish: NFAState) -> List[DFAState]: ...
def dump_nfa(self, name: Text, start: NFAState, finish: NFAState) -> List[DFAState]: ...
def dump_dfa(self, name: Text, dfa: Iterable[DFAState]) -> None: ...
def simplify_dfa(self, dfa: List[DFAState]) -> None: ...
def parse_rhs(self) -> Tuple[NFAState, NFAState]: ...
def parse_alt(self) -> Tuple[NFAState, NFAState]: ...
def parse_item(self) -> Tuple[NFAState, NFAState]: ...
def parse_atom(self) -> Tuple[NFAState, NFAState]: ...
def expect(self, type: int, value: Optional[Any] = ...) -> Text: ...
def gettoken(self) -> None: ...
def raise_error(self, msg: str, *args: Any) -> NoReturn: ...
class NFAState:
arcs: List[Tuple[Optional[Text], NFAState]]
def __init__(self) -> None: ...
def addarc(self, next: NFAState, label: Optional[Text] = ...) -> None: ...
class DFAState:
nfaset: Dict[NFAState, Any]
isfinal: bool
arcs: Dict[Text, DFAState]
def __init__(self, nfaset: Dict[NFAState, Any], final: NFAState) -> None: ...
def addarc(self, next: DFAState, label: Text) -> None: ...
def unifystate(self, old: DFAState, new: DFAState) -> None: ...
def __eq__(self, other: Any) -> bool: ...
def generate_grammar(filename: StrPath = ...) -> PgenGrammar: ...

View File

@@ -0,0 +1,71 @@
import sys
from typing import Dict, Text
ENDMARKER: int
NAME: int
NUMBER: int
STRING: int
NEWLINE: int
INDENT: int
DEDENT: int
LPAR: int
RPAR: int
LSQB: int
RSQB: int
COLON: int
COMMA: int
SEMI: int
PLUS: int
MINUS: int
STAR: int
SLASH: int
VBAR: int
AMPER: int
LESS: int
GREATER: int
EQUAL: int
DOT: int
PERCENT: int
BACKQUOTE: int
LBRACE: int
RBRACE: int
EQEQUAL: int
NOTEQUAL: int
LESSEQUAL: int
GREATEREQUAL: int
TILDE: int
CIRCUMFLEX: int
LEFTSHIFT: int
RIGHTSHIFT: int
DOUBLESTAR: int
PLUSEQUAL: int
MINEQUAL: int
STAREQUAL: int
SLASHEQUAL: int
PERCENTEQUAL: int
AMPEREQUAL: int
VBAREQUAL: int
CIRCUMFLEXEQUAL: int
LEFTSHIFTEQUAL: int
RIGHTSHIFTEQUAL: int
DOUBLESTAREQUAL: int
DOUBLESLASH: int
DOUBLESLASHEQUAL: int
OP: int
COMMENT: int
NL: int
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
tok_name: Dict[int, Text]
def ISTERMINAL(x: int) -> bool: ...
def ISNONTERMINAL(x: int) -> bool: ...
def ISEOF(x: int) -> bool: ...

View File

@@ -0,0 +1,23 @@
from lib2to3.pgen2.token import * # noqa
from typing import Callable, Iterable, Iterator, List, Text, Tuple
_Coord = Tuple[int, int]
_TokenEater = Callable[[int, Text, _Coord, _Coord, Text], None]
_TokenInfo = Tuple[int, Text, _Coord, _Coord, Text]
class TokenError(Exception): ...
class StopTokenizing(Exception): ...
def tokenize(readline: Callable[[], Text], tokeneater: _TokenEater = ...) -> None: ...
class Untokenizer:
tokens: List[Text]
prev_row: int
prev_col: int
def __init__(self) -> None: ...
def add_whitespace(self, start: _Coord) -> None: ...
def untokenize(self, iterable: Iterable[_TokenInfo]) -> Text: ...
def compat(self, token: Tuple[int, Text], iterable: Iterable[_TokenInfo]) -> None: ...
def untokenize(iterable: Iterable[_TokenInfo]) -> Text: ...
def generate_tokens(readline: Callable[[], Text]) -> Iterator[_TokenInfo]: ...

View File

@@ -0,0 +1,113 @@
from lib2to3.pgen2.grammar import Grammar
class Symbols:
def __init__(self, grammar: Grammar) -> None: ...
class python_symbols(Symbols):
and_expr: int
and_test: int
annassign: int
arglist: int
argument: int
arith_expr: int
assert_stmt: int
async_funcdef: int
async_stmt: int
atom: int
augassign: int
break_stmt: int
classdef: int
comp_for: int
comp_if: int
comp_iter: int
comp_op: int
comparison: int
compound_stmt: int
continue_stmt: int
decorated: int
decorator: int
decorators: int
del_stmt: int
dictsetmaker: int
dotted_as_name: int
dotted_as_names: int
dotted_name: int
encoding_decl: int
eval_input: int
except_clause: int
exec_stmt: int
expr: int
expr_stmt: int
exprlist: int
factor: int
file_input: int
flow_stmt: int
for_stmt: int
funcdef: int
global_stmt: int
if_stmt: int
import_as_name: int
import_as_names: int
import_from: int
import_name: int
import_stmt: int
lambdef: int
listmaker: int
not_test: int
old_lambdef: int
old_test: int
or_test: int
parameters: int
pass_stmt: int
power: int
print_stmt: int
raise_stmt: int
return_stmt: int
shift_expr: int
simple_stmt: int
single_input: int
sliceop: int
small_stmt: int
star_expr: int
stmt: int
subscript: int
subscriptlist: int
suite: int
term: int
test: int
testlist: int
testlist1: int
testlist_gexp: int
testlist_safe: int
testlist_star_expr: int
tfpdef: int
tfplist: int
tname: int
trailer: int
try_stmt: int
typedargslist: int
varargslist: int
vfpdef: int
vfplist: int
vname: int
while_stmt: int
with_item: int
with_stmt: int
with_var: int
xor_expr: int
yield_arg: int
yield_expr: int
yield_stmt: int
class pattern_symbols(Symbols):
Alternative: int
Alternatives: int
Details: int
Matcher: int
NegatedUnit: int
Repeater: int
Unit: int
python_grammar: Grammar
python_grammar_no_print_statement: Grammar
pattern_grammar: Grammar

View File

@@ -0,0 +1,97 @@
import sys
from lib2to3.pgen2.grammar import Grammar
from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union
_P = TypeVar("_P")
_NL = Union[Node, Leaf]
_Context = Tuple[Text, int, int]
_Results = Dict[Text, _NL]
_RawNode = Tuple[int, Text, _Context, Optional[List[_NL]]]
_Convert = Callable[[Grammar, _RawNode], Any]
HUGE: int
def type_repr(type_num: int) -> Text: ...
class Base:
type: int
parent: Optional[Node]
prefix: Text
children: List[_NL]
was_changed: bool
was_checked: bool
def __eq__(self, other: Any) -> bool: ...
def _eq(self: _P, other: _P) -> bool: ...
def clone(self: _P) -> _P: ...
def post_order(self) -> Iterator[_NL]: ...
def pre_order(self) -> Iterator[_NL]: ...
def replace(self, new: Union[_NL, List[_NL]]) -> None: ...
def get_lineno(self) -> int: ...
def changed(self) -> None: ...
def remove(self) -> Optional[int]: ...
@property
def next_sibling(self) -> Optional[_NL]: ...
@property
def prev_sibling(self) -> Optional[_NL]: ...
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: ...
class Node(Base):
fixers_applied: List[Any]
def __init__(
self,
type: int,
children: List[_NL],
context: Optional[Any] = ...,
prefix: Optional[Text] = ...,
fixers_applied: Optional[List[Any]] = ...,
) -> None: ...
def set_child(self, i: int, child: _NL) -> None: ...
def insert_child(self, i: int, child: _NL) -> None: ...
def append_child(self, child: _NL) -> None: ...
class Leaf(Base):
lineno: int
column: int
value: Text
fixers_applied: List[Any]
def __init__(
self,
type: int,
value: Text,
context: Optional[_Context] = ...,
prefix: Optional[Text] = ...,
fixers_applied: List[Any] = ...,
) -> None: ...
def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ...
class BasePattern:
type: int
content: Optional[Text]
name: Optional[Text]
def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns
def match(self, node: _NL, results: Optional[_Results] = ...) -> bool: ...
def match_seq(self, nodes: List[_NL], results: Optional[_Results] = ...) -> bool: ...
def generate_matches(self, nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ...
class LeafPattern(BasePattern):
def __init__(self, type: Optional[int] = ..., content: Optional[Text] = ..., name: Optional[Text] = ...) -> None: ...
class NodePattern(BasePattern):
wildcards: bool
def __init__(self, type: Optional[int] = ..., content: Optional[Text] = ..., name: Optional[Text] = ...) -> None: ...
class WildcardPattern(BasePattern):
min: int
max: int
def __init__(self, content: Optional[Text] = ..., min: int = ..., max: int = ..., name: Optional[Text] = ...) -> None: ...
class NegatedPattern(BasePattern):
def __init__(self, content: Optional[Text] = ...) -> None: ...
def generate_matches(patterns: List[BasePattern], nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ...

View File

@@ -0,0 +1,13 @@
import sys
from typing import Any, Dict, List, Optional, Text
_ModuleGlobals = Dict[str, Any]
def getline(filename: Text, lineno: int, module_globals: Optional[_ModuleGlobals] = ...) -> str: ...
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]: ...
if sys.version_info >= (3, 5):
def lazycache(filename: Text, module_globals: _ModuleGlobals) -> bool: ...

111
stdlib/@python2/locale.pyi Normal file
View File

@@ -0,0 +1,111 @@
import sys
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
CODESET: int
D_T_FMT: int
D_FMT: int
T_FMT: int
T_FMT_AMPM: int
DAY_1: int
DAY_2: int
DAY_3: int
DAY_4: int
DAY_5: int
DAY_6: int
DAY_7: int
ABDAY_1: int
ABDAY_2: int
ABDAY_3: int
ABDAY_4: int
ABDAY_5: int
ABDAY_6: int
ABDAY_7: int
MON_1: int
MON_2: int
MON_3: int
MON_4: int
MON_5: int
MON_6: int
MON_7: int
MON_8: int
MON_9: int
MON_10: int
MON_11: int
MON_12: int
ABMON_1: int
ABMON_2: int
ABMON_3: int
ABMON_4: int
ABMON_5: int
ABMON_6: int
ABMON_7: int
ABMON_8: int
ABMON_9: int
ABMON_10: int
ABMON_11: int
ABMON_12: int
RADIXCHAR: int
THOUSEP: int
YESEXPR: int
NOEXPR: int
CRNCYSTR: int
ERA: int
ERA_D_T_FMT: int
ERA_D_FMT: int
ERA_T_FMT: int
ALT_DIGITS: int
LC_CTYPE: int
LC_COLLATE: int
LC_TIME: int
LC_MONETARY: int
LC_MESSAGES: int
LC_NUMERIC: int
LC_ALL: int
CHAR_MAX: int
class Error(Exception): ...
def setlocale(category: int, locale: Union[_str, Iterable[_str], None] = ...) -> _str: ...
def localeconv() -> Mapping[_str, Union[int, _str, List[int]]]: ...
def nl_langinfo(__key: int) -> _str: ...
def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> Tuple[Optional[_str], Optional[_str]]: ...
def getlocale(category: int = ...) -> Sequence[_str]: ...
def getpreferredencoding(do_setlocale: bool = ...) -> _str: ...
def normalize(localename: _str) -> _str: ...
def resetlocale(category: int = ...) -> None: ...
def strcoll(string1: _str, string2: _str) -> int: ...
def strxfrm(string: _str) -> _str: ...
def format(percent: _str, value: 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 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: ...
locale_alias: Dict[_str, _str] # undocumented
locale_encoding_alias: Dict[_str, _str] # undocumented
windows_locale: Dict[int, _str] # undocumented

104
stdlib/@python2/macpath.pyi Normal file
View File

@@ -0,0 +1,104 @@
import sys
from _typeshed import AnyPath, BytesPath, StrPath
from genericpath import (
commonprefix as commonprefix,
exists as exists,
getatime as getatime,
getctime as getctime,
getmtime as getmtime,
getsize as getsize,
isdir as isdir,
isfile as isfile,
)
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,
curdir as curdir,
defpath as defpath,
devnull as devnull,
expanduser as expanduser,
expandvars as expandvars,
extsep as extsep,
isabs as isabs,
lexists as lexists,
pardir as pardir,
pathsep as pathsep,
sep as sep,
splitdrive as splitdrive,
splitext as splitext,
supports_unicode_filenames as supports_unicode_filenames,
)
from typing import AnyStr, 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 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]: ...

View File

@@ -0,0 +1,5 @@
from typing import Union
def url2pathname(pathname: str) -> str: ...
def pathname2url(pathname: str) -> str: ...
def _pncomp2url(component: Union[str, bytes]) -> str: ...

203
stdlib/@python2/mailbox.pyi Normal file
View File

@@ -0,0 +1,203 @@
import email.message
import sys
from _typeshed import AnyPath
from types import TracebackType
from typing import (
IO,
Any,
AnyStr,
Callable,
Dict,
Generic,
Iterable,
Iterator,
List,
Mapping,
Optional,
Protocol,
Sequence,
Text,
Tuple,
Type,
TypeVar,
Union,
overload,
)
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]]
class _HasIteritems(Protocol):
def iteritems(self) -> Iterator[Tuple[str, _MessageData]]: ...
class _HasItems(Protocol):
def items(self) -> Iterator[Tuple[str, _MessageData]]: ...
linesep: bytes
class Mailbox(Generic[_MessageT]):
_path: Union[bytes, str] # undocumented
_factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented
def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ...) -> None: ...
def add(self, message: _MessageData) -> str: ...
def remove(self, key: str) -> None: ...
def __delitem__(self, key: str) -> None: ...
def discard(self, key: str) -> None: ...
def __setitem__(self, key: str, message: _MessageData) -> None: ...
@overload
def get(self, key: str, default: None = ...) -> Optional[_MessageT]: ...
@overload
def get(self, key: str, default: _T) -> Union[_MessageT, _T]: ...
def __getitem__(self, key: str) -> _MessageT: ...
def get_message(self, key: str) -> _MessageT: ...
def get_string(self, key: str) -> str: ...
def get_bytes(self, key: str) -> bytes: ...
# As '_ProxyFile' doesn't implement the full IO spec, and BytesIO is incompatible with it, get_file return is Any here
def get_file(self, key: str) -> Any: ...
def iterkeys(self) -> Iterator[str]: ...
def keys(self) -> List[str]: ...
def itervalues(self) -> Iterator[_MessageT]: ...
def __iter__(self) -> Iterator[_MessageT]: ...
def values(self) -> List[_MessageT]: ...
def iteritems(self) -> Iterator[Tuple[str, _MessageT]]: ...
def items(self) -> List[Tuple[str, _MessageT]]: ...
def __contains__(self, key: str) -> bool: ...
def __len__(self) -> int: ...
def clear(self) -> None: ...
@overload
def pop(self, key: str, default: None = ...) -> Optional[_MessageT]: ...
@overload
def pop(self, key: str, default: _T = ...) -> Union[_MessageT, _T]: ...
def popitem(self) -> Tuple[str, _MessageT]: ...
def update(self, arg: Optional[Union[_HasIteritems, _HasItems, Iterable[Tuple[str, _MessageData]]]] = ...) -> None: ...
def flush(self) -> None: ...
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
def __init__(
self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ...
) -> None: ...
def get_file(self, key: str) -> _ProxyFile[bytes]: ...
def list_folders(self) -> List[str]: ...
def get_folder(self, folder: Text) -> Maildir: ...
def add_folder(self, folder: Text) -> Maildir: ...
def remove_folder(self, folder: Text) -> None: ...
def clean(self) -> None: ...
def next(self) -> Optional[str]: ...
class _singlefileMailbox(Mailbox[_MessageT]): ...
class _mboxMMDF(_singlefileMailbox[_MessageT]):
def get_file(self, key: str, from_: bool = ...) -> _PartialFile[bytes]: ...
def get_bytes(self, key: str, from_: bool = ...) -> bytes: ...
def get_string(self, key: str, from_: bool = ...) -> str: ...
class mbox(_mboxMMDF[mboxMessage]):
def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ...
class MMDF(_mboxMMDF[MMDFMessage]):
def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ...
class MH(Mailbox[MHMessage]):
def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> _ProxyFile[bytes]: ...
def list_folders(self) -> List[str]: ...
def get_folder(self, folder: AnyPath) -> MH: ...
def add_folder(self, folder: AnyPath) -> MH: ...
def remove_folder(self, folder: AnyPath) -> None: ...
def get_sequences(self) -> Dict[str, List[int]]: ...
def set_sequences(self, sequences: Mapping[str, Sequence[int]]) -> None: ...
def pack(self) -> None: ...
class Babyl(_singlefileMailbox[BabylMessage]):
def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ...
def get_file(self, key: str) -> IO[bytes]: ...
def get_labels(self) -> List[str]: ...
class Message(email.message.Message):
def __init__(self, message: Optional[_MessageData] = ...) -> None: ...
class MaildirMessage(Message):
def get_subdir(self) -> str: ...
def set_subdir(self, subdir: Literal["new", "cur"]) -> None: ...
def get_flags(self) -> str: ...
def set_flags(self, flags: Iterable[str]) -> None: ...
def add_flag(self, flag: str) -> None: ...
def remove_flag(self, flag: str) -> None: ...
def get_date(self) -> int: ...
def set_date(self, date: float) -> None: ...
def get_info(self) -> str: ...
def set_info(self, info: str) -> None: ...
class _mboxMMDFMessage(Message):
def get_from(self) -> str: ...
def set_from(
self, from_: str, time_: Optional[Union[bool, Tuple[int, int, int, int, int, int, int, int, int]]] = ...
) -> None: ...
def get_flags(self) -> str: ...
def set_flags(self, flags: Iterable[str]) -> None: ...
def add_flag(self, flag: str) -> None: ...
def remove_flag(self, flag: str) -> None: ...
class mboxMessage(_mboxMMDFMessage): ...
class MHMessage(Message):
def get_sequences(self) -> List[str]: ...
def set_sequences(self, sequences: Iterable[str]) -> None: ...
def add_sequence(self, sequence: str) -> None: ...
def remove_sequence(self, sequence: str) -> None: ...
class BabylMessage(Message):
def get_labels(self) -> List[str]: ...
def set_labels(self, labels: Iterable[str]) -> None: ...
def add_label(self, label: str) -> None: ...
def remove_label(self, label: str) -> None: ...
def get_visible(self) -> Message: ...
def set_visible(self, visible: _MessageData) -> None: ...
def update_visible(self) -> None: ...
class MMDFMessage(_mboxMMDFMessage): ...
class _ProxyFile(Generic[AnyStr]):
def __init__(self, f: IO[AnyStr], pos: Optional[int] = ...) -> None: ...
def read(self, size: Optional[int] = ...) -> AnyStr: ...
def read1(self, size: Optional[int] = ...) -> AnyStr: ...
def readline(self, size: Optional[int] = ...) -> AnyStr: ...
def readlines(self, sizehint: Optional[int] = ...) -> List[AnyStr]: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def tell(self) -> int: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def close(self) -> None: ...
def __enter__(self) -> _ProxyFile[AnyStr]: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]
) -> None: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def seekable(self) -> bool: ...
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: ...
class Error(Exception): ...
class NoSuchMailboxError(Error): ...
class NotEmptyError(Error): ...
class ExternalClashError(Error): ...
class FormatError(Error): ...

Some files were not shown because too many files have changed in this diff Show More