Skip to content

Commit 21428b3

Browse files
gh-152638: Import warnings locally and use semantic line breaks
Import warnings inside askopenfiles() rather than at module level, since it is only used by the deprecation there. Break the new documentation lines at sentence and clause boundaries. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e25abcd commit 21428b3

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

Doc/library/dialog.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,21 @@ string, an empty tuple, an empty list or ``None``.
164164

165165
.. function:: askopenfile(mode="r", **options)
166166

167-
Create an :class:`Open` dialog and return the opened file object, or
168-
``None`` if the dialog is cancelled.
167+
Create an :class:`Open` dialog and return the opened file object,
168+
or ``None`` if the dialog is cancelled.
169169
The file is opened in mode *mode* (read-only ``'r'`` by default).
170170

171171
.. function:: askopenfiles(mode="r", **options)
172172

173-
Create an :class:`Open` dialog and return a list of the opened file
174-
objects, or an empty list if cancelled.
173+
Create an :class:`Open` dialog and return a list of the opened file objects,
174+
or an empty list if cancelled.
175175
The files are opened in mode *mode* (read-only ``'r'`` by default).
176176

177177
.. deprecated-removed:: next 3.19
178-
Opening several files at once is error-prone, and the returned list
179-
cannot be used in a :keyword:`with` statement.
180-
Iterate over the names returned by :func:`askopenfilenames` and open
181-
them one by one instead.
178+
Opening several files at once is error-prone,
179+
and the returned list cannot be used in a :keyword:`with` statement.
180+
Iterate over the names returned by :func:`askopenfilenames`
181+
and open them one by one instead.
182182

183183
.. function:: asksaveasfile(mode="w", **options)
184184

Lib/tkinter/filedialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import fnmatch
2020
import os
2121
import tkinter
22-
import warnings
2322
from tkinter import (
2423
ACTIVE, CENTER, EW, NORMAL, NS, NSEW, RAISED, W, YES, BOTTOM, TOP, Tk, X,
2524
Toplevel, END, Listbox, BOTH,
@@ -576,6 +575,7 @@ def askopenfiles(mode = "r", **options):
576575
returns a list of open file objects or an empty list if
577576
cancel selected
578577
"""
578+
import warnings
579579
warnings._deprecated(
580580
"tkinter.filedialog.askopenfiles",
581581
message=f"{warnings._DEPRECATED_MSG}; iterate over the names returned "

0 commit comments

Comments
 (0)