MCPcopy Create free account
hub / github.com/apache/fory / infer_schema

Function infer_schema

python/pyfory/format/infer.py:143–159  ·  view source on GitHub ↗
(clz, types_path=None)

Source from the content-addressed store, hash-verified

141
142
143def 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
162class ForyTypeVisitor(TypeVisitor):

Callers 3

test_infer_class_schemaFunction · 0.90
visit_customizedMethod · 0.85

Calls 6

get_type_hintsFunction · 0.90
infer_fieldFunction · 0.90
ForyTypeVisitorClass · 0.85
schemaFunction · 0.85
listFunction · 0.50
keysMethod · 0.45

Tested by 2

test_infer_class_schemaFunction · 0.72