Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pydantic/pydantic
Data validation using Python type hints
https://github.com/pydantic/pydantic
hints json-schema parsing pydantic python python310 python311 python312 python37 python38 python39 validation
Last synced: about 12 hours ago
JSON representation
Data validation using Python type hints
- Host: GitHub
- URL: https://github.com/pydantic/pydantic
- Owner: pydantic
- License: mit
- Created: 2017-05-03T21:23:58.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T08:34:57.000Z (3 months ago)
- Last Synced: 2024-10-29T09:50:09.487Z (3 months ago)
- Topics: hints, json-schema, parsing, pydantic, python, python310, python311, python312, python37, python38, python39, validation
- Language: Python
- Homepage: https://docs.pydantic.dev
- Size: 154 MB
- Stars: 20,917
- Watchers: 117
- Forks: 1,881
- Open Issues: 444
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: docs/contributing.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
- best-of-python - GitHub - 10% open · ⏱️ 06.06.2024): (Data Validation)
- my-awesome-github-stars - pydantic/pydantic - Data validation using Python type hints (Python)
- awesome-ccamel - pydantic/pydantic - Data validation using Python type hints (Python)
- awesome-starred-test - pydantic/pydantic - Data validation using Python type hints (Python)
- awesome-repositories - pydantic/pydantic - Data validation using Python type hints (Python)
- awesome-list - pydantic - Data parsing and validation using Python type hints. (Data Processing / Data Representation)
- awesome-llm-json - Pydantic
- StarryDivineSky - pydantic/pydantic
- jimsghstars - pydantic/pydantic - Data validation using Python type hints (Python)
- stars - pydantic
- stars - pydantic
- awesome_ai_agents - Pydantic - Pydantic is a Python library facilitating data validation through type hints, particularly useful for AI agents, offering fast validation capabilities and compatibility with various development tools [github](https://github.com/pydantic/pydantic) | [website](https://docs.pydantic.dev/) (Learning / Repositories)
README
# Pydantic
[![CI](https://img.shields.io/github/actions/workflow/status/pydantic/pydantic/ci.yml?branch=main&logo=github&label=CI)](https://github.com/pydantic/pydantic/actions?query=event%3Apush+branch%3Amain+workflow%3ACI)
[![Coverage](https://coverage-badge.samuelcolvin.workers.dev/pydantic/pydantic.svg)](https://coverage-badge.samuelcolvin.workers.dev/redirect/pydantic/pydantic)
[![pypi](https://img.shields.io/pypi/v/pydantic.svg)](https://pypi.python.org/pypi/pydantic)
[![CondaForge](https://img.shields.io/conda/v/conda-forge/pydantic.svg)](https://anaconda.org/conda-forge/pydantic)
[![downloads](https://static.pepy.tech/badge/pydantic/month)](https://pepy.tech/project/pydantic)
[![versions](https://img.shields.io/pypi/pyversions/pydantic.svg)](https://github.com/pydantic/pydantic)
[![license](https://img.shields.io/github/license/pydantic/pydantic.svg)](https://github.com/pydantic/pydantic/blob/main/LICENSE)
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://docs.pydantic.dev/latest/contributing/#badges)Data validation using Python type hints.
Fast and extensible, Pydantic plays nicely with your linters/IDE/brain.
Define how data should be in pure, canonical Python 3.9+; validate it with Pydantic.## Pydantic Logfire :fire:
We've recently launched Pydantic Logfire to help you monitor your applications.
[Learn more](https://pydantic.dev/articles/logfire-announcement)## Pydantic V1.10 vs. V2
Pydantic V2 is a ground-up rewrite that offers many new features, performance improvements, and some breaking changes compared to Pydantic V1.
If you're using Pydantic V1 you may want to look at the
[pydantic V1.10 Documentation](https://docs.pydantic.dev/) or,
[`1.10.X-fixes` git branch](https://github.com/pydantic/pydantic/tree/1.10.X-fixes). Pydantic V2 also ships with the latest version of Pydantic V1 built in so that you can incrementally upgrade your code base and projects: `from pydantic import v1 as pydantic_v1`.## Help
See [documentation](https://docs.pydantic.dev/) for more details.
## Installation
Install using `pip install -U pydantic` or `conda install pydantic -c conda-forge`.
For more installation options to make Pydantic even faster,
see the [Install](https://docs.pydantic.dev/install/) section in the documentation.## A Simple Example
```python
from datetime import datetime
from typing import Optional
from pydantic import BaseModelclass User(BaseModel):
id: int
name: str = 'John Doe'
signup_ts: Optional[datetime] = None
friends: list[int] = []external_data = {'id': '123', 'signup_ts': '2017-06-01 12:22', 'friends': [1, '2', b'3']}
user = User(**external_data)
print(user)
#> User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
print(user.id)
#> 123
```## Contributing
For guidance on setting up a development environment and how to make a
contribution to Pydantic, see
[Contributing to Pydantic](https://docs.pydantic.dev/contributing/).## Reporting a Security Vulnerability
See our [security policy](https://github.com/pydantic/pydantic/security/policy).