Improvements to stdlib/3/_curses.pyi - take 3 (#1772)

* Added missing annotation for start_color() and wrapper() functions

* 1) Changed Optional types to be optional arguments (checked documentation and manual experiments to make sure I was doing it right)

2) Modified format to match CONTRIBUTING.md conventions

3) corrected a few missing return types or other mistaken type
annotations
This commit is contained in:
gossrock
2017-12-15 04:38:39 +00:00
committed by Jelle Zijlstra
parent 1dccd1fdc4
commit cb1d150092
2 changed files with 68 additions and 138 deletions

View File

@@ -234,7 +234,7 @@ def flash() -> None: ...
def flushinp() -> None: ...
def getmouse() -> Tuple[int, int, int, int, int]: ...
def getsyx() -> Tuple[int, int]: ...
def getwin(f: BinaryIO): ...
def getwin(f: BinaryIO) -> _CursesWindow: ...
def halfdelay(tenths: int) -> None: ...
def has_colors() -> bool: ...
def has_ic() -> bool: ...
@@ -253,7 +253,7 @@ def meta(yes: bool) -> None: ...
def mouseinterval(interval: int) -> None: ...
def mousemask(mousemask: int) -> Tuple[int, int]: ...
def napms(ms: int) -> int: ...
def newpad(nlines: int, ncols: 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: ...
@@ -292,227 +292,156 @@ def use_env(flag: bool) -> None: ...
class error(Exception): ...
class _CursesWindow:
encoding = ... # type: str
@overload
def addch(self, ch: _chtype, attr: Optional[int]) -> None: ...
def addch(self, ch: _chtype, attr: int = ...) -> None: ...
@overload
def addch(self, y: int, x: int, ch: _chtype, attr: Optional[int]) -> None: ...
def addch(self, y: int, x: int, ch: _chtype, attr: int = ...) -> None: ...
@overload
def addnstr(self, str: str, n: int, attr: Optional[int]) -> None: ...
def addnstr(self, str: str, n: int, attr: int = ...) -> None: ...
@overload
def addnstr(self, y: int, x: int, str: str, n: int, attr: Optional[int]) -> None: ...
def addnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
@overload
def addstr(self, str: str, attr: Optional[int]) -> None: ...
def addstr(self, str: str, attr: int = ...) -> None: ...
@overload
def addstr(self, y: int, x: int, str: str, attr: Optional[int]) -> None: ...
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: Optional[int]) -> None: ...
def bkgset(self, ch: _chtype, attr: Optional[int]) -> None: ...
def border(self, ls: Optional[int], rs: Optional[int],
ts: Optional[int], bs: Optional[int],
tl: Optional[int], tr: Optional[int],
bl: Optional[int], br: Optional[int]) -> None: ...
def box(self, vertch: Optional[Tuple[int, int]], horch: Optional[Tuple[int, int]]) -> None: ...
def bkgd(self, ch: _chtype, attr: int = ...) -> None: ...
def bkgset(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): ...
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: Optional[int]) -> None: ...
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]: ...
def getch(self, y: Optional[int], x: Optional[int]) -> _chtype: ...
def get_wch(self, y: Optional[int], x: Optional[int]) -> _chtype: ...
def getkey(self, y: Optional[int], x: Optional[int]) -> str: ...
def getmaxyx(self) -> Tuple['_CursesWindow', int, int]: ...
@overload
def getch(self) -> _chtype: ...
@overload
def getch(self, y: int, x: int) -> _chtype: ...
@overload
def get_wch(self) -> _chtype: ...
@overload
def get_wch(self, y: int, x: int) -> _chtype: ...
@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]: ...
def getstr(self, y: Optional[int], x: Optional[int]) -> None: ...
def getyx(self) -> Tuple['_CursesWindow', 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: ...
def inch(self, y: Optional[int], x: Optional[int]) -> _chtype: ...
@overload
def insch(self, ch: _chtype, attr: Optional[int]) -> None: ...
def inch(self) -> _chtype: ...
@overload
def insch(self, y: int, x: int, ch: _chtype, attr: Optional[int]) -> None: ...
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: Optional[int]) -> None: ...
def insnstr(self, str: str, n: int, attr: int = ...) -> None: ...
@overload
def insnstr(self, y: int, x: int, str: str, n: int, attr: Optional[int]) -> None: ...
def insnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
@overload
def insstr(self, str: str, attr: Optional[int]) -> None: ...
def insstr(self, str: str, attr: int = ...) -> None: ...
@overload
def insstr(self, y: int, x: int, str: str, attr: Optional[int]) -> None: ...
def insstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
@overload
def instr(self, n: Optional[int]) -> str: ...
def instr(self, n: int = ...) -> _chtype: ...
@overload
def instr(self, y: int, x: int, n: Optional[int]) -> str: ...
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: ...
def overlay(self, destwin: '_CursesWindow',
sminrow: Optional[int], smincol: Optional[int],
dminrow: Optional[int], dmincol: Optional[int],
dmaxrow: Optional[int], dmaxcol: Optional[int]) -> None: ...
def overwrite(self, destwin: '_CursesWindow',
sminrow: Optional[int], smincol: Optional[int],
dminrow: Optional[int], dmincol: Optional[int],
dmaxrow: Optional[int], dmaxcol: Optional[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: ...
def refresh(self, pminrow: Optional[int], pmincol: Optional[int],
sminrow: Optional[int], smincol: Optional[int],
smaxrow: Optional[int], smaxcol: Optional[int]) -> 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 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: Optional[bool]) -> 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: ...

View File

@@ -1,9 +1,10 @@
import _curses
from _curses import * # noqa: F403
from typing import Callable, Any, Sequence, Mapping
LINES: int
COLS: int
def initscr() -> _curses._CursesWindow: ...
def start_color(): ...
def wrapper(func, *args, **kwds): ...
def start_color() -> None: ...
def wrapper(func: Callable[..., Any], *arg: Any, **kwds: Any) -> None: ...