Skip to main content

A fake data generator that is pydantic compatible.

Project description

Pyfake

A flexible, schema-driven fake data generator built on top of Pydantic v2.

Documentation · Github · PyPI

Generate realistic fake data for your Pydantic models with ease. Perfect for testing, prototyping, and anywhere you need valid mock data.

⚡ Quick Example

from typing import Annotated, List, Set, Literal
from pydantic import BaseModel, Field
from pyfake import fake
from rich import print


class Playlist(BaseModel):
    track_ids: List[int]
    genre: Literal["rock", "pop", "jazz"]
    tags: Annotated[List[str], Field(min_length=2, max_length=5)]
    unique_ratings: Set[int]

result = fake(Playlist, as_dict=True)
print(result)

# {
#     "track_ids": [28, 25, 95, 40], 
#     "genre": "pop", 
#     "tags": ["CJKHILHXTN", "qkhhjDJYiV"], 
#     "unique_ratings": {17, 49}
# }

✨ Why Pyfake?

Problem Most fake data generators Pyfake
Random but not structured ❌ Generates random data without understanding the schema ✅ Reads your Pydantic models to produce structured, schema-aware data
Structured but not realistic ❌ Generates data that fits the schema but isn't realistic (e.g. random strings for names) ✅ Uses intelligent generators to produce realistic fake data (e.g. names, addresses)
Hard to extend ❌ Difficult to add custom generators or handle complex types ✅ Easily extensible with a flexible generator registry and schema resolution system
Support for constraints ❌ Ignores field constraints like min_length, gt, multiple_of ✅ Respects all Pydantic field constraints when generating data
Support for python primitive types ❌ Limited support for complex types like Decimal, UUID, datetime ✅ Full support for Python primitives, including Decimal, UUID, datetime, and more
Reproducibility ❌ No built-in way to generate the same fake data across runs ✅ Supports seeding for reproducible fake data generation

🧠 How It Works

Pyfake reads your Pydantic schema and:

  • Inspects field types and constraints
  • Applies intelligent generators
  • Produces validated fake data

Installation

Using uv (Recommended)

uv add pyfake

Using pip

python -m venv .venv
source .venv/bin/activate
pip install pyfake

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfake-0.0.10.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfake-0.0.10-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfake-0.0.10.tar.gz.

File metadata

  • Download URL: pyfake-0.0.10.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyfake-0.0.10.tar.gz
Algorithm Hash digest
SHA256 471e525223f8912f300019f16b1149a280db8daeaf9424a28fbdaeaaa30dfce8
MD5 9d72c2236ff2a01b7b9160f0be97242a
BLAKE2b-256 af90fbf37ffc93728d05720dddfe9c92e7c6edcd5123d49af02fbe1b3d6d6f4d

See more details on using hashes here.

File details

Details for the file pyfake-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: pyfake-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyfake-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 673e59c9b74bd6f78e780870f99373769ddbe631c6c3a72a123a5508b5e5b3ae
MD5 b9962aece93d131173fa7edd88aab3c8
BLAKE2b-256 2b4d3a72cdf6fdce99295e8a96f8b6bebfa504808d7a6e295f31bfa0057bd483

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page