{"id":5038,"library":"python-mimeparse","title":"Python-MimeParse","description":"Python-MimeParse is a stable and mature project that provides basic functions for parsing MIME type names and matching them against a list of media ranges, adhering to HTTP specifications. The current version is 2.0.0, which includes support for CPython 3.13 and drops support for Python 3.7. The project aims for stability with infrequent, but significant, updates.","status":"active","version":"2.0.0","language":"en","source_language":"en","source_url":"https://github.com/falconry/python-mimeparse","tags":["mime","media-type","http","parsing","content-type"],"install":[{"cmd":"pip install python-mimeparse","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"parse_mime_type","correct":"from mimeparse import parse_mime_type"},{"symbol":"parse_media_range","correct":"from mimeparse import parse_media_range"},{"symbol":"quality","correct":"from mimeparse import quality"},{"symbol":"quality_parsed","correct":"from mimeparse import quality_parsed"},{"symbol":"best_match","correct":"from mimeparse import best_match"}],"quickstart":{"code":"from mimeparse import best_match\n\nsupported_types = ['application/json', 'text/html', 'image/jpeg', 'text/plain']\naccept_header = 'text/*;q=0.5, application/json;q=1.0, */*;q=0.8'\n\nmatch = best_match(supported_types, accept_header)\nprint(f\"Best match for '{accept_header}' from supported types: {match}\")\n\n# Example with parsing a specific mime type\nfrom mimeparse import parse_mime_type\nmime_type = 'application/json; charset=utf-8'\nparsed_type = parse_mime_type(mime_type)\nprint(f\"Parsed '{mime_type}': {parsed_type}\")","lang":"python","description":"This quickstart demonstrates how to use `best_match` to select the most suitable MIME type based on an `Accept` header and available types, and `parse_mime_type` to break down a MIME type into its components."},"warnings":[{"fix":"Upgrade to Python 3.8+ or pin python-mimeparse to a 1.x version.","message":"Version 2.0.0 dropped official support for Python 3.7. Users on Python 3.7 or older must remain on python-mimeparse 1.x.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Always use `pip install python-mimeparse` instead of `pip install mimeparse`.","message":"There is an older, unmaintained package named `mimeparse` on PyPI (last updated 2013). Ensure you install `python-mimeparse` to get the actively maintained version.","severity":"gotcha","affected_versions":"All"},{"fix":"Review logic using `best_match` or `quality` if upgrading from pre-1.6.0 versions to account for improved q-value handling.","message":"Behavior related to `q` (quality) parameters in media ranges (e.g., in `Accept` headers) was significantly enhanced in version 1.6.0. Upgrading from versions prior to 1.6.0 might result in different `best_match` or `quality` outcomes for complex media range comparisons due to more accurate RFC compliance.","severity":"gotcha","affected_versions":"<1.6.0"},{"fix":"No direct user fix needed, but be aware that older versions of `python-mimeparse` would not be compatible with Python 3.13+.","message":"Version 2.0.0 internally addressed the deprecation and removal of the `cgi` module in Python 3.13 by vendoring necessary functions. While this prevents a future runtime error for users, it represents a significant internal compatibility overhaul for Python versions beyond 3.11.","severity":"breaking","affected_versions":"All Python 3.13+"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}