Repository navigation
Conversation
…r file paths feat: introduce MimeTypes class and deprecate file path support in guess_type with new guess_file_type method feat: add guess_file_type to mimetypes module to support path-based MIME lookups test: add test suite for mimetypes module Address PR feedback: fix mimetypes CLI, lazy imports, and doc deprecations
os, sys, and posixpath are loaded on interpreter start -- making them lazy has no meaningful effect, so they are made into plain imports. urllib.parse, warnings, and argparse.ArgumentParser are made into lazy imports. Inline imports are removed.
Per discussion and feedback, passing a Path is noted in text (not with a directive) as soft deprecated, and deprecated-removed for the 3.16 - 3.21 timeline.
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
closes #151576
This is a continuation of the aforementioned PR.
Deprecate passing file paths (path objects or any string which
urllib.parsedoesn't see as having a scheme) toguess_type, slating removal of support for 3.21.The soft-deprecation period, which started in 3.13 is noted in text under the
deprecated-removeddirective.As part of this work, lazy imports are converted to the 3.15+ syntax and moved to the top of the file. And lazy imports which were not meaningfully lazy (
sys,os,posixpath) were made non-lazy.Are we satisfied with the test changes? I considered the following additional changes but decided to wait for feedback:
file://URLs do not trigger the warningcc @StanFromIreland, @hugovk, I reviewed the original PR, and recall making a bit of a mistake with the way the deprecation should be stated. I'd especially appreciate your eyes on this one.
(Aside: I want to work through the deprecation process because there's an outstanding TODO I have on my list to go back to the devguide and document it. 😁 )
mimetypes.guess_type()#151575