Skip to content

inabayuta/pydantic

 
 

Repository files navigation

pydantic

CI Coverage pypi CondaForge downloads versions license

Python の型ヒントを使用したデータバリデーションと設定管理

高速で拡張可能な pydantic はあなたのリンター/IDE/脳でうまく連携します。

ヘルプ

より詳細な情報はドキュメンテーションを見てください。

インストール

インストールは pip install -U pydantic または conda install pydantic -c conda-forge を使用します。 pydantic をより高速化するインストールオプションの詳細は、ドキュメントのインストールを見てください。

簡単な例

from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel

class User(BaseModel):
    id: int
    name = '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

貢献

開発環境の設定と pydantic への貢献方法に関するガイダンスは、Pydantic への貢献を参照してください。

セキュリティーの脆弱性の報告

セキュリティーポリシーを見てください。

About

Data parsing and validation using Python type hints

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.7%
  • Other 0.3%