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
This commit is contained in:
Konstantin Baikov
2025-01-01 21:00:22 +01:00
committed by GitHub
parent b66d6cfa99
commit 4ce9f24f39

View File

@@ -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 = ...,