CheckOps home

Tools directory

P

CheckOps

Polyfactory

Polyfactory is an MIT-licensed Python library from the Litestar organisation that builds mock data factories from type hints for dataclasses, Pydantic, attrs, TypedDict, msgspec and ORM models.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

Introduction

Polyfactory provides simple and powerful factories for mock data generation. Factories read the type hints of a model and generate valid values automatically, so UserFactory.build() returns a populated instance with little or no configuration.

It supports dataclasses, TypedDicts, Pydantic models, attrs classes, msgspec structs, Beanie and Odmantic documents and SQLAlchemy models. Fields can be overridden, use Faker, be generated with custom functions, or be marked to be ignored; batch builds and persistence handlers support databases. Pytest fixtures can be registered from factories.

Release v3.5.0 shipped in October 2026.

In the quality loop it supports Python unit and integration tests, especially for API models.

The source code is at litestar-org/polyfactory on GitHub under the MIT licence, with about 1,500 stars; the most recent commit was on 25 October 2026.

Features

  1. Type-hint driven: Automatic valid data.
  2. Many model types: Pydantic, dataclasses, attrs, msgspec and more.
  3. Overrides: Fixed or custom values.
  4. Batch builds: Many objects.
  5. Pytest fixtures: Register factories as fixtures.

Pros

  1. Minimal config: Types do the work.
  2. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  3. Actively maintained: The repository had commits as recent as 25 October 2026.

Cons

  1. Random data: Set values that affect behaviour explicitly.
from dataclasses import dataclass
from polyfactory.factories import DataclassFactory

@dataclass
class User:
    name: str
    age: int

class UserFactory(DataclassFactory[User]): ...
user = UserFactory.build()

Resources:

Pricing

Polyfactory is free and open source under the MIT licence.

  1. Python teams using Pydantic or dataclasses.
  2. Not a fit for untyped code.

Conclusion

Polyfactory is a modern, type-driven factory library for Python.

On CheckOps, Polyfactory is filed under the Unit testing and Integration testing stages. Related tools listed here include factory_boy, Model Bakery, Faker (Python), Mimesis, Hypothesis and Fishery. Before choosing, compare them on licence, supported languages and platforms, hosting model, and how well each fits your existing CI pipeline. Facts on this page were checked against the official website, documentation and repository on 11 November 2026; statements the vendor makes about its own product are marked as vendor claims.

Compare

CheckOps pages that put Polyfactory next to related tools. There is no paid placement on these lists.

Alternatives

Other tools on CheckOps that cover similar ground. Open a page, or compare one with Polyfactory side by side.