Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pydantic

> 编程语言
Open source

Data validation using Python type hints

28.4K stars0 likes2 views
WebsiteGitHub

About

Data validation using Python type hints

Pydantic Validation

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.10+; validate it with Pydantic.

Pydantic Logfire :fire:

We've launched Pydantic Logfire to help you monitor your applications. Learn more

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 or, 1.10.X-fixes git branch. 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 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 section in the documentation.

A Simple Example

python
from datetime import datetime
from typing import Optional
from pydantic import BaseModel

class 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.

Reporting a Security Vulnerability

See our security policy.

Issues· 587 open

View all issuesOpen on GitHub
  • #13886

    Add support for string constraints for `SecretStr` type

    feature requestUpdated Sep 29, 2026
  • #11709

    Allow computed fields (and methods) to be provided with `create_model()`

    feature requestv3Updated Sep 29, 2026
  • #13173

    Add support for Python 3.15

    feature requestUpdated Sep 29, 2026
  • #11287

    `.model_dump()` coerces custom types to base class despite custom serializer

    bug V2pendingUpdated Sep 29, 2026
  • #13681

    Independently rebuild nested models when used within other core schema generation contexts

    topic-performanceUpdated Sep 28, 2026
  • #10033

    Pydantic V3 — not

    metav3Updated Sep 28, 2026
  • #12099

    Serialization of unions picks the wrong member when a default's type is not an exact match for the type annotation

    topic-serializationbug V2topic-unionsUpdated Sep 27, 2026
  • #11812

    duplicate use of the model's wrap serializer

    bug V2topic-validators-serializersUpdated Sep 27, 2026
  • #11886

    use_enum_values=True does not work if enum is set after instance is created

    bug V2topic-enumsUpdated Sep 27, 2026
  • #12029

    JSON schema for enum of lists missing `items` parameter

    feature requesttopic-enumsUpdated Sep 27, 2026

> Tags

Pythonhintsjson-schemaparsingpydantic

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言