Skip to content

Commit c3dbd0d

Browse files
committed
Address review
1 parent 0a16e9c commit c3dbd0d

3 files changed

Lines changed: 5 additions & 17 deletions

File tree

Doc/library/mimetypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ behavior of the module.
134134
When *strict* is ``True`` (the default), the mapping will be added to the
135135
official MIME types, otherwise to the non-standard ones.
136136

137-
.. versionchanged:: 3.14
137+
.. deprecated:: 3.14
138138
*ext* values that do not start with ``'.'`` are deprecated.
139139

140140
.. versionchanged:: next

Lib/mimetypes.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ def add_type(self, type, ext, strict=True):
9393
Valid extensions are empty or start with a '.'.
9494
"""
9595
if ext and not ext.startswith('.'):
96-
raise ValueError(
97-
"Adding an extension without a leading dot "
98-
f"{ext!r} is not supported"
99-
)
96+
raise ValueError(f"Extension {ext!r} must start with '.'")
10097

10198
if not type:
10299
return

Lib/test/test_mimetypes.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,10 @@ def test_added_types_are_used(self):
390390
self.assertEqual(mime_type, 'testing/type')
391391

392392
def test_add_type_with_undotted_extension_not_supported(self):
393-
msg = (
394-
"Adding an extension without a leading dot "
395-
"'undotted' is not supported"
396-
)
397-
with self.assertRaisesRegex(
398-
ValueError,
399-
msg,
400-
):
393+
msg = "Extension 'undotted' must start with '.'"
394+
with self.assertRaisesRegex(ValueError, msg):
401395
mimetypes.add_type("testing/type", "undotted")
402-
with self.assertRaisesRegex(
403-
ValueError,
404-
msg,
405-
):
396+
with self.assertRaisesRegex(ValueError, msg):
406397
mimetypes.add_type("", "undotted")
407398

408399

0 commit comments

Comments
 (0)