(clz, types_path=None)
| 141 | |
| 142 | |
| 143 | def infer_schema(clz, types_path=None) -> Schema: |
| 144 | types_path = list(types_path or []) |
| 145 | from pyfory.type_util import get_type_hints |
| 146 | |
| 147 | type_hints = get_type_hints(clz) |
| 148 | keys = sorted(type_hints.keys()) |
| 149 | fields = [ |
| 150 | infer_field( |
| 151 | field_name, |
| 152 | type_hints[field_name], |
| 153 | ForyTypeVisitor(), |
| 154 | types_path=types_path, |
| 155 | ) |
| 156 | for field_name in keys |
| 157 | ] |
| 158 | # TODO: Add metadata support to Fory Schema |
| 159 | return schema(fields) |
| 160 | |
| 161 | |
| 162 | class ForyTypeVisitor(TypeVisitor): |