Pydantic V1 to Pydantic V2 Complete Migration Guide

Pydantic V2 is rewritten in Rust. BaseSettings moved to pydantic-settings, @validator replaced by @field_validator, and .dict() replaced by .model_dump().

⚡ Automated 1-Line Codemod

pip install bump-pydantic && bump-pydantic .

🚨 Breaking Changes List

🔧 Verified Migration Diff

// Pydantic V1 -> V2 Migration
- from pydantic import BaseModel, BaseSettings, validator
- class Settings(BaseSettings):
-     email: str
-     @validator('email')
-     def validate_email(cls, v): return v
- data = model.dict()

+ from pydantic import BaseModel, field_validator
+ from pydantic_settings import BaseSettings
+ class Settings(BaseSettings):
+     email: str
+     @field_validator('email', mode='after')
+     @classmethod
+     def validate_email(cls, v: str) -> str: return v
+ data = model.model_dump()