Use bool | Literal[0, 1] instead of int in some tkinter bool parameters (#11412)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Akuli
2024-02-13 02:06:00 +02:00
committed by GitHub
parent 5382d24d1d
commit b44d22e81d

View File

@@ -184,7 +184,7 @@ _Relief: TypeAlias = Literal["raised", "sunken", "flat", "ridge", "solid", "groo
_ScreenUnits: TypeAlias = str | float # Often the right type instead of int. Manual page: Tk_GetPixels
# -xscrollcommand and -yscrollcommand in 'options' manual page
_XYScrollCommand: TypeAlias = str | Callable[[float, float], object]
_TakeFocusValue: TypeAlias = int | Literal[""] | Callable[[str], bool | None] # -takefocus in manual page named 'options'
_TakeFocusValue: TypeAlias = bool | Literal[0, 1, ""] | Callable[[str], bool | None] # -takefocus in manual page named 'options'
if sys.version_info >= (3, 11):
class _VersionInfoType(NamedTuple):
@@ -829,7 +829,7 @@ class Pack:
after: Misc = ...,
anchor: _Anchor = ...,
before: Misc = ...,
expand: int = ...,
expand: bool | Literal[0, 1] = 0,
fill: Literal["none", "x", "y", "both"] = ...,
side: Literal["left", "right", "top", "bottom"] = ...,
ipadx: _ScreenUnits = ...,
@@ -2110,7 +2110,7 @@ class Listbox(Widget, XView, YView):
borderwidth: _ScreenUnits = 1,
cursor: _Cursor = "",
disabledforeground: str = ...,
exportselection: int = 1,
exportselection: bool | Literal[0, 1] = 1,
fg: str = ...,
font: _FontDescription = ...,
foreground: str = ...,
@@ -2233,7 +2233,7 @@ class Menu(Widget):
relief: _Relief = ...,
selectcolor: str = ...,
takefocus: _TakeFocusValue = 0,
tearoff: int = ...,
tearoff: bool | Literal[0, 1] = 1,
# I guess tearoffcommand arguments are supposed to be widget objects,
# but they are widget name strings. Use nametowidget() to handle the
# arguments of tearoffcommand.