# pydantic.errors.PydanticUserError: 检测到未注解的属性：`children = []`。所有模型字段都需要类型注解；若 `children` 不是字段，可将其注解为 `ClassVar` 或更新 `model_config['ignored_types']`。

- **ID:** `python/pydantic-recursion-loop-model`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Pydantic v2 中，没有类型注解的类级赋值会被当作字段，即使原意为常量或辅助变量。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Annotate as ClassVar: `from typing import ClassVar
children: ClassVar[list] = []`
   ```
2. **** (92% 成功率)
   ```
   Add a type annotation: `children: list[Node] = []` if it really is a field (use `Field(default_factory=list)`).
   ```

## 无效尝试

- **** — Setting the attribute inside `__init__` instead of at class level changes semantics and breaks serialization. (60% 失败率)
- **** — Adding `ClassVar` but keeping the mutable default still shares state across instances. (40% 失败率)
