pydantic-compat is a compatibility layer designed to help developers write code that works seamlessly with both Pydantic v1 and v2. It provides common interfaces, aliases, and wrappers for key Pydantic components, allowing libraries and applications to support different Pydantic major versions without extensive conditional logic. The current version is 0.1.2, and it follows an as-needed release cadence to address compatibility needs.
pip install pydantic-compatVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a model using `CompatModel` and use `model_validator` for cross-version compatible validation. It also shows how to leverage `ConfigDict` for defining model configurations that adapt to Pydantic v1's `class Config` or v2's `model_config`.
Understand that you might still need conditional logic based on `pydantic.VERSION` for truly version-specific behavior or access to features not present in both major versions.
Always use `pydantic_compat.CompatModel` as the base for any model intended to be compatible across Pydantic v1 and v2. Ensure all relevant validators and configurations also use `pydantic_compat` imports.
Consult Pydantic's official migration guide for differences in configuration options. When in doubt, use options known to be common, or apply conditional logic based on `pydantic.VERSION` for specific configurations.
No dependency data recorded yet.