Commit 444de5d
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. Only apply this
resolution when the annotation is a string, preserving pydantic-specific
types like `DirectoryPath` and `FilePath` for non-PEP-563 modules.
When a class is passed (rather than a method), target `__init__` for
hint resolution since `inspect.signature` also uses `__init__`.
Fixes MiniscopeConverter schema generation failure.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 36a91c4 commit 444de5d
1 file changed
+15
-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 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
185 | 199 | | |
186 | 200 | | |
187 | 201 | | |
| |||
0 commit comments