Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit132b6bc

Browse files
KristinitaAA-Turnerhugovk
authored
pythongh-132054: Addapplication/yaml tomimetypes (python#132056)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parentfee8089 commit132b6bc

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

‎Doc/whatsnew/3.14.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,10 @@ mimetypes
910910

911911
(Contributed by Hugo van Kemenade in:gh:`129965`.)
912912

913+
* Add:rfc:`9512` ``application/yaml`` MIME type for YAML files (``.yaml``
914+
and ``.yml``). (Contributed by Sasha "Nelie" Chernykh and Hugo van Kemenade
915+
in:gh:`132056`.)
916+
913917

914918
multiprocessing
915919
---------------

‎Lib/mimetypes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ def _default_mime_types():
544544
'.rdf' :'application/xml',
545545
'.wsdl' :'application/xml',
546546
'.xpdl' :'application/xml',
547+
'.yaml' :'application/yaml',
548+
'.yml' :'application/yaml',
547549
'.zip' :'application/zip',
548550
'.3gp' :'audio/3gpp',
549551
'.3gpp' :'audio/3gpp',

‎Lib/test/test_mimetypes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def check_extensions():
243243
("application/x-texinfo",".texi"),
244244
("application/x-troff",".roff"),
245245
("application/xml",".xsl"),
246+
("application/yaml",".yaml"),
246247
("audio/flac",".flac"),
247248
("audio/matroska",".mka"),
248249
("audio/mp4",".m4a"),
@@ -285,6 +286,26 @@ def check_extensions():
285286
mimetypes.init()
286287
check_extensions()
287288

289+
deftest_guess_file_type(self):
290+
defcheck_file_type():
291+
formime_type,extin (
292+
("application/yaml",".yaml"),
293+
("application/yaml",".yml"),
294+
("audio/mpeg",".mp2"),
295+
("audio/mpeg",".mp3"),
296+
("video/mpeg",".m1v"),
297+
("video/mpeg",".mpe"),
298+
("video/mpeg",".mpeg"),
299+
("video/mpeg",".mpg"),
300+
):
301+
withself.subTest(mime_type=mime_type,ext=ext):
302+
result,_=mimetypes.guess_file_type(f"filename{ext}")
303+
self.assertEqual(result,mime_type)
304+
305+
check_file_type()
306+
mimetypes.init()
307+
check_file_type()
308+
288309
deftest_init_stability(self):
289310
mimetypes.init()
290311

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The ``application/yaml`` mime type (:rfc:`9512`) is now supported
2+
by:mod:`mimetypes`. Patch by Sasha "Nelie" Chernykh and Hugo van Kemenade.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp