From a07d9b991176ea8c77fa16d4abc0d195c6aff4c2 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Aug 2020 12:11:42 +0300 Subject: [PATCH 1/2] make tkinter.font.Font behave similarly to tkinter widgets --- stdlib/3/tkinter/font.pyi | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/stdlib/3/tkinter/font.pyi b/stdlib/3/tkinter/font.pyi index b884d9d51c33..fbfda09b1a04 100644 --- a/stdlib/3/tkinter/font.pyi +++ b/stdlib/3/tkinter/font.pyi @@ -48,6 +48,8 @@ class Font: underline: bool = ..., overstrike: bool = ..., ) -> None: ... + def __getitem__(self, key: str) -> Any: ... + def __setitem__(self, key: str, value: Any) -> None: ... @overload def cget(self, option: Literal["family"]) -> str: ... @overload @@ -58,7 +60,6 @@ class Font: def cget(self, option: Literal["slant"]) -> Literal["roman", "italic"]: ... @overload def cget(self, option: Literal["underline", "overstrike"]) -> Literal[0, 1]: ... - __getitem__ = cget @overload def actual(self, option: Literal["family"], displayof: Optional[tkinter.Misc] = ...) -> str: ... @overload @@ -73,18 +74,6 @@ class Font: def actual(self, option: None, displayof: Optional[tkinter.Misc] = ...) -> _FontDict: ... @overload def actual(self, *, displayof: Optional[tkinter.Misc] = ...) -> _FontDict: ... - @overload - def __setitem__(self, key: Literal["family"], value: str) -> None: ... - @overload - def __setitem__(self, key: Literal["size"], value: int) -> None: ... - @overload - def __setitem__(self, key: Literal["weight"], value: Literal["normal", "bold"]) -> None: ... - @overload - def __setitem__(self, key: Literal["slant"], value: Literal["roman", "italic"]) -> None: ... - @overload - def __setitem__(self, key: Literal["underline"], value: bool) -> None: ... - @overload - def __setitem__(self, key: Literal["overstrike"], value: bool) -> None: ... def config( self, *, From ec20aa48a2261c78549b75db63b22e1fa97f45dc Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Aug 2020 12:17:53 +0300 Subject: [PATCH 2/2] fix missing import --- stdlib/3/tkinter/font.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/tkinter/font.pyi b/stdlib/3/tkinter/font.pyi index fbfda09b1a04..9d4739508169 100644 --- a/stdlib/3/tkinter/font.pyi +++ b/stdlib/3/tkinter/font.pyi @@ -1,5 +1,5 @@ import tkinter -from typing import List, Optional, Tuple, TypeVar, Union, overload +from typing import Any, List, Optional, Tuple, TypeVar, Union, overload from typing_extensions import Literal, TypedDict NORMAL: Literal["normal"]