From e1b6be76739e1fab23f4dc5a4d8d0fcd6c0d42a1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 5 Jan 2024 02:55:23 +0100 Subject: [PATCH] Marshmallow has replaced `field.default` with `field.dump_default`. --- platypush/common/reflection/_parser/rst.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/platypush/common/reflection/_parser/rst.py b/platypush/common/reflection/_parser/rst.py index 844028c5b..e185b6544 100644 --- a/platypush/common/reflection/_parser/rst.py +++ b/platypush/common/reflection/_parser/rst.py @@ -59,6 +59,10 @@ class RstExtensionsMixin: return cls._expand_module(docstr, ex_name, match, obj) + @staticmethod + def _field_default(field): + return getattr(field, "dump_default", getattr(field, "default", None)) + @classmethod def _expand_schema(cls, docstr: str, match: re.Match) -> str: from marshmallow import missing @@ -98,19 +102,25 @@ class RstExtensionsMixin: + ( ( '"' - + field.metadata.get("example", field.default) + + field.metadata.get( + "example", cls._field_default(field) + ) + '"' if isinstance( - field.metadata.get("example", field.default), + field.metadata.get( + "example", cls._field_default(field) + ), str, ) else str( - field.metadata.get("example", field.default) + field.metadata.get( + "example", cls._field_default(field) + ) ) ) if not ( field.metadata.get("example") is None - and field.default is missing + and cls._field_default(field) is missing ) else "..." )