Skip to content

Use typeshed.Incomplete and object instead of Any in tkinter stubs #8458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
"stdlib/sqlite3/dbapi2.pyi",
"stdlib/_tkinter.pyi",
"stdlib/tkinter/__init__.pyi",
"stdlib/tkinter/colorchooser.pyi",
"stdlib/tkinter/commondialog.pyi",
"stdlib/tkinter/dialog.pyi",
"stdlib/tkinter/dnd.pyi",
"stdlib/tkinter/filedialog.pyi",
"stdlib/tkinter/messagebox.pyi",
"stdlib/tkinter/scrolledtext.pyi",
"stdlib/tkinter/tix.pyi",
"stdlib/tkinter/ttk.pyi",
"stdlib/xml/dom/NodeFilter.pyi",
"stdlib/xml/dom/expatbuilder.pyi",
Expand Down
165 changes: 85 additions & 80 deletions stdlib/tkinter/__init__.pyi

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions stdlib/tkinter/colorchooser.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sys
from tkinter.commondialog import Dialog
from typing import Any, ClassVar
from typing import ClassVar

if sys.version_info >= (3, 9):
__all__ = ["Chooser", "askcolor"]

class Chooser(Dialog):
command: ClassVar[str]

def askcolor(color: str | bytes | None = ..., **options: Any) -> tuple[None, None] | tuple[tuple[float, float, float], str]: ...
def askcolor(color: str | bytes | None = ..., **options) -> tuple[None, None] | tuple[tuple[float, float, float], str]: ...
11 changes: 6 additions & 5 deletions stdlib/tkinter/commondialog.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import sys
from _typeshed import Incomplete
from collections.abc import Mapping
from typing import Any, ClassVar
from typing import ClassVar

if sys.version_info >= (3, 9):
__all__ = ["Dialog"]

class Dialog:
command: ClassVar[str | None]
master: Any | None
options: Mapping[str, Any]
def __init__(self, master: Any | None = ..., **options) -> None: ...
def show(self, **options) -> Any: ...
master: Incomplete | None
options: Mapping[str, Incomplete]
def __init__(self, master: Incomplete | None = ..., **options) -> None: ...
def show(self, **options): ...
3 changes: 2 additions & 1 deletion stdlib/tkinter/dialog.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from _typeshed import Incomplete
from collections.abc import Mapping
from tkinter import Widget
from typing import Any
Expand All @@ -11,5 +12,5 @@ DIALOG_ICON: str
class Dialog(Widget):
widgetName: str
num: int
def __init__(self, master: Any | None = ..., cnf: Mapping[str, Any] = ..., **kw) -> None: ...
def __init__(self, master: Incomplete | None = ..., cnf: Mapping[str, Any] = ..., **kw) -> None: ...
def destroy(self) -> None: ...
28 changes: 14 additions & 14 deletions stdlib/tkinter/filedialog.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from _typeshed import StrOrBytesPath
from _typeshed import Incomplete, StrOrBytesPath
from collections.abc import Iterable
from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog
from typing import IO, Any, ClassVar
from typing import IO, ClassVar
from typing_extensions import Literal

if sys.version_info >= (3, 9):
Expand All @@ -22,12 +22,12 @@ if sys.version_info >= (3, 9):
"askdirectory",
]

dialogstates: dict[Any, tuple[Any, Any]]
dialogstates: dict[Incomplete, tuple[Incomplete, Incomplete]]

class FileDialog:
title: str
master: Any
directory: Any | None
master: Incomplete
directory: Incomplete | None
top: Toplevel
botframe: Frame
selection: Entry
Expand All @@ -41,21 +41,21 @@ class FileDialog:
filter_button: Button
cancel_button: Button
def __init__(
self, master, title: Any | None = ...
self, master, title: Incomplete | None = ...
) -> None: ... # title is usually a str or None, but e.g. int doesn't raise en exception either
how: Any | None
def go(self, dir_or_file: Any = ..., pattern: str = ..., default: str = ..., key: Any | None = ...): ...
def quit(self, how: Any | None = ...) -> None: ...
how: Incomplete | None
def go(self, dir_or_file: Incomplete = ..., pattern: str = ..., default: str = ..., key: Incomplete | None = ...): ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def go(self, dir_or_file: Incomplete = ..., pattern: str = ..., default: str = ..., key: Incomplete | None = ...): ...
def go(self, dir_or_file=..., pattern: str = ..., default: str = ..., key: Incomplete | None = ...): ...

def quit(self, how: Incomplete | None = ...) -> None: ...
def dirs_double_event(self, event) -> None: ...
def dirs_select_event(self, event) -> None: ...
def files_double_event(self, event) -> None: ...
def files_select_event(self, event) -> None: ...
def ok_event(self, event) -> None: ...
def ok_command(self) -> None: ...
def filter_command(self, event: Any | None = ...) -> None: ...
def filter_command(self, event: Incomplete | None = ...) -> None: ...
def get_filter(self): ...
def get_selection(self): ...
def cancel_command(self, event: Any | None = ...) -> None: ...
def cancel_command(self, event: Incomplete | None = ...) -> None: ...
def set_filter(self, dir, pat) -> None: ...
def set_selection(self, file) -> None: ...

Expand Down Expand Up @@ -126,7 +126,7 @@ def asksaveasfile(
parent: Misc | None = ...,
title: str | None = ...,
typevariable: StringVar | str | None = ...,
) -> IO[Any] | None: ...
) -> IO[Incomplete] | None: ...
def askopenfile(
mode: str = ...,
*,
Expand All @@ -137,7 +137,7 @@ def askopenfile(
parent: Misc | None = ...,
title: str | None = ...,
typevariable: StringVar | str | None = ...,
) -> IO[Any] | None: ...
) -> IO[Incomplete] | None: ...
def askopenfiles(
mode: str = ...,
*,
Expand All @@ -148,5 +148,5 @@ def askopenfiles(
parent: Misc | None = ...,
title: str | None = ...,
typevariable: StringVar | str | None = ...,
) -> tuple[IO[Any], ...]: ... # can be empty tuple
) -> tuple[IO[Incomplete], ...]: ... # can be empty tuple
def test() -> None: ...
18 changes: 9 additions & 9 deletions stdlib/tkinter/messagebox.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from tkinter.commondialog import Dialog
from typing import Any, ClassVar
from typing import ClassVar

if sys.version_info >= (3, 9):
__all__ = [
Expand Down Expand Up @@ -34,11 +34,11 @@ NO: str
class Message(Dialog):
command: ClassVar[str]

def showinfo(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ...
def showwarning(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ...
def showerror(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ...
def askquestion(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ...
def askokcancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ...
def askyesno(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ...
def askyesnocancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool | None: ...
def askretrycancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ...
def showinfo(title: str | None = ..., message: str | None = ..., **options) -> str: ...
def showwarning(title: str | None = ..., message: str | None = ..., **options) -> str: ...
def showerror(title: str | None = ..., message: str | None = ..., **options) -> str: ...
def askquestion(title: str | None = ..., message: str | None = ..., **options) -> str: ...
def askokcancel(title: str | None = ..., message: str | None = ..., **options) -> bool: ...
def askyesno(title: str | None = ..., message: str | None = ..., **options) -> bool: ...
def askyesnocancel(title: str | None = ..., message: str | None = ..., **options) -> bool | None: ...
def askretrycancel(title: str | None = ..., message: str | None = ..., **options) -> bool: ...
3 changes: 1 addition & 2 deletions stdlib/tkinter/scrolledtext.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from tkinter import Frame, Misc, Scrollbar, Text
from typing import Any

__all__ = ["ScrolledText"]

# The methods from Pack, Place, and Grid are dynamically added over the parent's impls
class ScrolledText(Text):
frame: Frame
vbar: Scrollbar
def __init__(self, master: Misc | None = ..., **kwargs: Any) -> None: ...
def __init__(self, master: Misc | None = ..., **kwargs) -> None: ...
Loading