MCPcopy
hub / github.com/pydantic/pydantic / load_file

Function load_file

pydantic/v1/parse.py:47–66  ·  view source on GitHub ↗
(
    path: Union[str, Path],
    *,
    content_type: str = None,
    encoding: str = 'utf8',
    proto: Protocol = None,
    allow_pickle: bool = False,
    json_loads: Callable[[str], Any] = json.loads,
)

Source from the content-addressed store, hash-verified

45
46
47def load_file(
48 path: Union[str, Path],
49 *,
50 content_type: str = None,
51 encoding: str = 'utf8',
52 proto: Protocol = None,
53 allow_pickle: bool = False,
54 json_loads: Callable[[str], Any] = json.loads,
55) -> Any:
56 path = Path(path)
57 b = path.read_bytes()
58 if content_type is None:
59 if path.suffix in ('.js', '.json'):
60 proto = Protocol.json
61 elif path.suffix == '.pkl':
62 proto = Protocol.pickle
63
64 return load_str_bytes(
65 b, proto=proto, content_type=content_type, encoding=encoding, allow_pickle=allow_pickle, json_loads=json_loads
66 )

Callers 3

parse_file_asFunction · 0.90
parse_fileMethod · 0.90
test_deprecated_moduleFunction · 0.90

Calls 1

load_str_bytesFunction · 0.70

Tested by 1

test_deprecated_moduleFunction · 0.72