From 5161ac2e5b73dc7597536eb4444219868317e5d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 19:50:28 -0700 Subject: [PATCH] Sync typeshed (#17124) Source commit: https://github.com/python/typeshed/commit/7c8e82fe483a40ec4cb0a2505cfdb0f3e7cc81d9 Co-authored-by: mypybot <> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: AlexWaygood --- mypy/typeshed/stdlib/_curses.pyi | 1091 +++++++++-------- mypy/typeshed/stdlib/asyncio/streams.pyi | 15 +- mypy/typeshed/stdlib/curses/__init__.pyi | 27 +- mypy/typeshed/stdlib/curses/ascii.pyi | 117 +- mypy/typeshed/stdlib/curses/has_key.pyi | 5 +- mypy/typeshed/stdlib/curses/panel.pyi | 41 +- mypy/typeshed/stdlib/curses/textpad.pyi | 18 +- .../stdlib/importlib/resources/simple.pyi | 15 +- mypy/typeshed/stdlib/io.pyi | 10 +- .../multiprocessing/resource_tracker.pyi | 4 +- mypy/typeshed/stdlib/multiprocessing/util.pyi | 31 +- mypy/typeshed/stdlib/ssl.pyi | 6 + mypy/typeshed/stdlib/typing.pyi | 10 +- mypy/typeshed/stdlib/typing_extensions.pyi | 8 +- mypy/typeshed/stdlib/winreg.pyi | 121 +- mypy/typeshed/stdlib/xml/dom/minidom.pyi | 4 +- mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi | 2 +- 17 files changed, 795 insertions(+), 730 deletions(-) diff --git a/mypy/typeshed/stdlib/_curses.pyi b/mypy/typeshed/stdlib/_curses.pyi index 929c6f8f3bc8..6f3fbd807fcc 100644 --- a/mypy/typeshed/stdlib/_curses.pyi +++ b/mypy/typeshed/stdlib/_curses.pyi @@ -3,557 +3,564 @@ from _typeshed import ReadOnlyBuffer, SupportsRead from typing import IO, Any, NamedTuple, final, overload from typing_extensions import TypeAlias -if sys.platform != "win32": - # Handled by PyCurses_ConvertToChtype in _cursesmodule.c. - _ChType: TypeAlias = str | bytes | int +# NOTE: This module is ordinarily only available on Unix, but the windows-curses +# package makes it available on Windows as well with the same contents. - # 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.platform != "darwin": - 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 - # Darwin ncurses doesn't provide BUTTON5_* constants - if sys.version_info >= (3, 10) and sys.platform != "darwin": - BUTTON5_PRESSED: int - BUTTON5_RELEASED: int - BUTTON5_CLICKED: int - BUTTON5_DOUBLE_CLICKED: int - BUTTON5_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 = True, /) -> None: ... - def color_content(color_number: int, /) -> tuple[int, int, int]: ... - def color_pair(pair_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 = True, /) -> None: ... - def endwin() -> None: ... - def erasechar() -> bytes: ... - def filter() -> None: ... - def flash() -> None: ... - def flushinp() -> None: ... - if sys.version_info >= (3, 9): - def get_escdelay() -> int: ... - def get_tabsize() -> int: ... +# Handled by PyCurses_ConvertToChtype in _cursesmodule.c. +_ChType: TypeAlias = str | bytes | int - def getmouse() -> tuple[int, int, int, int, int]: ... - def getsyx() -> tuple[int, int]: ... - def getwin(file: SupportsRead[bytes], /) -> _CursesWindow: ... - def halfdelay(tenths: int, /) -> None: ... - def has_colors() -> bool: ... - if sys.version_info >= (3, 10): - def has_extended_color_support() -> bool: ... +# 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.platform != "darwin": + 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 +# Darwin ncurses doesn't provide BUTTON5_* constants +if sys.version_info >= (3, 10) and sys.platform != "darwin": + BUTTON5_PRESSED: int + BUTTON5_RELEASED: int + BUTTON5_CLICKED: int + BUTTON5_DOUBLE_CLICKED: int + BUTTON5_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 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 = True, /) -> 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: ReadOnlyBuffer, /) -> None: ... - def qiflush(flag: bool = True, /) -> None: ... - def raw(flag: bool = True, /) -> 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: ... - if sys.version_info >= (3, 9): - def set_escdelay(ms: int, /) -> None: ... - def set_tabsize(size: int, /) -> None: ... +def baudrate() -> int: ... +def beep() -> None: ... +def can_change_color() -> bool: ... +def cbreak(flag: bool = True, /) -> None: ... +def color_content(color_number: int, /) -> tuple[int, int, int]: ... +def color_pair(pair_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 = True, /) -> None: ... +def endwin() -> None: ... +def erasechar() -> bytes: ... +def filter() -> None: ... +def flash() -> None: ... +def flushinp() -> None: ... - def setsyx(y: int, x: int, /) -> None: ... - def setupterm(term: str | None = None, fd: int = -1) -> 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 | None: ... - def tparm( - str: ReadOnlyBuffer, - i1: int = 0, - i2: int = 0, - i3: int = 0, - i4: int = 0, - i5: int = 0, - i6: int = 0, - i7: int = 0, - i8: int = 0, - i9: int = 0, - /, - ) -> bytes: ... - def typeahead(fd: int, /) -> None: ... - def unctrl(ch: _ChType, /) -> bytes: ... - if sys.version_info < (3, 12) or sys.platform != "darwin": - # The support for macos was dropped in 3.12 - def unget_wch(ch: int | str, /) -> None: ... +if sys.version_info >= (3, 9): + def get_escdelay() -> int: ... + def get_tabsize() -> int: ... - def ungetch(ch: _ChType, /) -> None: ... - def ungetmouse(id: int, x: int, y: int, z: int, bstate: int, /) -> None: ... - def update_lines_cols() -> None: ... - def use_default_colors() -> None: ... - def use_env(flag: bool, /) -> None: ... +def getmouse() -> tuple[int, int, int, int, int]: ... +def getsyx() -> tuple[int, int]: ... +def getwin(file: SupportsRead[bytes], /) -> _CursesWindow: ... +def halfdelay(tenths: int, /) -> None: ... +def has_colors() -> bool: ... - class error(Exception): ... +if sys.version_info >= (3, 10): + def has_extended_color_support() -> bool: ... - @final - class _CursesWindow: - 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, 12) or sys.platform != "darwin": - # The support for macos was dropped in 3.12 - @overload - def get_wch(self) -> int | str: ... - @overload - def get_wch(self, y: int, x: int) -> int | str: ... +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 = True, /) -> 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: ReadOnlyBuffer, /) -> None: ... +def qiflush(flag: bool = True, /) -> None: ... +def raw(flag: bool = True, /) -> 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: ... +if sys.version_info >= (3, 9): + def set_escdelay(ms: int, /) -> None: ... + def set_tabsize(size: int, /) -> None: ... + +def setsyx(y: int, x: int, /) -> None: ... +def setupterm(term: str | None = None, fd: int = -1) -> 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 | None: ... +def tparm( + str: ReadOnlyBuffer, + i1: int = 0, + i2: int = 0, + i3: int = 0, + i4: int = 0, + i5: int = 0, + i6: int = 0, + i7: int = 0, + i8: int = 0, + i9: int = 0, + /, +) -> bytes: ... +def typeahead(fd: int, /) -> None: ... +def unctrl(ch: _ChType, /) -> bytes: ... + +if sys.version_info < (3, 12) or sys.platform != "darwin": + # The support for macos was dropped in 3.12 + def unget_wch(ch: int | str, /) -> None: ... + +def ungetch(ch: _ChType, /) -> None: ... +def ungetmouse(id: int, x: int, y: int, z: int, bstate: int, /) -> None: ... +def update_lines_cols() -> None: ... +def use_default_colors() -> None: ... +def use_env(flag: bool, /) -> None: ... + +class error(Exception): ... + +@final +class _CursesWindow: + 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, 12) or sys.platform != "darwin": + # The support for macos was dropped in 3.12 @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) -> bytes: ... - @overload - def getstr(self, n: int) -> bytes: ... - @overload - def getstr(self, y: int, x: int) -> bytes: ... - @overload - def getstr(self, y: int, x: int, n: int) -> bytes: ... - 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) -> int: ... - @overload - def inch(self, y: int, x: int) -> int: ... - @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 = ...) -> bytes: ... - @overload - def instr(self, y: int, x: int, n: int = ...) -> bytes: ... - 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: ... - @overload - def noutrefresh(self) -> None: ... - @overload - def noutrefresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> 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: ... + def get_wch(self) -> int | str: ... @overload - def vline(self, y: int, x: int, ch: _ChType, n: int) -> None: ... + def get_wch(self, y: int, x: int) -> 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) -> bytes: ... + @overload + def getstr(self, n: int) -> bytes: ... + @overload + def getstr(self, y: int, x: int) -> bytes: ... + @overload + def getstr(self, y: int, x: int, n: int) -> bytes: ... + 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) -> int: ... + @overload + def inch(self, y: int, x: int) -> int: ... + @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 = ...) -> bytes: ... + @overload + def instr(self, y: int, x: int, n: int = ...) -> bytes: ... + 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: ... + @overload + def noutrefresh(self) -> None: ... + @overload + def noutrefresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> 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: ... - class _ncurses_version(NamedTuple): - major: int - minor: int - patch: int +class _ncurses_version(NamedTuple): + major: int + minor: int + patch: int - ncurses_version: _ncurses_version - window = _CursesWindow # undocumented +ncurses_version: _ncurses_version +window = _CursesWindow # undocumented diff --git a/mypy/typeshed/stdlib/asyncio/streams.pyi b/mypy/typeshed/stdlib/asyncio/streams.pyi index 4dff8d28b616..c3cc7b8c9e5a 100644 --- a/mypy/typeshed/stdlib/asyncio/streams.pyi +++ b/mypy/typeshed/stdlib/asyncio/streams.pyi @@ -1,8 +1,8 @@ import ssl import sys -from _typeshed import StrPath -from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence -from typing import Any, SupportsIndex +from _typeshed import ReadableBuffer, StrPath +from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence, Sized +from typing import Any, Protocol, SupportsIndex from typing_extensions import Self, TypeAlias from . import events, protocols, transports @@ -23,6 +23,8 @@ else: _ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None] +class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ... + if sys.version_info >= (3, 10): async def open_connection( host: str | None = None, @@ -140,8 +142,11 @@ class StreamReader(AsyncIterator[bytes]): def at_eof(self) -> bool: ... def feed_data(self, data: Iterable[SupportsIndex]) -> None: ... async def readline(self) -> bytes: ... - # Can be any buffer that supports len(); consider changing to a Protocol if PEP 688 is accepted - async def readuntil(self, separator: bytes | bytearray | memoryview = b"\n") -> bytes: ... + if sys.version_info >= (3, 13): + async def readuntil(self, separator: _ReaduntilBuffer | tuple[_ReaduntilBuffer, ...] = b"\n") -> bytes: ... + else: + async def readuntil(self, separator: _ReaduntilBuffer = b"\n") -> bytes: ... + async def read(self, n: int = -1) -> bytes: ... async def readexactly(self, n: int) -> bytes: ... def __aiter__(self) -> Self: ... diff --git a/mypy/typeshed/stdlib/curses/__init__.pyi b/mypy/typeshed/stdlib/curses/__init__.pyi index 2a82ae9bda22..1df184dbaa60 100644 --- a/mypy/typeshed/stdlib/curses/__init__.pyi +++ b/mypy/typeshed/stdlib/curses/__init__.pyi @@ -1,21 +1,22 @@ -import sys +from _curses import * +from _curses import _CursesWindow as _CursesWindow from collections.abc import Callable from typing import TypeVar from typing_extensions import Concatenate, ParamSpec -if sys.platform != "win32": - from _curses import * - from _curses import _CursesWindow as _CursesWindow +# NOTE: The _curses module is ordinarily only available on Unix, but the +# windows-curses package makes it available on Windows as well with the same +# contents. - _T = TypeVar("_T") - _P = ParamSpec("_P") +_T = TypeVar("_T") +_P = ParamSpec("_P") - # available after calling `curses.initscr()` - LINES: int - COLS: int +# available after calling `curses.initscr()` +LINES: int +COLS: int - # available after calling `curses.start_color()` - COLORS: int - COLOR_PAIRS: int +# available after calling `curses.start_color()` +COLORS: int +COLOR_PAIRS: int - def wrapper(func: Callable[Concatenate[_CursesWindow, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ... +def wrapper(func: Callable[Concatenate[_CursesWindow, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ... diff --git a/mypy/typeshed/stdlib/curses/ascii.pyi b/mypy/typeshed/stdlib/curses/ascii.pyi index 25de8f605bda..66efbe36a7df 100644 --- a/mypy/typeshed/stdlib/curses/ascii.pyi +++ b/mypy/typeshed/stdlib/curses/ascii.pyi @@ -1,63 +1,62 @@ -import sys from typing import TypeVar -if sys.platform != "win32": - _CharT = TypeVar("_CharT", str, int) +_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 +NUL: int +SOH: int +STX: int +ETX: int +EOT: int +ENQ: int +ACK: int +BEL: int +BS: int +TAB: int +HT: int +LF: int +NL: int +VT: int +FF: int +CR: int +SO: int +SI: int +DLE: int +DC1: int +DC2: int +DC3: int +DC4: int +NAK: int +SYN: int +ETB: int +CAN: int +EM: int +SUB: int +ESC: int +FS: int +GS: int +RS: int +US: int +SP: int +DEL: int - controlnames: list[int] - def isalnum(c: str | int) -> bool: ... - def isalpha(c: str | int) -> bool: ... - def isascii(c: str | int) -> bool: ... - def isblank(c: str | int) -> bool: ... - def iscntrl(c: str | int) -> bool: ... - def isdigit(c: str | int) -> bool: ... - def isgraph(c: str | int) -> bool: ... - def islower(c: str | int) -> bool: ... - def isprint(c: str | int) -> bool: ... - def ispunct(c: str | int) -> bool: ... - def isspace(c: str | int) -> bool: ... - def isupper(c: str | int) -> bool: ... - def isxdigit(c: str | int) -> bool: ... - def isctrl(c: str | int) -> bool: ... - def ismeta(c: str | int) -> bool: ... - def ascii(c: _CharT) -> _CharT: ... - def ctrl(c: _CharT) -> _CharT: ... - def alt(c: _CharT) -> _CharT: ... - def unctrl(c: str | int) -> str: ... +controlnames: list[int] + +def isalnum(c: str | int) -> bool: ... +def isalpha(c: str | int) -> bool: ... +def isascii(c: str | int) -> bool: ... +def isblank(c: str | int) -> bool: ... +def iscntrl(c: str | int) -> bool: ... +def isdigit(c: str | int) -> bool: ... +def isgraph(c: str | int) -> bool: ... +def islower(c: str | int) -> bool: ... +def isprint(c: str | int) -> bool: ... +def ispunct(c: str | int) -> bool: ... +def isspace(c: str | int) -> bool: ... +def isupper(c: str | int) -> bool: ... +def isxdigit(c: str | int) -> bool: ... +def isctrl(c: str | int) -> bool: ... +def ismeta(c: str | int) -> bool: ... +def ascii(c: _CharT) -> _CharT: ... +def ctrl(c: _CharT) -> _CharT: ... +def alt(c: _CharT) -> _CharT: ... +def unctrl(c: str | int) -> str: ... diff --git a/mypy/typeshed/stdlib/curses/has_key.pyi b/mypy/typeshed/stdlib/curses/has_key.pyi index ff728aedf84b..3811060b916a 100644 --- a/mypy/typeshed/stdlib/curses/has_key.pyi +++ b/mypy/typeshed/stdlib/curses/has_key.pyi @@ -1,4 +1 @@ -import sys - -if sys.platform != "win32": - def has_key(ch: int | str) -> bool: ... +def has_key(ch: int | str) -> bool: ... diff --git a/mypy/typeshed/stdlib/curses/panel.pyi b/mypy/typeshed/stdlib/curses/panel.pyi index 403ae9b50019..3d3448bd9584 100644 --- a/mypy/typeshed/stdlib/curses/panel.pyi +++ b/mypy/typeshed/stdlib/curses/panel.pyi @@ -1,25 +1,22 @@ -import sys +from _curses import _CursesWindow -if sys.platform != "win32": - from _curses import _CursesWindow +version: str - version: str +class _Curses_Panel: # type is (note the space in the class name) + def above(self) -> _Curses_Panel: ... + def below(self) -> _Curses_Panel: ... + def bottom(self) -> None: ... + def hidden(self) -> bool: ... + def hide(self) -> None: ... + def move(self, y: int, x: int) -> None: ... + def replace(self, win: _CursesWindow) -> None: ... + def set_userptr(self, obj: object) -> None: ... + def show(self) -> None: ... + def top(self) -> None: ... + def userptr(self) -> object: ... + def window(self) -> _CursesWindow: ... - class _Curses_Panel: # type is (note the space in the class name) - def above(self) -> _Curses_Panel: ... - def below(self) -> _Curses_Panel: ... - def bottom(self) -> None: ... - def hidden(self) -> bool: ... - def hide(self) -> None: ... - def move(self, y: int, x: int) -> None: ... - def replace(self, win: _CursesWindow) -> None: ... - def set_userptr(self, obj: object) -> None: ... - def show(self) -> None: ... - def top(self) -> None: ... - def userptr(self) -> object: ... - def window(self) -> _CursesWindow: ... - - def bottom_panel() -> _Curses_Panel: ... - def new_panel(win: _CursesWindow, /) -> _Curses_Panel: ... - def top_panel() -> _Curses_Panel: ... - def update_panels() -> _Curses_Panel: ... +def bottom_panel() -> _Curses_Panel: ... +def new_panel(win: _CursesWindow, /) -> _Curses_Panel: ... +def top_panel() -> _Curses_Panel: ... +def update_panels() -> _Curses_Panel: ... diff --git a/mypy/typeshed/stdlib/curses/textpad.pyi b/mypy/typeshed/stdlib/curses/textpad.pyi index 4d28b4dfbcdc..ce6eed09b289 100644 --- a/mypy/typeshed/stdlib/curses/textpad.pyi +++ b/mypy/typeshed/stdlib/curses/textpad.pyi @@ -1,13 +1,11 @@ -import sys +from _curses import _CursesWindow from collections.abc import Callable -if sys.platform != "win32": - from _curses import _CursesWindow - def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... +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 = False) -> None: ... - def edit(self, validate: Callable[[int], int] | None = None) -> str: ... - def do_command(self, ch: str | int) -> None: ... - def gather(self) -> str: ... +class Textbox: + stripspaces: bool + def __init__(self, win: _CursesWindow, insert_mode: bool = False) -> None: ... + def edit(self, validate: Callable[[int], int] | None = None) -> str: ... + def do_command(self, ch: str | int) -> None: ... + def gather(self) -> str: ... diff --git a/mypy/typeshed/stdlib/importlib/resources/simple.pyi b/mypy/typeshed/stdlib/importlib/resources/simple.pyi index c360da96d856..c4c758111c2d 100644 --- a/mypy/typeshed/stdlib/importlib/resources/simple.pyi +++ b/mypy/typeshed/stdlib/importlib/resources/simple.pyi @@ -1,6 +1,5 @@ import abc import sys -from _typeshed import Incomplete, OpenBinaryMode, OpenTextMode, Unused from collections.abc import Iterator from io import TextIOWrapper from typing import IO, Any, BinaryIO, Literal, NoReturn, overload @@ -28,11 +27,19 @@ if sys.version_info >= (3, 11): def is_file(self) -> Literal[True]: ... def is_dir(self) -> Literal[False]: ... @overload - def open(self, mode: OpenTextMode = "r", *args, **kwargs) -> TextIOWrapper: ... + def open( + self, + mode: Literal["r"] = "r", + encoding: str | None = None, + errors: str | None = None, + newline: str | None = None, + line_buffering: bool = False, + write_through: bool = False, + ) -> TextIOWrapper: ... @overload - def open(self, mode: OpenBinaryMode, *args: Unused, **kwargs: Unused) -> BinaryIO: ... + def open(self, mode: Literal["rb"]) -> BinaryIO: ... @overload - def open(self, mode: str, *args: Incomplete, **kwargs) -> IO[Any]: ... + def open(self, mode: str) -> IO[Any]: ... def joinpath(self, name: Never) -> NoReturn: ... # type: ignore[override] class ResourceContainer(Traversable, metaclass=abc.ABCMeta): diff --git a/mypy/typeshed/stdlib/io.pyi b/mypy/typeshed/stdlib/io.pyi index e7ed1b0b5ee5..fdbbc8dddce9 100644 --- a/mypy/typeshed/stdlib/io.pyi +++ b/mypy/typeshed/stdlib/io.pyi @@ -179,11 +179,11 @@ class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible d def __init__( self, buffer: _WrappedBuffer, - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., - line_buffering: bool = ..., - write_through: bool = ..., + encoding: str | None = None, + errors: str | None = None, + newline: str | None = None, + line_buffering: bool = False, + write_through: bool = False, ) -> None: ... # Equals the "buffer" argument passed in to the constructor. @property diff --git a/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi b/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi index 78ad79cf925f..61da7fdf1ceb 100644 --- a/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi @@ -6,8 +6,8 @@ __all__ = ["ensure_running", "register", "unregister"] class ResourceTracker: def getfd(self) -> int | None: ... def ensure_running(self) -> None: ... - def register(self, name: Sized, rtype) -> None: ... - def unregister(self, name: Sized, rtype) -> None: ... + def register(self, name: Sized, rtype: str) -> None: ... + def unregister(self, name: Sized, rtype: str) -> None: ... _resource_tracker: ResourceTracker ensure_running = _resource_tracker.ensure_running diff --git a/mypy/typeshed/stdlib/multiprocessing/util.pyi b/mypy/typeshed/stdlib/multiprocessing/util.pyi index 8b900996f9eb..790d6c7467f0 100644 --- a/mypy/typeshed/stdlib/multiprocessing/util.pyi +++ b/mypy/typeshed/stdlib/multiprocessing/util.pyi @@ -2,7 +2,7 @@ import threading from _typeshed import ConvertibleToInt, Incomplete, Unused from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from logging import Logger, _Level as _LoggingLevel -from typing import Any +from typing import Any, Generic, TypeVar, overload __all__ = [ "sub_debug", @@ -22,6 +22,9 @@ __all__ = [ "SUBWARNING", ] +_T = TypeVar("_T") +_R_co = TypeVar("_R_co", default=Any, covariant=True) + NOTSET: int SUBDEBUG: int DEBUG: int @@ -42,13 +45,29 @@ def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ... abstract_sockets_supported: bool def get_temp_dir() -> str: ... -def register_after_fork(obj, func: Callable[[Incomplete], object]) -> None: ... +def register_after_fork(obj: _T, func: Callable[[_T], object]) -> None: ... -class Finalize: +class Finalize(Generic[_R_co]): + # "args" and "kwargs" are passed as arguments to "callback". + @overload + def __init__( + self, + obj: None, + callback: Callable[..., _R_co], + *, + args: Sequence[Any] = (), + kwargs: Mapping[str, Any] | None = None, + exitpriority: int, + ) -> None: ... + @overload + def __init__( + self, obj: None, callback: Callable[..., _R_co], args: Sequence[Any], kwargs: Mapping[str, Any] | None, exitpriority: int + ) -> None: ... + @overload def __init__( self, - obj: Incomplete | None, - callback: Callable[..., Incomplete], + obj: Any, + callback: Callable[..., _R_co], args: Sequence[Any] = (), kwargs: Mapping[str, Any] | None = None, exitpriority: int | None = None, @@ -59,7 +78,7 @@ class Finalize: _finalizer_registry: MutableMapping[Incomplete, Incomplete] = {}, sub_debug: Callable[..., object] = ..., getpid: Callable[[], int] = ..., - ): ... + ) -> _R_co: ... def cancel(self) -> None: ... def still_active(self) -> bool: ... diff --git a/mypy/typeshed/stdlib/ssl.pyi b/mypy/typeshed/stdlib/ssl.pyi index b2263df1337d..15d86372531a 100644 --- a/mypy/typeshed/stdlib/ssl.pyi +++ b/mypy/typeshed/stdlib/ssl.pyi @@ -366,6 +366,9 @@ class SSLSocket(socket.socket): def recvmsg(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] def recvmsg_into(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] def sendmsg(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] + if sys.version_info >= (3, 13): + def get_verified_chain(self) -> list[bytes]: ... + def get_unverified_chain(self) -> list[bytes]: ... class TLSVersion(enum.IntEnum): MINIMUM_SUPPORTED: int @@ -476,6 +479,9 @@ class SSLObject: def version(self) -> str | None: ... def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ... def verify_client_post_handshake(self) -> None: ... + if sys.version_info >= (3, 13): + def get_verified_chain(self) -> list[bytes]: ... + def get_unverified_chain(self) -> list[bytes]: ... @final class MemoryBIO: diff --git a/mypy/typeshed/stdlib/typing.pyi b/mypy/typeshed/stdlib/typing.pyi index a2294f2f579f..580322b653b4 100644 --- a/mypy/typeshed/stdlib/typing.pyi +++ b/mypy/typeshed/stdlib/typing.pyi @@ -170,7 +170,7 @@ class TypeVar: def __or__(self, right: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ... if sys.version_info >= (3, 11): - def __typing_subst__(self, arg): ... + def __typing_subst__(self, arg: Any) -> Any: ... # Used for an undocumented mypy feature. Does not exist at runtime. _promote = object() @@ -221,7 +221,7 @@ if sys.version_info >= (3, 11): def __init__(self, name: str) -> None: ... def __iter__(self) -> Any: ... def __typing_subst__(self, arg: Never) -> Never: ... - def __typing_prepare_subst__(self, alias, args): ... + def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... if sys.version_info >= (3, 10): @final @@ -270,8 +270,8 @@ if sys.version_info >= (3, 10): @property def kwargs(self) -> ParamSpecKwargs: ... if sys.version_info >= (3, 11): - def __typing_subst__(self, arg): ... - def __typing_prepare_subst__(self, alias, args): ... + def __typing_subst__(self, arg: Any) -> Any: ... + def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ... def __or__(self, right: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ... @@ -290,7 +290,7 @@ if sys.version_info >= (3, 10): def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... - __supertype__: type + __supertype__: type | NewType else: def NewType(name: str, tp: Any) -> Any: ... diff --git a/mypy/typeshed/stdlib/typing_extensions.pyi b/mypy/typeshed/stdlib/typing_extensions.pyi index cb67eb612a71..48a398ba4095 100644 --- a/mypy/typeshed/stdlib/typing_extensions.pyi +++ b/mypy/typeshed/stdlib/typing_extensions.pyi @@ -374,7 +374,7 @@ else: class NewType: def __init__(self, name: str, tp: Any) -> None: ... def __call__(self, obj: _T, /) -> _T: ... - __supertype__: type + __supertype__: type | NewType if sys.version_info >= (3, 10): def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... @@ -413,7 +413,7 @@ class TypeVar: def __or__(self, right: Any) -> _SpecialForm: ... def __ror__(self, left: Any) -> _SpecialForm: ... if sys.version_info >= (3, 11): - def __typing_subst__(self, arg): ... + def __typing_subst__(self, arg: Any) -> Any: ... @final class ParamSpec: @@ -453,10 +453,10 @@ class TypeVarTuple: def __iter__(self) -> Any: ... # Unpack[Self] class deprecated: - message: str + message: LiteralString category: type[Warning] | None stacklevel: int - def __init__(self, message: str, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ... + def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ... def __call__(self, arg: _T, /) -> _T: ... if sys.version_info >= (3, 12): diff --git a/mypy/typeshed/stdlib/winreg.pyi b/mypy/typeshed/stdlib/winreg.pyi index ffb0a4cb8094..d4d04817d7e0 100644 --- a/mypy/typeshed/stdlib/winreg.pyi +++ b/mypy/typeshed/stdlib/winreg.pyi @@ -1,6 +1,7 @@ import sys +from _typeshed import ReadableBuffer, Unused from types import TracebackType -from typing import Any, Literal, final +from typing import Any, Final, Literal, final, overload from typing_extensions import Self, TypeAlias if sys.platform == "win32": @@ -24,12 +25,40 @@ if sys.platform == "win32": def QueryValueEx(key: _KeyType, name: str, /) -> tuple[Any, int]: ... def SaveKey(key: _KeyType, file_name: str, /) -> None: ... def SetValue(key: _KeyType, sub_key: str, type: int, value: str, /) -> None: ... + @overload # type=REG_DWORD|REG_QWORD def SetValueEx( - key: _KeyType, value_name: str | None, reserved: Any, type: int, value: str | int, / - ) -> None: ... # reserved is ignored + key: _KeyType, value_name: str | None, reserved: Unused, type: Literal[4, 5], value: int | None, / + ) -> None: ... + @overload # type=REG_SZ|REG_EXPAND_SZ + def SetValueEx( + key: _KeyType, value_name: str | None, reserved: Unused, type: Literal[1, 2], value: str | None, / + ) -> None: ... + @overload # type=REG_MULTI_SZ + def SetValueEx( + key: _KeyType, value_name: str | None, reserved: Unused, type: Literal[7], value: list[str] | None, / + ) -> None: ... + @overload # type=REG_BINARY and everything else + def SetValueEx( + key: _KeyType, + value_name: str | None, + reserved: Unused, + type: Literal[0, 3, 8, 9, 10, 11], + value: ReadableBuffer | None, + /, + ) -> None: ... + @overload # Unknown or undocumented + def SetValueEx( + key: _KeyType, + value_name: str | None, + reserved: Unused, + type: int, + value: int | str | list[str] | ReadableBuffer | None, + /, + ) -> None: ... def DisableReflectionKey(key: _KeyType, /) -> None: ... def EnableReflectionKey(key: _KeyType, /) -> None: ... def QueryReflectionKey(key: _KeyType, /) -> bool: ... + HKEY_CLASSES_ROOT: int HKEY_CURRENT_USER: int HKEY_LOCAL_MACHINE: int @@ -38,52 +67,52 @@ if sys.platform == "win32": HKEY_CURRENT_CONFIG: int HKEY_DYN_DATA: int - KEY_ALL_ACCESS: Literal[983103] - KEY_WRITE: Literal[131078] - KEY_READ: Literal[131097] - KEY_EXECUTE: Literal[131097] - KEY_QUERY_VALUE: Literal[1] - KEY_SET_VALUE: Literal[2] - KEY_CREATE_SUB_KEY: Literal[4] - KEY_ENUMERATE_SUB_KEYS: Literal[8] - KEY_NOTIFY: Literal[16] - KEY_CREATE_LINK: Literal[32] + KEY_ALL_ACCESS: Final = 983103 + KEY_WRITE: Final = 131078 + KEY_READ: Final = 131097 + KEY_EXECUTE: Final = 131097 + KEY_QUERY_VALUE: Final = 1 + KEY_SET_VALUE: Final = 2 + KEY_CREATE_SUB_KEY: Final = 4 + KEY_ENUMERATE_SUB_KEYS: Final = 8 + KEY_NOTIFY: Final = 16 + KEY_CREATE_LINK: Final = 32 - KEY_WOW64_64KEY: Literal[256] - KEY_WOW64_32KEY: Literal[512] + KEY_WOW64_64KEY: Final = 256 + KEY_WOW64_32KEY: Final = 512 - REG_BINARY: Literal[3] - REG_DWORD: Literal[4] - REG_DWORD_LITTLE_ENDIAN: Literal[4] - REG_DWORD_BIG_ENDIAN: Literal[5] - REG_EXPAND_SZ: Literal[2] - REG_LINK: Literal[6] - REG_MULTI_SZ: Literal[7] - REG_NONE: Literal[0] - REG_QWORD: Literal[11] - REG_QWORD_LITTLE_ENDIAN: Literal[11] - REG_RESOURCE_LIST: Literal[8] - REG_FULL_RESOURCE_DESCRIPTOR: Literal[9] - REG_RESOURCE_REQUIREMENTS_LIST: Literal[10] - REG_SZ: Literal[1] + REG_BINARY: Final = 3 + REG_DWORD: Final = 4 + REG_DWORD_LITTLE_ENDIAN: Final = 4 + REG_DWORD_BIG_ENDIAN: Final = 5 + REG_EXPAND_SZ: Final = 2 + REG_LINK: Final = 6 + REG_MULTI_SZ: Final = 7 + REG_NONE: Final = 0 + REG_QWORD: Final = 11 + REG_QWORD_LITTLE_ENDIAN: Final = 11 + REG_RESOURCE_LIST: Final = 8 + REG_FULL_RESOURCE_DESCRIPTOR: Final = 9 + REG_RESOURCE_REQUIREMENTS_LIST: Final = 10 + REG_SZ: Final = 1 - REG_CREATED_NEW_KEY: int # undocumented - REG_LEGAL_CHANGE_FILTER: int # undocumented - REG_LEGAL_OPTION: int # undocumented - REG_NOTIFY_CHANGE_ATTRIBUTES: int # undocumented - REG_NOTIFY_CHANGE_LAST_SET: int # undocumented - REG_NOTIFY_CHANGE_NAME: int # undocumented - REG_NOTIFY_CHANGE_SECURITY: int # undocumented - REG_NO_LAZY_FLUSH: int # undocumented - REG_OPENED_EXISTING_KEY: int # undocumented - REG_OPTION_BACKUP_RESTORE: int # undocumented - REG_OPTION_CREATE_LINK: int # undocumented - REG_OPTION_NON_VOLATILE: int # undocumented - REG_OPTION_OPEN_LINK: int # undocumented - REG_OPTION_RESERVED: int # undocumented - REG_OPTION_VOLATILE: int # undocumented - REG_REFRESH_HIVE: int # undocumented - REG_WHOLE_HIVE_VOLATILE: int # undocumented + REG_CREATED_NEW_KEY: Final = 1 # undocumented + REG_LEGAL_CHANGE_FILTER: Final = 268435471 # undocumented + REG_LEGAL_OPTION: Final = 31 # undocumented + REG_NOTIFY_CHANGE_ATTRIBUTES: Final = 2 # undocumented + REG_NOTIFY_CHANGE_LAST_SET: Final = 4 # undocumented + REG_NOTIFY_CHANGE_NAME: Final = 1 # undocumented + REG_NOTIFY_CHANGE_SECURITY: Final = 8 # undocumented + REG_NO_LAZY_FLUSH: Final = 4 # undocumented + REG_OPENED_EXISTING_KEY: Final = 2 # undocumented + REG_OPTION_BACKUP_RESTORE: Final = 4 # undocumented + REG_OPTION_CREATE_LINK: Final = 2 # undocumented + REG_OPTION_NON_VOLATILE: Final = 0 # undocumented + REG_OPTION_OPEN_LINK: Final = 8 # undocumented + REG_OPTION_RESERVED: Final = 0 # undocumented + REG_OPTION_VOLATILE: Final = 1 # undocumented + REG_REFRESH_HIVE: Final = 2 # undocumented + REG_WHOLE_HIVE_VOLATILE: Final = 1 # undocumented error = OSError diff --git a/mypy/typeshed/stdlib/xml/dom/minidom.pyi b/mypy/typeshed/stdlib/xml/dom/minidom.pyi index 28bfa1b36924..fae2c4d98714 100644 --- a/mypy/typeshed/stdlib/xml/dom/minidom.pyi +++ b/mypy/typeshed/stdlib/xml/dom/minidom.pyi @@ -256,9 +256,9 @@ class Text(CharacterData): nodeName: str attributes: Incomplete data: Incomplete - def splitText(self, offset): ... + def splitText(self, offset: int) -> Self: ... def writexml(self, writer: SupportsWrite[str], indent: str = "", addindent: str = "", newl: str = "") -> None: ... - def replaceWholeText(self, content): ... + def replaceWholeText(self, content) -> Self | None: ... @property def isWhitespaceInElementContent(self) -> bool: ... @property diff --git a/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi b/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi index 62ca7dd9fc45..ab76d362e23f 100644 --- a/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi +++ b/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi @@ -60,7 +60,7 @@ class DOMBuilder: def supportsFeature(self, name: str) -> bool: ... def canSetFeature(self, name: str, state: int) -> bool: ... # getFeature could return any attribute from an instance of `Options` - def getFeature(self, name: str): ... + def getFeature(self, name: str) -> Any: ... def parseURI(self, uri: str) -> ExpatBuilder | ExpatBuilderNS: ... def parse(self, input: DOMInputSource) -> ExpatBuilder | ExpatBuilderNS: ... # `input` and `cnode` argtypes for `parseWithContext` are unknowable