# pydantic.errors.PydanticSchemaGenerationError: 无法为 <class 'decimal.Decimal'> 生成 pydantic-core schema。请在 model_config 中设置 `arbitrary_types_allowed=True` 以忽略此错误，或实现 `__get_pydantic_core_schema__`。

- **ID:** `python/pydantic-arbitrary-types-not-allowed`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

字段使用了 Pydantic 无法内省的类型（自定义类或缺少 schema 钩子的第三方类型），且未启用 `arbitrary_types_allowed`。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 2.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Enable it: `model_config = ConfigDict(arbitrary_types_allowed=True)` and add a `field_validator` for the type.
   ```
2. **** (85% 成功率)
   ```
   Implement `__get_pydantic_core_schema__` on the custom class to provide a proper schema.
   ```

## 无效尝试

- **** — Adding `arbitrary_types_allowed=True` without `isinstance` checks means the field is never validated, leading to silent bad data. (50% 失败率)
- **** — Subclassing the third-party type does not help; Pydantic still cannot introspect it. (85% 失败率)
