MCPcopy
hub / github.com/marshmallow-code/marshmallow / _do_load

Method _do_load

src/marshmallow/schema.py:843–945  ·  view source on GitHub ↗

Deserialize `data`, returning the deserialized result. This method is private API. :param data: The data to deserialize. :param many: Whether to deserialize `data` as a collection. If `None`, the value for `self.many` is used. :param partial: Whether to v

(
        self,
        data: (Mapping[str, typing.Any] | Sequence[Mapping[str, typing.Any]]),
        *,
        many: bool | None = None,
        partial: bool | types.StrSequenceOrSet | None = None,
        unknown: types.UnknownOption | None = None,
        postprocess: bool = True,
    )

Source from the content-addressed store, hash-verified

841 ##### Private Helpers #####
842
843 def _do_load(
844 self,
845 data: (Mapping[str, typing.Any] | Sequence[Mapping[str, typing.Any]]),
846 *,
847 many: bool | None = None,
848 partial: bool | types.StrSequenceOrSet | None = None,
849 unknown: types.UnknownOption | None = None,
850 postprocess: bool = True,
851 ):
852 """Deserialize `data`, returning the deserialized result.
853 This method is private API.
854
855 :param data: The data to deserialize.
856 :param many: Whether to deserialize `data` as a collection. If `None`, the
857 value for `self.many` is used.
858 :param partial: Whether to validate required fields. If its
859 value is an iterable, only fields listed in that iterable will be
860 ignored will be allowed missing. If `True`, all fields will be allowed missing.
861 If `None`, the value for `self.partial` is used.
862 :param unknown: Whether to exclude, include, or raise an error for unknown
863 fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
864 If `None`, the value for `self.unknown` is used.
865 :param postprocess: Whether to run post_load methods..
866 :return: Deserialized data
867 """
868 error_store = ErrorStore()
869 errors: dict[str, list[str]] = {}
870 many = self.many if many is None else bool(many)
871 unknown = self.unknown if unknown is None else unknown
872 if partial is None:
873 partial = self.partial
874 # Run preprocessors
875 if self._hooks[PRE_LOAD]:
876 try:
877 processed_data = self._invoke_load_processors(
878 PRE_LOAD,
879 data,
880 many=many,
881 original_data=data,
882 partial=partial,
883 unknown=unknown,
884 )
885 except ValidationError as err:
886 errors = err.normalized_messages()
887 result: list | dict | None = None
888 else:
889 processed_data = data
890 if not errors:
891 # Deserialize data
892 result = self._deserialize(
893 processed_data,
894 error_store=error_store,
895 many=many,
896 partial=partial,
897 unknown=unknown,
898 )
899 # Run field-level validation
900 self._invoke_field_validators(

Callers 2

loadMethod · 0.95
validateMethod · 0.95

Calls 8

_deserializeMethod · 0.95
handle_errorMethod · 0.95
ErrorStoreClass · 0.90
ValidationErrorClass · 0.90
normalized_messagesMethod · 0.80

Tested by

no test coverage detected