Metadata-Version: 2.1 Name: polyfactory Version: 2.15.0 Summary: Mock data generation factories Project-URL: Issue Tracker, https://github.com/litestar-org/polyfactory/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc Project-URL: Changelog, https://github.com/litestar-org/polyfactory/releases/ Project-URL: Twitter, https://twitter.com/LitestarAPI Project-URL: Reddit, https://www.reddit.com/r/LitestarAPI Project-URL: Discord, https://discord.gg/MmcwxztmQb Project-URL: Blog, https://blog.litestar.dev Project-URL: homepage, https://github.com/litestar-org/polyfactory Project-URL: repository, https://github.com/litestar-org/polyfactory Project-URL: documentation, https://github.com/litestar-org/polyfactory Author-email: Na'aman Hirschfeld Maintainer-email: Visakh Unnikrishnan , Cody Fincher , Janek Nouvertné , Jacob Coffee , Peter Schutt License: MIT License-File: LICENSE Keywords: attrs,dataclasses,msgspec,pydantic,sqlalchemy Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Software Development :: Testing :: Unit Classifier: Topic :: Utilities Classifier: Typing :: Typed Requires-Python: <4.0,>=3.8 Requires-Dist: faker Requires-Dist: typing-extensions>=4.6.0 Provides-Extra: attrs Requires-Dist: attrs>=22.2.0; extra == 'attrs' Provides-Extra: beanie Requires-Dist: beanie; extra == 'beanie' Requires-Dist: pydantic[email]; extra == 'beanie' Provides-Extra: full Requires-Dist: attrs; extra == 'full' Requires-Dist: beanie; extra == 'full' Requires-Dist: msgspec; extra == 'full' Requires-Dist: odmantic; extra == 'full' Requires-Dist: pydantic; extra == 'full' Requires-Dist: sqlalchemy; extra == 'full' Provides-Extra: msgspec Requires-Dist: msgspec; extra == 'msgspec' Provides-Extra: odmantic Requires-Dist: odmantic<1.0.0; extra == 'odmantic' Requires-Dist: pydantic[email]; extra == 'odmantic' Provides-Extra: pydantic Requires-Dist: pydantic[email]; extra == 'pydantic' Provides-Extra: sqlalchemy Requires-Dist: sqlalchemy>=1.4.29; extra == 'sqlalchemy' Description-Content-Type: text/markdown

Polyfactory Logo - Light

| Project | | Status | | --------- | :-- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CI/CD | | [![Publish package](https://github.com/litestar-org/polyfactory/actions/workflows/publish.yaml/badge.svg)](https://github.com/litestar-org/polyfactory/actions/workflows/publish.yaml) [![ci](https://github.com/litestar-org/polyfactory/actions/workflows/ci.yaml/badge.svg)](https://github.com/litestar-org/polyfactory/actions/workflows/ci.yaml) [![pages-build-deployment](https://github.com/litestar-org/polyfactory/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/litestar-org/polyfactory/actions/workflows/pages/pages-build-deployment) | | Quality | | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar&metric=coverage)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=litestar-org_litestar&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=litestar-org_litestar) | | Package | | [![PyPI - Version](https://img.shields.io/pypi/v/polyfactory?labelColor=202235&color=edb641&logo=python&logoColor=edb641)](https://badge.fury.io/py/polyfactory) ![PyPI - Support Python Versions](https://img.shields.io/pypi/pyversions/polyfactory?labelColor=202235&color=edb641&logo=python&logoColor=edb641) ![Pydantic Factories PyPI - Downloads](https://img.shields.io/pypi/dm/pydantic-factories?logo=python&label=Pydantic%20Factories%20downloads&labelColor=202235&color=edb641&logoColor=edb641) ![Polyfactory PyPI - Downloads](https://img.shields.io/pypi/dm/polyfactory?logo=python&label=Polyfactory%20downloads&labelColor=202235&color=edb641&logoColor=edb641) | | Community | | [![Reddit](https://img.shields.io/reddit/subreddit-subscribers/litestarapi?label=r%2FLitestar&logo=reddit&labelColor=202235&color=edb641&logoColor=edb641)](https://reddit.com/r/litestarapi) [![Discord](https://img.shields.io/discord/919193495116337154?labelColor=202235&color=edb641&label=chat%20on%20discord&logo=discord&logoColor=edb641)](https://discord.gg/X3FJqy8d2j) [![Matrix](https://img.shields.io/badge/chat%20on%20Matrix-bridged-202235?labelColor=202235&color=edb641&logo=matrix&logoColor=edb641)](https://matrix.to/#/#litestar:matrix.org) [![Medium](https://img.shields.io/badge/Medium-202235?labelColor=202235&color=edb641&logo=medium&logoColor=edb641)](https://blog.litestar.dev) [![Twitter](https://img.shields.io/twitter/follow/LitestarAPI?labelColor=202235&color=edb641&logo=twitter&logoColor=edb641&style=flat)](https://twitter.com/LitestarAPI) [![Blog](https://img.shields.io/badge/Blog-litestar.dev-202235?logo=blogger&labelColor=202235&color=edb641&logoColor=edb641)](https://blog.litestar.dev) | | Meta | | [![Litestar Project](https://img.shields.io/badge/Litestar%20Org-%E2%AD%90%20Polyfactory-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://github.com/litestar-org/polyfactory) [![types - Mypy](https://img.shields.io/badge/types-Mypy-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://github.com/python/mypy) [![License - MIT](https://img.shields.io/badge/license-MIT-202235.svg?logo=python&labelColor=202235&color=edb641&logoColor=edb641)](https://spdx.org/licenses/) [![Litestar Sponsors](https://img.shields.io/badge/Sponsor-%E2%9D%A4-%23edb641.svg?&logo=github&logoColor=edb641&labelColor=202235)](https://github.com/sponsors/litestar-org) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json&labelColor=202235)](https://github.com/astral-sh/ruff) [![code style - Black](https://img.shields.io/badge/code%20style-black-000000.svg?logo=python&labelColor=202235&logoColor=edb641)](https://github.com/psf/black) [![Sourcery](https://img.shields.io/badge/Sourcery-enabled-edb641?labelColor=202235&logoColor=edb641)](https://sourcery.ai) [![All Contributors](https://img.shields.io/github/all-contributors/litestar-org/polyfactory?labelColor=202235&color=edb641&logoColor=edb641)](#contributors-) |
# Polyfactory Polyfactory is a simple and powerful mock data generation library, based around type hints and supporting dataclasses, typed-dicts, pydantic models, msgspec structs and more. Polyfactory part of the Litestar project and as such actively maintained by a community of maintainers and contributors. ## Example ```python from dataclasses import dataclass from polyfactory.factories import DataclassFactory @dataclass class Person: name: str age: float height: float weight: float class PersonFactory(DataclassFactory[Person]): ... def test_is_person() -> None: person_instance = PersonFactory.build() assert isinstance(person_instance, Person) ``` That's it - with almost no work, we are able to create a mock data object fitting the `Person` class model definition. This is possible because of the typing information available on the dataclass, which are used as a source of truth for data generation. The factory parses the information stored in the dataclass and generates a dictionary of kwargs that are passed to `Person`. ## Documentation Usage and API reference documentation is available on https://polyfactory.litestar.dev/. ## Installation ```shell pip install polyfactory ``` ## Relation to Pydantic-Factories Prior to version 2, this library was known as [pydantic-factories](https://pypi.org/project/pydantic-factories/), a name under which it gained quite a bit of popularity. A main motivator for the 2.0 release was that we wanted to support more than just Pydantic models, something which also required a change to its core architecture. As this library would no longer be directly tied to Pydantic, `polyfactory` was chosen as its new name to reflect its capabilities; It can generate mock data for dataclasses, typed-dicts, Pydantic, odmantic, and beanie ODM models, as well as custom factories. ## Contributing This library is a community driven open source project. We welcome and encourage contributions. Please checkout the GitHub issues, read the contribution guide (at the repository's root), and you're always welcome to [join our discord server](https://discord.gg/F4jPQzHpBU). ## Contributors ✨ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Na'aman Hirschfeld
Na'aman Hirschfeld

🚧 🚇 ⚠️ 💻 📖
Jacob Coffee
Jacob Coffee

🚧 📖 ⚠️
Janek Nouvertné
Janek Nouvertné

🚧 📖 ⚠️ 💻
Peter Schutt
Peter Schutt

🚧 ⚠️ 💻 📖
Marek Czaplicki
Marek Czaplicki

💻
Piotr Przybyło
Piotr Przybyło

💻
sygutss
sygutss

🐛 💻
chrisbeardy
chrisbeardy

📖
guacs
guacs

💻
Vadim
Vadim

💻
Simske
Simske

💻
Sondre Lillebø Gundersen
Sondre Lillebø Gundersen

💻
Mateusz Ciszczoń
Mateusz Ciszczoń

💻
Pedro Bernardes
Pedro Bernardes

💻
Martin Roy
Martin Roy

💻
Matthew Aylward
Matthew Aylward

💻
Elton H.Y. Chou
Elton H.Y. Chou

💻
Thang
Thang

💻
Daan
Daan

💻
Lyz
Lyz

💻
Thorin Schiffer
Thorin Schiffer

💻
Iipin
Iipin

💻
avihai-yosef
avihai-yosef

💻
anthonyh209
anthonyh209

💻
Roman Reznikov
Roman Reznikov

💻
gigelu
gigelu

💻
Rodrigo Medina
Rodrigo Medina

💻
Gerrit Egnew
Gerrit Egnew

💻
danielkatzan
danielkatzan

📖
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!