Commit daedb0c
Fix PEP 563 string annotations in JSON schema generation
When a module uses `from __future__ import annotations` (PEP 563),
all type annotations are stored as strings at runtime. This causes
pydantic to fail when creating models from method signatures, as it
cannot resolve types like `DirectoryPath` from their string form.
Use `typing.get_type_hints()` to resolve string annotations back to
their actual types before passing them to pydantic. When a class is
passed (rather than a method), target `__init__` for hint resolution
since `inspect.signature` also uses `__init__` in that case.
Fixes MiniscopeConverter schema generation failure.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 36a91c4 commit daedb0c
1 file changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
162 | 172 | | |
163 | 173 | | |
164 | 174 | | |
| |||
181 | 191 | | |
182 | 192 | | |
183 | 193 | | |
184 | | - | |
| 194 | + | |
| 195 | + | |
185 | 196 | | |
186 | 197 | | |
187 | 198 | | |
| |||
0 commit comments