Metadata-Version: 2.1
Name: pyfactories
Version: 1.0.0
Summary: Mock data generation for pydantic and dataclasses
Project-URL: Homepage, https://github.com/tarsil/pyfactories
Project-URL: Documentation, https://pyfactories.tarsild.io
Project-URL: Changelog, https://pyfactories.tarsild.io/release-notes/
Project-URL: Funding, https://github.com/sponsors/tarsil
Project-URL: Source, https://github.com/tarsil/pyfactories
Author-email: Tiago Silva <tiago.arasilva@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: pyfactories
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: AnyIO
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Topic :: Internet
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: faker<30.0.0,>=18.11.1
Requires-Dist: pydantic<2.0.0,>=1.10.9
Requires-Dist: typing-extensions<7.0.0,>=4.6.3
Provides-Extra: dev
Requires-Dist: email-validator<4.0.0,>=2.0.0.post2; extra == 'dev'
Requires-Dist: hypothesis<7.0.0,>=6.79.1; extra == 'dev'
Requires-Dist: ipdb<1.0.0,>=0.13.13; extra == 'dev'
Requires-Dist: pre-commit<4.0.0,>=3.3.1; extra == 'dev'
Provides-Extra: doc
Requires-Dist: mdx-include<2.0.0,>=1.4.1; extra == 'doc'
Requires-Dist: mkautodoc<0.3.0,>=0.2.0; extra == 'doc'
Requires-Dist: mkdocs-markdownextradata-plugin<0.3.0,>=0.1.7; extra == 'doc'
Requires-Dist: mkdocs-material==9.1.5; extra == 'doc'
Requires-Dist: mkdocs<2.0.0,>=1.4.2; extra == 'doc'
Requires-Dist: mkdocstrings<0.21.0,>=0.19.0; extra == 'doc'
Requires-Dist: pyyaml<7.0.0,>=5.3.1; extra == 'doc'
Provides-Extra: test
Requires-Dist: autoflake<3.0.0,>=2.0.2; extra == 'test'
Requires-Dist: black<24.0.0,>=23.3.0; extra == 'test'
Requires-Dist: isort<6.0.0,>=5.12.0; extra == 'test'
Requires-Dist: mypy<2.0.0,>=1.1.0; extra == 'test'
Requires-Dist: pytest-asyncio<1.0.0,>=0.21.0; extra == 'test'
Requires-Dist: pytest-cov<5.0.0,>=4.0.0; extra == 'test'
Requires-Dist: pytest<8.0.0,>=7.2.2; extra == 'test'
Requires-Dist: requests>=2.28.2; extra == 'test'
Requires-Dist: ruff<1.0.0,>=0.0.256; extra == 'test'
Requires-Dist: saffier[postgres,testing]>=0.13.0; extra == 'test'
Description-Content-Type: text/markdown

# PyFactories

<p align="center">
  <a href="https://esmerald.dymmond.com"><img src="https://res.cloudinary.com/tarsild/image/upload/v1687347327/packages/pyfactories/logo_lvtl5d.png" alt='Esmerald'></a>
</p>


<p align="center">
    <em>🚀 Mock data generation for pydantic and dataclasses. 🚀</em>
</p>

<p align="center">
<a href="https://github.com/tarsil/pyfactories/workflows/Test%20Suite/badge.svg?event=push&branch=main" target="_blank">
    <img src="https://github.com/tarsil/pyfactories/workflows/Test%20Suite/badge.svg?event=push&branch=main" alt="Test Suite">
</a>

<a href="https://pypi.org/project/pyfactories" target="_blank">
    <img src="https://img.shields.io/pypi/v/pyfactories?color=%2334D058&label=pypi%20package" alt="Package version">
</a>

<a href="https://pypi.org/project/pyfactories" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/pyfactories.svg?color=%2334D058" alt="Supported Python versions">
</a>
</p>

---

**Documentation**: [https://pyfactories.tarsild.io][docs] 📚

**Source Code**: [https://github.com/dymmond/esmerald][github]

---

## Motivation

[Pydantic Factories][pydantic_factories] was initially created and used by a lot of people and it
is an extremely powerful package that was heavily tested by the same authors of Starlite, now,
Litestar. During their own evolution and development they felt the need to add more support to the
package that was no longer only pydantic and therefore they created the [Polyfactory][polyfactory]
and archived the [Pydantic Factories][pydantic_factories].

PyFactories is a literal fork from the latest Pydantic Factories and aims to continue the same
work set by the previous creators with the difference that will be only maintaining the factories
for Pydantic and the upcoming Pydantic 2.0+.

The team behind Pydantic Factories did a fantastic job and the credit goes to them while
**PyFactories** continues its own fork path.

If you aim to use something more than just Pydantic, it is strongly recommended to visit
[Polyfactory][polyfactory] and migrate to it and of course, leave them a ⭐️.

In the meantime if you only want the Pydantic side of things, then you can use **PyFactories** in
the same fashion as its ancestor.

## Installation

```shell
pip install pyfactories
```

## Migrate from Pydantic Factories

It is actually straightforward, you simply need to replace `pydantic_factories` with `pyfactories`
in your imports and that is it.

## Example

```python
from datetime import date, datetime
from typing import List, Union

from pydantic import UUID4, BaseModel

from pyfactories import ModelFactory


class Person(BaseModel):
    id: UUID4
    name: str
    hobbies: List[str]
    age: Union[float, int]
    birthday: Union[datetime, date]


class PersonFactory(ModelFactory):
    __model__ = Person


result = PersonFactory.build()
```

And just its own ancestor, this is it. Almost no work, you are able to create mock data objects
that fits the `Person` Pydantic class model definition.

This is possible because of the typing information available on the pydantic model and model-fields,
which are used as a source of truth for data generation.

The factory parses the information stored in the pydantic model and generates a dictionary of kwargs
that are passed to the `Person` class' `init` method.

## Features

Being initially the fork of [Pydantic Factories][pydantic_factories], that also means:

- ✅ Supports both built-in and pydantic types
- ✅ Supports pydantic field constraints
- ✅ Supports complex field types
- ✅ Supports custom model fields
- ✅ Supports dataclasses
- ✅ Supports TypedDicts

## Why This Library

This library was widely used before because of its powerfull features and therefore with the
upcoming Pydantic 2.0, it will be even more robust with the core done in Rust.

- 💯 Powerful
- 💯 Extensible
- 💯 Simple
- 💯 Rigorously tested

## Contributing

This library is open to contributions. [Please see the contribution guide!][contributing]

## Star the initial authors

Although the intial [Pydantic Factories][pydantic_factories] is no longer maintained, there is
always the [Polyfactory][polyfactory] that deserves a ⭐️.

[docs]: https://pyfactories.tarsild.io
[github]: https://github.com/tarsil/pyfactories
[pydantic_factories]: https://github.com/litestar-org/pydantic-factories
[polyfactory]: https://pypi.org/project/polyfactory/
[contributing]: https://pyfactories.tarsild.io/contributing
