Commit 3bf5d4b
fix(pydantic): unconditional TypeAdapter import — eliminate NameError window
_get_adapter and the TypeError fallback inside PydanticDecoder.decode both
referenced TypeAdapter as a bare name. The name was bound only under
`if import_checker.is_pydantic_installed:`. If a test reloaded the module
with the flag patched to False, TypeAdapter was undefined and subsequent
calls raised NameError instead of the documented ImportError.
Hoist `from pydantic import TypeAdapter` unconditionally. The module is
gated upstream by client.py:_default_pydantic_decoder(), which raises
ImportError before this module is loaded when pydantic is absent — there
is no real-world path that loads pydantic.py without pydantic available.
Update the module docstring to reflect the new contract.
Closes audit Low finding (pydantic.py:15-16, 27, 43) from
planning/audit/2026-06-07-deep-audit.md.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e879eb8 commit 3bf5d4b
1 file changed
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | | - | |
13 | | - | |
| 15 | + | |
14 | 16 | | |
15 | | - | |
16 | | - | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
0 commit comments