Skip to content

Commit 9652321

Browse files
sirosenhugovkStanFromIreland
committed
Apply review suggestions
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent 354cdfa commit 9652321

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎Doc/deprecations/pending-removal-in-3.21.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Pending removal in Python 3.21
2727
parameter or pass the dispatch type explicitly instead.
2828
(Contributed by Bartosz Sławecki in :gh:`143465`.)
2929

30+
* :mod:`mimetypes`:
31+
32+
* Passing a file path (including path-like objects and bytes paths) to
33+
:func:`~mimetypes.guess_type`. Use :func:`~mimetypes.guess_file_type`
34+
instead.
35+
3036
* :mod:`struct`:
3137

3238
* Soft-deprecated since Python 3.15, using ``'F'`` and ``'D'`` type codes are now

‎Doc/deprecations/pending-removal-in-future.rst‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ although there is currently no date scheduled for their removal.
7171
* :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
7272
BytesIO and binary mode instead.
7373

74-
* :mod:`mimetypes`: Passing a file path (including path-like objects and bytes
75-
paths) to :func:`~mimetypes.guess_type`. Use
76-
:func:`~mimetypes.guess_file_type` instead. (:gh:`151575`)
77-
7874
* :mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process.
7975

8076
* :mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use

‎Doc/library/mimetypes.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ the information :func:`init` sets up.
5656
.. deprecated-removed:: 3.16 3.21
5757
Passing a file path (or path-like object) instead of a URL.
5858
Use :func:`guess_file_type` instead.
59-
Soft deprecated since version 3.13.
59+
This has been soft deprecated since version 3.13.
6060

6161

6262
.. function:: guess_file_type(path, *, strict=True)
@@ -268,7 +268,7 @@ than one MIME-type database; it provides an interface similar to the one of the
268268
.. deprecated-removed:: 3.16 3.21
269269
Passing a file path (or path-like object) instead of a URL.
270270
Use :func:`guess_file_type` instead.
271-
Soft deprecated since version 3.13.
271+
This has been soft deprecated since version 3.13.
272272

273273
.. method:: MimeTypes.guess_file_type(path, *, strict=True)
274274

‎Lib/mimetypes.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"""
2525

2626
import sys
27-
import os
28-
import posixpath
27+
lazy import os
28+
lazy import posixpath
2929
lazy import urllib.parse
3030
lazy import warnings
3131
lazy from argparse import ArgumentParser
@@ -145,11 +145,11 @@ def guess_type(self, url, strict=True):
145145
scheme = p.scheme
146146
url = p.path
147147
else:
148-
warnings.warn(
148+
warnings._deprecated(
149149
"Passing a file path to guess_type() is deprecated and will be "
150150
"removed in a future version. Use guess_file_type() instead.",
151-
DeprecationWarning,
152-
stacklevel=2,
151+
remove=(3, 21),
152+
stacklevel=4,
153153
)
154154
return self.guess_file_type(url, strict=strict)
155155
if scheme == 'data':

0 commit comments

Comments
 (0)