CodeVetter · Repo Unpack · Extension points
pydantic/pydantic
Most application extensions attach to public schema hooks, Annotated metadata, decorators, factories, or plugin protocols. JSON Schema generation offers an explicit generator subclass boundary separate from executable-schema generation. Installed validation plugins wrap three input methods without replacing the underlying Rust validator. Adding a native schema kind requires coordination with fixed dispatch and schema definitions.
- Custom types can implement __get_pydantic_core_schema__; GenerateSchema supplies CallbackGetCoreSchemaHandler and normalizes returned definitions/references, while skipping BaseModel's compatibility implementation.
- Annotated handlers such as AfterValidator and PlainSerializer compose a generated inner schema with Python callbacks and, for serializers, an optional generated return schema.
- field_validator and field_serializer register PydanticDescriptorProxy metadata; class construction collects it, and _common_field_schema applies matching field handlers.
- JSON Schema customization uses __get_pydantic_json_schema__ metadata hooks or a GenerateJsonSchema subclass supplied to model_json_schema; schema tags map to named *_schema methods.
- Validation instrumentation plugins register in entry-point group pydantic and implement new_schema_validator, returning optional Python/JSON/string handlers; PYDANTIC_DISABLE_PLUGINS supports global disablement or named exclusions.
- create_model accepts bases, configuration, validators, namespace attributes, and field definitions, checks namespace clashes, and delegates class creation to the resolved metaclass.
- Native validators plug into BuildValidator implementations selected by EXPECTED_TYPE in build_validator_inner; unknown type tags error, and supported executable schema kinds are constrained by the Python/Rust contract.
- The Mypy plugin factory returns PydanticPlugin, whose hooks transform BaseModel subclasses, model metaclasses, from_orm calls, and create_model dynamic classes; configuration data participates in cache invalidation.