Skip to content

Commit 4ce9f24

Browse files
authored
Add some defaults to tkinter.filedialog (#13345)
Partially fixes: #11482 Source of fixes based on the @Akuli comment: #11482 (comment)
1 parent b66d6cf commit 4ce9f24

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

stdlib/tkinter/filedialog.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class Directory(commondialog.Dialog):
8080
# TODO: command kwarg available on macos
8181
def asksaveasfilename(
8282
*,
83-
confirmoverwrite: bool | None = ...,
84-
defaultextension: str | None = ...,
83+
confirmoverwrite: bool | None = True,
84+
defaultextension: str | None = "",
8585
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
8686
initialdir: StrOrBytesPath | None = ...,
8787
initialfile: StrOrBytesPath | None = ...,
@@ -91,7 +91,7 @@ def asksaveasfilename(
9191
) -> str: ... # can be empty string
9292
def askopenfilename(
9393
*,
94-
defaultextension: str | None = ...,
94+
defaultextension: str | None = "",
9595
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
9696
initialdir: StrOrBytesPath | None = ...,
9797
initialfile: StrOrBytesPath | None = ...,
@@ -101,7 +101,7 @@ def askopenfilename(
101101
) -> str: ... # can be empty string
102102
def askopenfilenames(
103103
*,
104-
defaultextension: str | None = ...,
104+
defaultextension: str | None = "",
105105
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
106106
initialdir: StrOrBytesPath | None = ...,
107107
initialfile: StrOrBytesPath | None = ...,
@@ -110,15 +110,15 @@ def askopenfilenames(
110110
typevariable: StringVar | str | None = ...,
111111
) -> Literal[""] | tuple[str, ...]: ...
112112
def askdirectory(
113-
*, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = ..., parent: Misc | None = ..., title: str | None = ...
113+
*, initialdir: StrOrBytesPath | None = ..., mustexist: bool | None = False, parent: Misc | None = ..., title: str | None = ...
114114
) -> str: ... # can be empty string
115115

116116
# TODO: If someone actually uses these, overload to have the actual return type of open(..., mode)
117117
def asksaveasfile(
118118
mode: str = "w",
119119
*,
120-
confirmoverwrite: bool | None = ...,
121-
defaultextension: str | None = ...,
120+
confirmoverwrite: bool | None = True,
121+
defaultextension: str | None = "",
122122
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
123123
initialdir: StrOrBytesPath | None = ...,
124124
initialfile: StrOrBytesPath | None = ...,
@@ -129,7 +129,7 @@ def asksaveasfile(
129129
def askopenfile(
130130
mode: str = "r",
131131
*,
132-
defaultextension: str | None = ...,
132+
defaultextension: str | None = "",
133133
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
134134
initialdir: StrOrBytesPath | None = ...,
135135
initialfile: StrOrBytesPath | None = ...,
@@ -140,7 +140,7 @@ def askopenfile(
140140
def askopenfiles(
141141
mode: str = "r",
142142
*,
143-
defaultextension: str | None = ...,
143+
defaultextension: str | None = "",
144144
filetypes: Iterable[tuple[str, str | list[str] | tuple[str, ...]]] | None = ...,
145145
initialdir: StrOrBytesPath | None = ...,
146146
initialfile: StrOrBytesPath | None = ...,

0 commit comments

Comments
 (0)