From 6485df675d219f406404c1a9bddf559039873c04 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Mon, 6 Jan 2025 19:59:43 -0500 Subject: [PATCH 1/2] Fix marshmallow 3.24.0 compat --- CHANGELOG.rst | 7 +++++++ src/marshmallow_sqlalchemy/convert.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 71e6973..82e7092 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ Changelog --------- +1.1.1 (unreleased) +++++++++++++++++++ + +Bug fixes: + +* Fix compatibility with marshmallow 3.24.0. + 1.1.0 (2024-08-14) ++++++++++++++++++ diff --git a/src/marshmallow_sqlalchemy/convert.py b/src/marshmallow_sqlalchemy/convert.py index 81458da..594d1c8 100644 --- a/src/marshmallow_sqlalchemy/convert.py +++ b/src/marshmallow_sqlalchemy/convert.py @@ -43,7 +43,7 @@ def _postgres_array_factory(converter, data_type): def _enum_field_factory(converter, data_type): - return fields.Enum if data_type.enum_class else fields.Field + return fields.Enum if data_type.enum_class else fields.Raw def _field_update_kwargs(field_class, field_kwargs, kwargs): @@ -57,7 +57,7 @@ def _field_update_kwargs(field_class, field_kwargs, kwargs): possible_field_keywords = { key for cls in inspect.getmro(field_class) - for key, param in inspect.signature(cls).parameters.items() + for key, param in inspect.signature(cls.__init__).parameters.items() if param.kind is inspect.Parameter.POSITIONAL_OR_KEYWORD or param.kind is inspect.Parameter.KEYWORD_ONLY } From 166fe756d8af76d5c18d6730e127a4aad42751f0 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Mon, 6 Jan 2025 20:04:48 -0500 Subject: [PATCH 2/2] Fix marshmallow 4.0.0 compat --- CHANGELOG.rst | 2 +- src/marshmallow_sqlalchemy/convert.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 82e7092..8fb48bc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,7 +6,7 @@ Changelog Bug fixes: -* Fix compatibility with marshmallow 3.24.0. +* Fix compatibility with marshmallow 3.24.0 and 4.0.0. 1.1.0 (2024-08-14) ++++++++++++++++++ diff --git a/src/marshmallow_sqlalchemy/convert.py b/src/marshmallow_sqlalchemy/convert.py index 594d1c8..6cfac83 100644 --- a/src/marshmallow_sqlalchemy/convert.py +++ b/src/marshmallow_sqlalchemy/convert.py @@ -305,7 +305,7 @@ def _add_column_kwargs(self, kwargs, column): if hasattr(column.type, "enums") and not kwargs.get("dump_only"): kwargs["validate"].append(validate.OneOf(choices=column.type.enums)) - if hasattr(column.type, "enum_class"): + if hasattr(column.type, "enum_class") and column.type.enum_class is not None: kwargs["enum"] = column.type.enum_class # Add a length validator if a max length is set on the column