()
| 45 | def test_forward_ref_auto_update_no_model(create_module): |
| 46 | @create_module |
| 47 | def module(): |
| 48 | from typing import Optional |
| 49 | |
| 50 | import pytest |
| 51 | |
| 52 | from pydantic import BaseModel, PydanticUserError |
| 53 | |
| 54 | class Foo(BaseModel): |
| 55 | a: Optional['Bar'] = None |
| 56 | |
| 57 | with pytest.raises(PydanticUserError, match='`Foo` is not fully defined; you should define `Bar`,'): |
| 58 | Foo(a={'b': {'a': {}}}) |
| 59 | |
| 60 | class Bar(BaseModel): |
| 61 | b: 'Foo' |
| 62 | |
| 63 | assert module.Bar.__pydantic_complete__ is True |
| 64 | assert module.Bar.model_fields['b']._complete |
nothing calls this directly
no test coverage detected