From 2de97bc97891f88a56653fd583fe3635830afa2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Thu, 8 Sep 2022 18:54:00 +0200 Subject: [PATCH] Fix Field._serialize typing --- src/marshmallow/fields.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/marshmallow/fields.py b/src/marshmallow/fields.py index 5611b24a4..52d13dcf7 100644 --- a/src/marshmallow/fields.py +++ b/src/marshmallow/fields.py @@ -387,7 +387,9 @@ def _bind_to_schema(self, field_name, schema): self.parent.root if isinstance(self.parent, FieldABC) else self.parent ) - def _serialize(self, value: typing.Any, attr: str, obj: typing.Any, **kwargs): + def _serialize( + self, value: typing.Any, attr: str | None, obj: typing.Any, **kwargs + ): """Serializes ``value`` to a basic Python datatype. Noop by default. Concrete :class:`Field` classes should implement this method.