From 060146f9027434abfe252c0daebf6917ecef8600 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sun, 6 Jun 2021 23:59:15 +0300 Subject: [PATCH 1/3] most common tkinter.Entry methods --- stdlib/tkinter/__init__.pyi | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index cb362924b199..00602d7c2942 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1421,6 +1421,8 @@ class Checkbutton(Widget): def select(self): ... def toggle(self): ... +_EntryIndex = Union[str, int] # "INDICES" in manual page + class Entry(Widget, XView): def __init__( self, @@ -1512,25 +1514,25 @@ class Entry(Widget, XView): @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def delete(self, first, last: Optional[Any] = ...): ... - def get(self): ... - def icursor(self, index): ... - def index(self, index): ... - def insert(self, index, string): ... + def delete(self, first: _EntryIndex, last: _EntryIndex | None = ...) -> None: ... + def get(self) -> str: ... + def icursor(self, index: _EntryIndex) -> None: ... + def index(self, index: _EntryIndex) -> int: ... + def insert(self, index: _EntryIndex, string: str) -> None: ... def scan_mark(self, x): ... def scan_dragto(self, x): ... - def selection_adjust(self, index): ... - select_adjust: Any - def selection_clear(self): ... - select_clear: Any - def selection_from(self, index): ... - select_from: Any - def selection_present(self): ... - select_present: Any - def selection_range(self, start, end): ... - select_range: Any - def selection_to(self, index): ... - select_to: Any + def selection_adjust(self, index: _EntryIndex) -> None: ... + def selection_clear(self) -> None: ... + def selection_from(self, index: _EntryIndex) -> None: ... + def selection_present(self) -> bool: ... + def selection_range(self, start: _EntryIndex, end: _EntryIndex) -> None: ... + def selection_to(self, index: _EntryIndex): ... + select_adjust = selection_adjust + select_clear = selection_clear + select_from = selection_from + select_present = selection_present + select_range = selection_range + select_to = selection_to class Frame(Widget): def __init__( From b0977df8cdfbd203bc628fbb9241bb43963de0d5 Mon Sep 17 00:00:00 2001 From: Akuli Date: Mon, 7 Jun 2021 00:01:53 +0300 Subject: [PATCH 2/3] fix missing return type --- stdlib/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 00602d7c2942..6fc1b1378e99 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1526,7 +1526,7 @@ class Entry(Widget, XView): def selection_from(self, index: _EntryIndex) -> None: ... def selection_present(self) -> bool: ... def selection_range(self, start: _EntryIndex, end: _EntryIndex) -> None: ... - def selection_to(self, index: _EntryIndex): ... + def selection_to(self, index: _EntryIndex) -> None: ... select_adjust = selection_adjust select_clear = selection_clear select_from = selection_from From dcc3349404b30bc40dcb0ccbf0e1dc381ba6bd71 Mon Sep 17 00:00:00 2001 From: Akuli Date: Mon, 7 Jun 2021 00:04:07 +0300 Subject: [PATCH 3/3] type-ignore tkinter's lsp violation --- stdlib/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 6fc1b1378e99..e97b65342e9a 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1522,7 +1522,7 @@ class Entry(Widget, XView): def scan_mark(self, x): ... def scan_dragto(self, x): ... def selection_adjust(self, index: _EntryIndex) -> None: ... - def selection_clear(self) -> None: ... + def selection_clear(self) -> None: ... # type: ignore def selection_from(self, index: _EntryIndex) -> None: ... def selection_present(self) -> bool: ... def selection_range(self, start: _EntryIndex, end: _EntryIndex) -> None: ...