From 02e19d6e2d7090ff4be3d63d2d13f9d5491bcfad Mon Sep 17 00:00:00 2001 From: Akuli Date: Sun, 21 Jan 2024 03:10:29 +0200 Subject: [PATCH] tkinter: font size must be integer (#11295) --- stdlib/tkinter/font.pyi | 7 +++++-- test_cases/stdlib/check_tkinter.py | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index ca65b8e2b..448e2b005 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -15,8 +15,11 @@ ITALIC: Literal["italic"] _FontDescription: TypeAlias = ( str # "Helvetica 12" | Font # A font object constructed in Python - | list[Any] # ("Helvetica", 12, BOLD) - | tuple[Any, ...] + | list[Any] # ["Helvetica", 12, BOLD] + | tuple[str] # ("Liberation Sans",) needs wrapping in tuple/list to handle spaces + | tuple[str, int] # ("Liberation Sans", 12) + | tuple[str, int, str] # ("Liberation Sans", 12, "bold") + | tuple[str, int, list[str] | tuple[str, ...]] # e.g. bold and italic | _tkinter.Tcl_Obj # A font object constructed in Tcl ) diff --git a/test_cases/stdlib/check_tkinter.py b/test_cases/stdlib/check_tkinter.py index 61da56ea6..befac6697 100644 --- a/test_cases/stdlib/check_tkinter.py +++ b/test_cases/stdlib/check_tkinter.py @@ -20,3 +20,11 @@ def foo(x: int, y: str) -> None: root.after(1000, foo, 10, "lol") root.after(1000, foo, 10, 10) # type: ignore + + +# Font size must be integer +label = tkinter.Label() +label.config(font=("", 12)) +label.config(font=("", 12.34)) # type: ignore +label.config(font=("", 12, "bold")) +label.config(font=("", 12.34, "bold")) # type: ignore