MCPcopy
hub / github.com/pydantic/pydantic / parse_file

Method parse_file

pydantic/main.py:1451–1475  ·  view source on GitHub ↗
(  # noqa: D102
        cls,
        path: str | Path,
        *,
        content_type: str | None = None,
        encoding: str = 'utf8',
        proto: DeprecatedParseProtocol | None = None,
        allow_pickle: bool = False,
    )

Source from the content-addressed store, hash-verified

1449 category=None,
1450 )
1451 def parse_file( # noqa: D102
1452 cls,
1453 path: str | Path,
1454 *,
1455 content_type: str | None = None,
1456 encoding: str = 'utf8',
1457 proto: DeprecatedParseProtocol | None = None,
1458 allow_pickle: bool = False,
1459 ) -> Self:
1460 warnings.warn(
1461 'The `parse_file` method is deprecated; load the data from file, then if your data is JSON '
1462 'use `model_validate_json`, otherwise `model_validate` instead.',
1463 category=PydanticDeprecatedSince20,
1464 stacklevel=2,
1465 )
1466 from .deprecated import parse
1467
1468 obj = parse.load_file(
1469 path,
1470 proto=proto,
1471 content_type=content_type,
1472 encoding=encoding,
1473 allow_pickle=allow_pickle,
1474 )
1475 return cls.parse_obj(obj)
1476
1477 @classmethod
1478 @typing_extensions.deprecated(

Callers 1

test_parse_fileFunction · 0.45

Calls 1

parse_objMethod · 0.45

Tested by 1

test_parse_fileFunction · 0.36