class AttributesSchema(helpers.BaseSchema): _regex = helpers.RegexField( unknown=marshmallow.EXCLUDE, pattern=re.compile(""), type=helpers.LazyNestedField( nested=helpers.absmod(__name__, "...None"), unknown=marshmallow.EXCLUDE, allow_none=True, many=True, ), ) class Meta: unknown = marshmallow.EXCLUDE @marshmallow.post_load def post_load(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).postprocess(data) return models.Attributes(**data) @marshmallow.pre_load def pre_load(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).preprocess(data) return data @marshmallow.pre_dump def pre_dump(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).preprocess(data) return data @marshmallow.post_dump def post_dump(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).postprocess(data) return data
class GraphQLVariablesMapSchema(marshmallow.Schema): """Marshmallow schema for :class:`commercetools.types.GraphQLVariablesMap`.""" _regex = helpers.RegexField( unknown=marshmallow.EXCLUDE, pattern=re.compile(""), type=marshmallow.fields.Raw(allow_none=True), ) class Meta: unknown = marshmallow.EXCLUDE @marshmallow.post_load def post_load(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).postprocess(data) return types.GraphQLVariablesMap(**data) @marshmallow.pre_load def pre_load(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).preprocess(data) return data @marshmallow.pre_dump def pre_dump(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).preprocess(data) return data @marshmallow.post_dump def post_dump(self, data, **kwargs): data = typing.cast(helpers.RegexField, self.fields["_regex"]).postprocess(data) return data