From e0967441e2aa687fcf6cc4ab8aded09ce14dde48 Mon Sep 17 00:00:00 2001 From: Konstantin Baikov Date: Wed, 1 Jan 2025 21:00:22 +0100 Subject: [PATCH] Add some defaults to tkinter.filedialog (#13345) Partially fixes: https://github.com/python/typeshed/issues/11482 Source of fixes based on the @akuli comment: https://github.com/python/typeshed/issues/11482#issuecomment-1981710718 --- stdlib/tkinter/filedialog.pyi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index 3d62f079178e..03f89cfbe3e6 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -80,8 +80,8 @@ class Directory(commondialog.Dialog): # TODO: command kwarg available on macos def asksaveasfilename( *, - confirmoverwrite: bool | None = ..., - defaultextension: str | None = ..., + confirmoverwrite: bool | None = True, + defaultextension: str | None = "", filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., @@ -91,7 +91,7 @@ def asksaveasfilename( ) -> str: ... # can be empty string def askopenfilename( *, - defaultextension: str | None = ..., + defaultextension: str | None = "", filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., @@ -101,7 +101,7 @@ def askopenfilename( ) -> str: ... # can be empty string def askopenfilenames( *, - defaultextension: str | None = ..., + defaultextension: str | None = "", filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., @@ -110,15 +110,15 @@ def askopenfilenames( typevariable: StringVar | str | None = ..., ) -> Literal[""] | tuple[str, ...]: ... def askdirectory( - *, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ... + *, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = False, parent: Misc | None = ..., title: str | None = ... ) -> str: ... # can be empty string # TODO: If someone actually uses these, overload to have the actual return type of open(..., mode) def asksaveasfile( mode: str = "w", *, - confirmoverwrite: bool | None = ..., - defaultextension: str | None = ..., + confirmoverwrite: bool | None = True, + defaultextension: str | None = "", filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., @@ -129,7 +129,7 @@ def asksaveasfile( def askopenfile( mode: str = "r", *, - defaultextension: str | None = ..., + defaultextension: str | None = "", filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ..., @@ -140,7 +140,7 @@ def askopenfile( def askopenfiles( mode: str = "r", *, - defaultextension: str | None = ..., + defaultextension: str | None = "", filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ..., initialdir: StrOrBytesPath | None = ..., initialfile: StrOrBytesPath | None = ...,