Skip to content

Commit

Permalink
Bumped marshmallow 3.23.3 => 3.24.0
Browse files Browse the repository at this point in the history
We need to track the signature changes of Fields.Nested,
see marshmallow-code/marshmallow#2723.

CMK-21417

Change-Id: Idf723bc5360a46a9a1f68e78776dab895e5be247
  • Loading branch information
lpetrora authored and spt29 committed Feb 12, 2025
1 parent 7a9939d commit 7582fd7
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 105 deletions.
42 changes: 21 additions & 21 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion cmk/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,18 @@ class Nested(OpenAPIAttributes, fields.Nested, UniqueFields):
# In this situation, it should be sufficient to replace the `missing` parameter with
# a `lambda` which returns the same object, as callables are ignored by apispec.

def _deserialize(self, value, attr, data, partial=None, **kwargs):
context: dict[object, object] = {}

def __init__(
self,
*args,
**kwargs,
):
context = kwargs.pop("context", {})
super().__init__(*args, **kwargs)
self.context = context

def _deserialize(self, value, attr, data=None, partial=None, **kwargs):
self._validate_missing(value)
if value is fields.missing_: # type: ignore[attr-defined, unused-ignore]
_miss = self.missing
Expand Down
4 changes: 3 additions & 1 deletion cmk/gui/fields/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from cmk.fields import Boolean, Constant, Integer, List, Nested, String, Time
from cmk.fields.validators import IsValidRegexp, ValidateIPv4, ValidateIPv4Network

from .definitions import CmkOneOfSchema

# TODO: make wrong 'tuple_fields' entries fail at compile not, not at runtime.


Expand Down Expand Up @@ -808,7 +810,7 @@ class SNMPv3AuthPrivacy(BaseSchema, CheckmkTuple):
)


class SNMPCredentials(OneOfSchema):
class SNMPCredentials(CmkOneOfSchema):
"""Validate and convert from/to Checkmk internal format for SNMP credentials.
Here are the various possible values in the attribute
Expand Down
11 changes: 11 additions & 0 deletions cmk/gui/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ class Meta:
def dict_class(self) -> type:
return dict

context: dict[typing.Any, typing.Any] = {}

def __init__(
self,
*args,
**kwargs,
):
context = kwargs.pop("context", {})
super().__init__(*args, **kwargs)
self.context = context

@post_load(pass_many=True)
@post_dump(pass_many=True)
def remove_ordered_dict(self, data, **kwargs):
Expand Down
28 changes: 25 additions & 3 deletions cmk/gui/fields/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,20 @@ class LogicalExprSchema(BaseSchema):
)


class ExprSchema(OneOfSchema):
class CmkOneOfSchema(OneOfSchema):
context: dict[object, object] = {}

def __init__(
self,
*args,
**kwargs,
):
context = kwargs.pop("context", {})
super().__init__(*args, **kwargs)
self.context = context


class ExprSchema(CmkOneOfSchema):
"""Top level class for query expression schema
Operators can be one of: AND, OR
Expand Down Expand Up @@ -364,8 +377,17 @@ def load(self, data, *, many=None, partial=None, unknown=None, **kwargs):


class _ExprNested(base.Nested):
def _load(self, value, data, partial=None):
_data = super()._load(value, data, partial=partial)
def __init__(
self,
*args,
**kwargs,
):
context = kwargs.pop("context", {})
super().__init__(*args, **kwargs)
self.context = context

def _load(self, value, partial=None):
_data = super()._load(value, partial=partial)
return tree_to_expr(_data, table=self.metadata["table"])


Expand Down
2 changes: 1 addition & 1 deletion cmk/gui/openapi/endpoints/rule/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def __init__(
only: types.StrSequenceOrSet | None = None,
exclude: types.StrSequenceOrSet = (),
many: bool = False,
context: dict | None = None,
context: dict[object, object] = {},
load_only: types.StrSequenceOrSet = (),
dump_only: types.StrSequenceOrSet = (),
partial: bool | types.StrSequenceOrSet = False,
Expand Down
2 changes: 1 addition & 1 deletion cmk/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pymssql==2.3.1 # needed by check_sql active check
pymysql~=1.1.1 # needed by check_sql active check
psycopg2-binary==2.9.6 # needed by check_sql active check
apispec
marshmallow==3.23.3 # temporary pin
marshmallow==3.24.0 # temporary pin
marshmallow-oneofschema
apispec-oneofschema
pydantic~=2.7
Expand Down
Loading

0 comments on commit 7582fd7

Please sign in to comment.