Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix marshmallow 3.24 and 4.0 compat #628

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
---------

1.1.1 (unreleased)
++++++++++++++++++

Bug fixes:

* Fix compatibility with marshmallow 3.24.0 and 4.0.0.

1.1.0 (2024-08-14)
++++++++++++++++++

Expand Down
6 changes: 3 additions & 3 deletions src/marshmallow_sqlalchemy/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
Loading