Skip to main content

Pydantic Media Type

This package provides a Pydantic type that can be used to validate media types. It uses the media types from the mimetypes module of The Python Standard Library.

Installation

Install using uv:

uv add pydantic-media-type

or using pip:

pip install pydantic-media-type

Example

from pydantic import BaseModel

from pydantic_media_type import MediaType


class Model(BaseModel):
    media_type: MediaType

print(Model(media_type=MediaType("image/png")).media_type)  # Will print: image/png
Model(media_type=MediaType("invalid"))  # Will raise pydantic.ValidationError with code media_type_unsupported

Development

Getting the project up and running can be achieved without much effort using Docker Compose. Doing so ensures that there should be very little difference in environment between all of us devs.

Starting the project

docker compose build
docker compose run --rm pydantic-media-type sh

The last command gives you a shell within the container.

Dependency management

We shouldn't have any other dependencies other than python and pydantic.

However, we do have some dev dependencies like:

  • ruff
  • mypy
  • pytest

We will do our best to keep those up to date. Should you want to upgrade them yourself, please do it from the shell inside the container using:

uv sync --upgrade

Similarly, installing new dependencies is possible using the command:

uv add name-of-the-dependency-to-install

Dev tools

This project uses ruff, mypy and pytest. The preferred way to run them is by using the container, for example:

docker compose build
docker compose run --rm pydantic-media-type sh
uv run ruff check
uv run mypy .
uv run pytest -v

Metadata

Release files for pydantic-media-type 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-media-type 0.1.0
File Size Uploaded Provenance Actions
pydantic_media_type-0.1.0.tar.gz 2.2 kB Without provenance Details for pydantic_media_type-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-media-type 0.1.0
File Interpreter ABI Platform Actions
pydantic_media_type-0.1.0-py3-none-any.whl Python 3 none any Details for pydantic_media_type-0.1.0-py3-none-any.whl

Total release size: 5.1 kB

Release files / pydantic_media_type-0.1.0.tar.gz

Download URL pydantic_media_type-0.1.0.tar.gz
Size 2.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8dab17a9d205b5570958fd7f2e4022bd335bd05d9b06914dd4560e79e17c5be0
BLAKE2b-256 checksum
How to use checksums
23fb09595645ee70dc005ff346cc81c3352bb626f056a7d2806c8d03b8038e47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pydantic_media_type-0.1.0-py3-none-any.whl

Download URL pydantic_media_type-0.1.0-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
921f6db78cc7b41ab2ca1a90932409c22524550453cb325c0883180c07f8fa27
BLAKE2b-256 checksum
How to use checksums
9f46d0b491cf224504126b684f09d7d8ab332ae1ec8cc8c6741ffddb3e5e137e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pydantic-media-type 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page