GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-132054: Add ``application/yaml`` to ``mimetypes`` by Kristinita · Pull Request #132056 · python/cpython

Conversation

@Kristinita

@Kristinita Kristinita commented Apr 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Add application/yaml to mimetypes #132054

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Kristinita
pythongh-132054 Add application/yaml to mimetypes
5e0f103
@Kristinita
Kristinita requested a review from a team as a code owner April 3, 2025 17:43
@bedevere-app bedevere-app Bot added the awaiting review label Apr 3, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 3, 2025
Add application/yaml to mimetypes #132054
Closed
AA-Turner
AA-Turner reviewed Apr 3, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-04-03-20-28-54.gh-issue-132054.c1nlOx.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner
Update NEWS fragment
1031592
AA-Turner
AA-Turner approved these changes Apr 3, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Apr 3, 2025
@AA-Turner AA-Turner changed the title gh-132054 Add application/yaml to mimetypes gh-132054: Add application/yaml to mimetypes Apr 3, 2025
@Kristinita
Kristinita requested review from a team, AlexWaygood and JelleZijlstra as code owners April 3, 2025 18:40
@Kristinita
fix(error): remove .yml from the list of preferred extensions
a528d60
https://github.com/python/cpython/actions/runs/14249517987/job/39938739555?pr=132056#step:11:655
@brianschubert

brianschubert commented Apr 3, 2025

Copy link
Copy Markdown
Contributor

@Kristinita I think you accidentally included some unrelated changes in your last push

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kristinita

Kristinita commented Apr 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Type: Reply 💬

@brianschubert, I’m sorry, I made a mistake in the test file and create the new commit that fix tests. I can’t push my changes to GitHub, so I run git fetch, git rebase and then push changes to GitHub.

I can close this pull request, update my CPython fork and send a new pull request. Or should I do something else? I can’t find instructions for this case in Python Developer’s Guide.

I apologize for the concern.

Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brianschubert

brianschubert commented Apr 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

No worries! And no need to open a new PR. You can undo the extra changes by running git restore -s HEAD~1 ./ (which will reset your working tree to what it was before the commit), then remake the intended change to test_mimetypes.py and create a new commit.

Kristinita reacted with thumbs up emoji Kristinita reacted with hooray emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner

AA-Turner commented Apr 3, 2025

Copy link
Copy Markdown
Member

@Kristinita please read our AI policy.

A

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kristinita
fix(git): undo extra changes from the last push use “git restore” com…
6d29f25
…mand

python#132056 (comment)
Signed-off-by: Kristinita <[email protected]>
@Kristinita

Kristinita commented Apr 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Type: Fixed ✔️

@brianschubert , done. All checks have passed now.

Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

hugovk commented Apr 3, 2025

Copy link
Copy Markdown
Member

Please could you add it to What's New?

https://docs.python.org/3.14/whatsnew/3.14.html#mimetypes

And add a test for .yml?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Kristinita

Kristinita commented Apr 4, 2025

Copy link
Copy Markdown
Contributor Author

Type: Question ❓

1. Question

And add a test for .yml?

@hugovk, what is the preferred format for tests for non-preferred extensions like .yml? I was looking for the answer to this in previous pull requests that add new media types, but I can’t find a conventional method.

2. Missing tests

Currently, the file test_mimetypes.py in many cases contains tests solely for preferred extensions. Examples:

  1. For audio/mpeg media type: test_mimetypes.py has the test for the .mp3 preferred extension, but not for the non-preferred extension .mp2.
  2. For video/mpeg media type: test_mimetypes.py has the test for the .mpeg preferred extension, but not for non-preferred extensions .m1v, .mpa, .mpe and .mpg.

3. Existing test for non-preferred extensions

Should I create a test like the test for the text/plain media type?

cpython/Lib/test/test_mimetypes.py

Lines 177 to 179 in ef17252

all = self.db.guess_all_extensions('text/plain', strict=True)
self.assertTrue(set(all) >= {'.bat', '.c', '.h', '.ksh', '.pl', '.txt'})
self.assertEqual(len(set(all)), len(all)) # no duplicates

4. Simpler adding tests

Possibly, it would be nice if adding tests for non-preferred extension will be simpler. For example, the file test_mimetypes.py could have a function like test_non_preferred_extensions to which users will be able to add all non-preferred extensions for media types. Example:

("application/yaml", ".yml"),
("audio/mpeg", ".mp2"),
("video/mpeg", ".m1v"),
("video/mpeg", ".mpa"),
("video/mpeg", ".mpe"),
("video/mpeg", ".mpg")

Thanks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

hugovk commented Apr 4, 2025

Copy link
Copy Markdown
Member

We could add some a test case to check the output of guess_file_type is as expected, for example:

    def test_guess_file_type(self):
        def check_file_type():
            for mime_type, ext in (
                ("application/yaml", ".yaml"),
                ("application/yaml", ".yml"),
            ):
                with self.subTest(mime_type=mime_type, ext=ext):
                    result, _ = mimetypes.guess_file_type(f"filename{ext}")
                    self.assertEqual(result, mime_type)

        check_file_type()
        mimetypes.init()
        check_file_type()

No need to exhaustively fill lots of other preferred+optional extensions, but we could include a few more, such as the audio/mpeg and video/mpeg ones mentioned.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@python-cla-bot

python-cla-bot Bot commented Apr 6, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@python python deleted a comment Apr 7, 2025
hugovk added 4 commits April 20, 2025 14:58
@hugovk
Test guess_file_type with types with multiple extensions
3b3bd87
@hugovk
Omit ambiguous .mpa (audio/mpeg on Windows)
bb8b661
@hugovk
Add What's New entry
c8a4f73
@hugovk
Update What's New entry
c5a6f68
hugovk
hugovk approved these changes Apr 20, 2025
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to add tests and a What's New entry.

The What's New for mimetypes is getting a bit sprawling, but we can copyedit that later as part of #123299.

@Kristinita Thank you and congratulations on your first contribution to CPython!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Kristinita reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Doc/whatsnew/3.14.rst Outdated
(Contributed by Hugo van Kemenade in :gh:`129965`.)

* Add :rfc:`9512` ``application/yaml`` MIME type for YAML files (``.yaml``
and ``.yml``). (Contributed by Kristinita in :gh:`132056`.)

@hugovk hugovk Apr 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kristinita We can put your full name here if you like.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Kristinita Kristinita Apr 20, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hugovk, thanks for adding the function test_guess_file_type()!

My contribution here is insignificant, and I think it would be more fair if you will add your name instead of my.

(But if the name of the author of the pull request is required, perhaps, Sasha “Nelie” Chernykh instead of Kristinita would be better).

Thanks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Apr 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You contribution is not insignificant. I've put both our names there, thanks again!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hugovk
Update credit
3bf23ce
@hugovk
hugovk merged commit 132b6bc into python:main Apr 21, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk approved these changes
@AA-Turner AA-Turner AA-Turner approved these changes
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Kristinita @brianschubert @AA-Turner @hugovk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.