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

gh-132054: Addapplication/yaml tomimetypes#132056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 9 commits intopython:mainfromKristinita:KiraMediaTypeApplicationYaml
Apr 21, 2025

Conversation

@Kristinita
Copy link
Contributor

@KristinitaKristinita commentedApr 3, 2025
edited
Loading

@AA-TurnerAA-Turner changed the titlegh-132054 Addapplication/yaml tomimetypesgh-132054: Addapplication/yaml tomimetypesApr 3, 2025
@brianschubert
Copy link
Member

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

@Kristinita
Copy link
ContributorAuthor

Kristinita commentedApr 3, 2025
edited
Loading

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 rungit 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.

@brianschubert
Copy link
Member

brianschubert commentedApr 3, 2025
edited
Loading

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

Kristinita reacted with thumbs up emojiKristinita reacted with hooray emoji

@AA-Turner
Copy link
Member

@Kristinita please read ourAI policy.

A

…mandpython#132056 (comment)Signed-off-by: Kristinita <Kristinita@users.noreply.github.com>
@Kristinita
Copy link
ContributorAuthor

Kristinita commentedApr 3, 2025
edited
Loading

Type: Fixed ✔️

@brianschubert , done. All checks have passed now.

Thanks.

@hugovk
Copy link
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?

@Kristinita
Copy link
ContributorAuthor

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 filetest_mimetypes.py in many cases contains tests solely for preferred extensions. Examples:

  1. Foraudio/mpeg media type:test_mimetypes.py has the test for the.mp3 preferred extension, but not for the non-preferred extension.mp2.
  2. Forvideo/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 thetext/plain media type?

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 filetest_mimetypes.py could have a function liketest_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.

@hugovk
Copy link
Member

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

deftest_guess_file_type(self):defcheck_file_type():formime_type,extin (                ("application/yaml",".yaml"),                ("application/yaml",".yml"),            ):withself.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 theaudio/mpeg andvideo/mpeg ones mentioned.

@python-cla-bot
Copy link

All commit authors signed the Contributor License Agreement.

CLA signed

@pythonpython deleted a commentApr 7, 2025
Copy link
Member

@hugovkhugovk left a 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 formimetypes 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!

Kristinita reacted with thumbs up emoji
(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`.)
Copy link
Member

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.

Copy link
ContributorAuthor

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 functiontest_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 ofKristinita would be better).

Thanks.

Copy link
Member

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!

@hugovkhugovk merged commit132b6bc intopython:mainApr 21, 2025
39 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@hugovkhugovkhugovk approved these changes

@AA-TurnerAA-TurnerAA-Turner approved these changes

@JelleZijlstraJelleZijlstraAwaiting requested review from JelleZijlstra

@AlexWaygoodAlexWaygoodAwaiting requested review from AlexWaygood

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@Kristinita@brianschubert@AA-Turner@hugovk

[8]ページ先頭

©2009-2025 Movatter.jp