From aa861221cf046fc2aa514ccab142aeb690bde601 Mon Sep 17 00:00:00 2001 From: gossrock Date: Sun, 17 Dec 2017 20:26:09 +0000 Subject: [PATCH 01/10] adding ascii, panal and textpad modules to the curses module. --- stdlib/3/curses/ascii.pyi | 69 +++++++++++++++++++++++++++++++++++++ stdlib/3/curses/panel.pyi | 20 +++++++++++ stdlib/3/curses/textpad.pyi | 11 ++++++ 3 files changed, 100 insertions(+) create mode 100644 stdlib/3/curses/ascii.pyi create mode 100644 stdlib/3/curses/panel.pyi create mode 100644 stdlib/3/curses/textpad.pyi diff --git a/stdlib/3/curses/ascii.pyi b/stdlib/3/curses/ascii.pyi new file mode 100644 index 000000000000..15c42f2d3e8c --- /dev/null +++ b/stdlib/3/curses/ascii.pyi @@ -0,0 +1,69 @@ +from typing import Sequence, Union, overload + +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: Sequence[int] = ... + +def isalnum(c: str) -> bool: ... +def isalpha(c: str) -> bool: ... +def isascii(c: str) -> bool: ... +def isblank(c: str) -> bool: ... +def iscntrl(c: str) -> bool: ... +def isdigit(c: str) -> bool: ... +def isgraph(c: str) -> bool: ... +def islower(c: str) -> bool: ... +def isprint(c: str) -> bool: ... +def ispunct(c: str) -> bool: ... +def isspace(c: str) -> bool: ... +def isupper(c: str) -> bool: ... +def isxdigit(c: str) -> bool: ... +def isctrl(c: str) -> bool: ... +def ismeta(c: str) -> bool: ... +@overload +def ascii(c: str) -> str: ... +@overload +def ascii(c: int) -> int: ... +@overload +def ctrl(c: str) -> str: ... +@overload +def ctrl(c: int) -> str: ... +@overload +def alt(c: str) -> str: ... +@overload +def alt(c: int) -> int: ... +def unctrl(c: Union[str, int]) -> str: ... diff --git a/stdlib/3/curses/panel.pyi b/stdlib/3/curses/panel.pyi new file mode 100644 index 000000000000..56a2a92a12eb --- /dev/null +++ b/stdlib/3/curses/panel.pyi @@ -0,0 +1,20 @@ +from _curses import _CursesWindow + +class _Curses_Panel: # type is (note the space in the class name) + def above(self) -> '_Curses_Panel': ... + def below(self) -> '_Curses_Panel': ... + def bottom(self) -> None: ... + def hidden(self) -> bool: ... + def hide(self) -> None: ... + def move(self, y: int, x: int) -> None: ... + def replace(self, win: _CursesWindow) -> None: ... + def set_userptr(self, obj: object) -> None: ... + def show(self) -> None: ... + def top(self) -> None: ... + def userptr(self) -> object: ... + def window(self) -> _CursesWindow: ... + +def bottom_panel() -> _Curses_Panel: ... +def new_panel(win: _CursesWindow) -> _Curses_Panel: ... +def top_panel() -> _Curses_Panel: ... +def update_panels() -> _Curses_Panel: ... diff --git a/stdlib/3/curses/textpad.pyi b/stdlib/3/curses/textpad.pyi new file mode 100644 index 000000000000..4bed2e3d644f --- /dev/null +++ b/stdlib/3/curses/textpad.pyi @@ -0,0 +1,11 @@ +from _curses import _CursesWindow +from typing import Callable, Union + +def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... + +class Textbox: + stripspaces: bool + def __init__(self, w: _CursesWindow) -> None: ... + def edit(self, validator: Callable[[int], int]) -> str: ... + def do_command(self, ch: Union[str,int]) -> None: ... + def gather(self) -> str: ... From ea5870ec2df5b17a7b4cf7b11848771d25b9a0ba Mon Sep 17 00:00:00 2001 From: gossrock Date: Sun, 17 Dec 2017 20:48:30 +0000 Subject: [PATCH 02/10] made a few flake8 changes --- stdlib/3/curses/ascii.pyi | 2 +- stdlib/3/curses/panel.pyi | 3 ++- stdlib/3/curses/textpad.pyi | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/3/curses/ascii.pyi b/stdlib/3/curses/ascii.pyi index 15c42f2d3e8c..576c03032ffe 100644 --- a/stdlib/3/curses/ascii.pyi +++ b/stdlib/3/curses/ascii.pyi @@ -35,7 +35,7 @@ GS: int = ... RS: int = ... US: int = ... SP: int = ... -DEL: int =... +DEL: int = ... controlnames: Sequence[int] = ... diff --git a/stdlib/3/curses/panel.pyi b/stdlib/3/curses/panel.pyi index 56a2a92a12eb..71733483eaac 100644 --- a/stdlib/3/curses/panel.pyi +++ b/stdlib/3/curses/panel.pyi @@ -1,6 +1,7 @@ +import _curses from _curses import _CursesWindow -class _Curses_Panel: # type is (note the space in the class name) +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: ... diff --git a/stdlib/3/curses/textpad.pyi b/stdlib/3/curses/textpad.pyi index 4bed2e3d644f..95faac6ff312 100644 --- a/stdlib/3/curses/textpad.pyi +++ b/stdlib/3/curses/textpad.pyi @@ -1,3 +1,4 @@ +import _curses from _curses import _CursesWindow from typing import Callable, Union @@ -7,5 +8,5 @@ class Textbox: stripspaces: bool def __init__(self, w: _CursesWindow) -> None: ... def edit(self, validator: Callable[[int], int]) -> str: ... - def do_command(self, ch: Union[str,int]) -> None: ... + def do_command(self, ch: Union[str, int]) -> None: ... def gather(self) -> str: ... From bfc0865a0a6d86591e399aa8bba88e4fb64663af Mon Sep 17 00:00:00 2001 From: gossrock Date: Sun, 17 Dec 2017 20:49:47 +0000 Subject: [PATCH 03/10] remove a couple of unnessisary imports --- stdlib/3/curses/panel.pyi | 1 - stdlib/3/curses/textpad.pyi | 1 - 2 files changed, 2 deletions(-) diff --git a/stdlib/3/curses/panel.pyi b/stdlib/3/curses/panel.pyi index 71733483eaac..4b95fb079235 100644 --- a/stdlib/3/curses/panel.pyi +++ b/stdlib/3/curses/panel.pyi @@ -1,4 +1,3 @@ -import _curses from _curses import _CursesWindow class _Curses_Panel: # type is (note the space in the class name) diff --git a/stdlib/3/curses/textpad.pyi b/stdlib/3/curses/textpad.pyi index 95faac6ff312..99b62baeb12a 100644 --- a/stdlib/3/curses/textpad.pyi +++ b/stdlib/3/curses/textpad.pyi @@ -1,4 +1,3 @@ -import _curses from _curses import _CursesWindow from typing import Callable, Union From f5f8b4df0f18ea1b3914a7d290410e19edb5906f Mon Sep 17 00:00:00 2001 From: gossrock Date: Mon, 18 Dec 2017 10:47:31 +0000 Subject: [PATCH 04/10] Update ascii.pyi removed '= ...' from variable definitions --- stdlib/3/curses/ascii.pyi | 74 +++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/stdlib/3/curses/ascii.pyi b/stdlib/3/curses/ascii.pyi index 576c03032ffe..be7209513d45 100644 --- a/stdlib/3/curses/ascii.pyi +++ b/stdlib/3/curses/ascii.pyi @@ -1,43 +1,43 @@ from typing import Sequence, Union, overload -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: Sequence[int] = ... +controlnames: Sequence[int] def isalnum(c: str) -> bool: ... def isalpha(c: str) -> bool: ... From 76b3276ce2cb0aa9234a136204729912d999748e Mon Sep 17 00:00:00 2001 From: gossrock Date: Mon, 18 Dec 2017 14:36:43 +0000 Subject: [PATCH 05/10] added curses/panel.pyi and curses/textpad.pyi to test/pytype_blacklist.txt just like curses/__init__.pyi because they all import _curses. (This may not be the right thing to do) --- tests/pytype_blacklist.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/pytype_blacklist.txt b/tests/pytype_blacklist.txt index 19ec1d1ea07a..7d5b30b6afd9 100644 --- a/tests/pytype_blacklist.txt +++ b/tests/pytype_blacklist.txt @@ -34,6 +34,8 @@ stdlib/3/concurrent/futures/__init__.pyi # parse only stdlib/3/concurrent/futures/process.pyi # parse only stdlib/3/concurrent/futures/thread.pyi # parse only stdlib/3/curses/__init__.pyi # parse only +stdlib/3/curses/panel.pyi # parse only +stdlib/3/curses/textpad.pyi # parse only stdlib/3/email/__init__.pyi # parse only stdlib/3/email/contentmanager.pyi # parse only stdlib/3/email/encoders.pyi # parse only From 4b7fec6d9af35519043ee77ee86f11e2e76ce207 Mon Sep 17 00:00:00 2001 From: gossrock Date: Thu, 21 Dec 2017 10:43:45 +0000 Subject: [PATCH 06/10] Update ascii.pyi changed controlnames variable to be declared as List[str] instead of Sequence[str] --- stdlib/3/curses/ascii.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/curses/ascii.pyi b/stdlib/3/curses/ascii.pyi index be7209513d45..5ae730ce0ea0 100644 --- a/stdlib/3/curses/ascii.pyi +++ b/stdlib/3/curses/ascii.pyi @@ -1,4 +1,4 @@ -from typing import Sequence, Union, overload +from typing import List, Union, overload NUL: int SOH: int @@ -37,7 +37,7 @@ US: int SP: int DEL: int -controlnames: Sequence[int] +controlnames: List[int] def isalnum(c: str) -> bool: ... def isalpha(c: str) -> bool: ... From 67f3b3c0cfd09290f7674e86a8055a3c3abfd8d4 Mon Sep 17 00:00:00 2001 From: gossrock Date: Thu, 21 Dec 2017 11:35:27 +0000 Subject: [PATCH 07/10] changed from using @overload to TypeVar --- stdlib/3/curses/ascii.pyi | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/stdlib/3/curses/ascii.pyi b/stdlib/3/curses/ascii.pyi index 5ae730ce0ea0..ff2e0a7fbe19 100644 --- a/stdlib/3/curses/ascii.pyi +++ b/stdlib/3/curses/ascii.pyi @@ -1,4 +1,6 @@ -from typing import List, Union, overload +from typing import List, Union, overload, TypeVar + +Ch = TypeVar('Ch', str, int) NUL: int SOH: int @@ -54,16 +56,7 @@ def isupper(c: str) -> bool: ... def isxdigit(c: str) -> bool: ... def isctrl(c: str) -> bool: ... def ismeta(c: str) -> bool: ... -@overload -def ascii(c: str) -> str: ... -@overload -def ascii(c: int) -> int: ... -@overload -def ctrl(c: str) -> str: ... -@overload -def ctrl(c: int) -> str: ... -@overload -def alt(c: str) -> str: ... -@overload -def alt(c: int) -> int: ... -def unctrl(c: Union[str, int]) -> str: ... +def ascii(c: Ch) -> Ch: ... +def ctrl(c: Ch) -> Ch: ... +def alt(c: Ch) -> Ch: ... +def unctrl(c: Ch) -> str: ... From e3a8f65892378e6e5dfe9bd6a3b3a5577e04a6b4 Mon Sep 17 00:00:00 2001 From: gossrock Date: Thu, 21 Dec 2017 11:45:43 +0000 Subject: [PATCH 08/10] in 'edit' method stub changed 'validator' to 'validate' to match source code. --- stdlib/3/curses/textpad.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/curses/textpad.pyi b/stdlib/3/curses/textpad.pyi index 99b62baeb12a..87103aed2435 100644 --- a/stdlib/3/curses/textpad.pyi +++ b/stdlib/3/curses/textpad.pyi @@ -5,7 +5,7 @@ def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> Non class Textbox: stripspaces: bool - def __init__(self, w: _CursesWindow) -> None: ... - def edit(self, validator: Callable[[int], int]) -> str: ... + def __init__(self, w: _CursesWindow, insert_mode: bool= ...) -> None: ... + def edit(self, validate: Callable[[int], int]) -> str: ... def do_command(self, ch: Union[str, int]) -> None: ... def gather(self) -> str: ... From 6dd2efc218606feafdde3ea43436551178da225a Mon Sep 17 00:00:00 2001 From: gossrock Date: Thu, 21 Dec 2017 13:30:03 +0000 Subject: [PATCH 09/10] Update ascii.pyi fixed flake8 issue related to needing and underscore before a private TypeVar --- stdlib/3/curses/ascii.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/3/curses/ascii.pyi b/stdlib/3/curses/ascii.pyi index ff2e0a7fbe19..6caf90d457f4 100644 --- a/stdlib/3/curses/ascii.pyi +++ b/stdlib/3/curses/ascii.pyi @@ -1,6 +1,6 @@ from typing import List, Union, overload, TypeVar -Ch = TypeVar('Ch', str, int) +_Ch = TypeVar('_Ch', str, int) NUL: int SOH: int @@ -56,7 +56,7 @@ def isupper(c: str) -> bool: ... def isxdigit(c: str) -> bool: ... def isctrl(c: str) -> bool: ... def ismeta(c: str) -> bool: ... -def ascii(c: Ch) -> Ch: ... -def ctrl(c: Ch) -> Ch: ... -def alt(c: Ch) -> Ch: ... -def unctrl(c: Ch) -> str: ... +def ascii(c: _Ch) -> _Ch: ... +def ctrl(c: _Ch) -> _Ch: ... +def alt(c: _Ch) -> _Ch: ... +def unctrl(c: _Ch) -> str: ... From f5f480d7d0081b185285eddefc9e22a7726f300b Mon Sep 17 00:00:00 2001 From: gossrock Date: Thu, 21 Dec 2017 19:45:58 +0000 Subject: [PATCH 10/10] changed 'is' functions to take Union[str, int] instead of only str. also change unctrl to also take the same. (instead of the inapropriate TypeVar) --- stdlib/3/curses/ascii.pyi | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/stdlib/3/curses/ascii.pyi b/stdlib/3/curses/ascii.pyi index 6caf90d457f4..4033769252c8 100644 --- a/stdlib/3/curses/ascii.pyi +++ b/stdlib/3/curses/ascii.pyi @@ -41,22 +41,22 @@ DEL: int controlnames: List[int] -def isalnum(c: str) -> bool: ... -def isalpha(c: str) -> bool: ... -def isascii(c: str) -> bool: ... -def isblank(c: str) -> bool: ... -def iscntrl(c: str) -> bool: ... -def isdigit(c: str) -> bool: ... -def isgraph(c: str) -> bool: ... -def islower(c: str) -> bool: ... -def isprint(c: str) -> bool: ... -def ispunct(c: str) -> bool: ... -def isspace(c: str) -> bool: ... -def isupper(c: str) -> bool: ... -def isxdigit(c: str) -> bool: ... -def isctrl(c: str) -> bool: ... -def ismeta(c: str) -> bool: ... +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: _Ch) -> _Ch: ... def ctrl(c: _Ch) -> _Ch: ... def alt(c: _Ch) -> _Ch: ... -def unctrl(c: _Ch) -> str: ... +def unctrl(c: Union[str, int]) -> str: ...