Skip to content

Commit

Permalink
⬆️ Upgrade dependencies (openwallet-foundation#3455)
Browse files Browse the repository at this point in the history
* ➖ Remove deprecated package

async-timeout has been pulled into asyncio since python 3.11

Signed-off-by: ff137 <[email protected]>

* ⬆️ Upgrade dependencies

Includes major upgrades without breaking changes

Signed-off-by: ff137 <[email protected]>

* 📌 Unpin dependency versions

Signed-off-by: ff137 <[email protected]>

* ⬆️ Upgrade pre-commit

Signed-off-by: ff137 <[email protected]>

* 🎨 Fix deprecation warning - module moved

Signed-off-by: ff137 <[email protected]>

* ⬆️ Upgrade marshmallow

Remove deprecated field (order is now preserved by default)

Handle new TypeError

Signed-off-by: ff137 <[email protected]>

* ⬆️ Update lock file

Signed-off-by: ff137 <[email protected]>

* 🎨 Resolve Marshmallow deprecation warning

Fixes: `ChangedInMarshmallow4Warning: Returning `False` from a validator is deprecated. Raise a `ValidationError` instead.`
Signed-off-by: ff137 <[email protected]>

* 🎨 Fix pytest-asyncio warning: unclosed event loop

Signed-off-by: ff137 <[email protected]>

* ⬆️ Upgrade aiohttp-apispec-acapy

Signed-off-by: ff137 <[email protected]>

* ⬆️ Upgrade pydevd-pycharm

Signed-off-by: ff137 <[email protected]>

---------

Signed-off-by: ff137 <[email protected]>
  • Loading branch information
ff137 authored Jan 23, 2025
1 parent 0a1e946 commit d93518f
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 188 deletions.
8 changes: 3 additions & 5 deletions acapy_agent/config/logging/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Optional

import yaml
from pythonjsonlogger import jsonlogger
from pythonjsonlogger.json import JsonFormatter

from ...config.settings import Settings
from ...version import __version__
Expand Down Expand Up @@ -221,9 +221,7 @@ def _configure_multitenant_logging(cls, log_config_path, log_level, log_file):
)
timed_file_handler.addFilter(log_filter)
# By default this will be set up.
timed_file_handler.setFormatter(
jsonlogger.JsonFormatter(LOG_FORMAT_FILE_ALIAS_PATTERN)
)
timed_file_handler.setFormatter(JsonFormatter(LOG_FORMAT_FILE_ALIAS_PATTERN))
logging.root.handlers.append(timed_file_handler)

else:
Expand All @@ -234,7 +232,7 @@ def _configure_multitenant_logging(cls, log_config_path, log_level, log_file):
# Set Json formatter for rotated file handler which cannot be set with
# config file.
# By default this will be set up.
handler.setFormatter(jsonlogger.JsonFormatter(log_formater))
handler.setFormatter(JsonFormatter(log_formater))
# Add context filter to handlers
handler.addFilter(log_filter)

Expand Down
4 changes: 4 additions & 0 deletions acapy_agent/messaging/jsonld/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ async def asyncSetUp(self):
headers={"x-api-key": "secret-key"},
)

async def asyncTearDown(self):
# Ensure the event loop is closed
await self.profile.close()

async def test_verify_credential(self):
POSTED_REQUEST = { # posted json
"verkey": (
Expand Down
3 changes: 1 addition & 2 deletions acapy_agent/messaging/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def serialize(
if as_string
else schema.dump(self)
)
except (AttributeError, ValidationError) as err:
except (AttributeError, ValidationError, TypeError) as err:
LOGGER.exception(f"{self.__class__.__name__} message serialization error:")
raise BaseModelError(
f"{self.__class__.__name__} schema validation failed"
Expand Down Expand Up @@ -321,7 +321,6 @@ class Meta:

model_class = None
skip_values = [None]
ordered = True

def __init__(self, *args, **kwargs):
"""Initialize BaseModelSchema.
Expand Down
12 changes: 3 additions & 9 deletions acapy_agent/messaging/models/paginated_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from aiohttp.web import BaseRequest
from marshmallow import fields
from marshmallow.validate import Range

from ...messaging.models.openapi import OpenAPISchema
from ...storage.base import DEFAULT_PAGE_SIZE, MAXIMUM_PAGE_SIZE
Expand All @@ -15,21 +16,14 @@ class PaginatedQuerySchema(OpenAPISchema):
limit = fields.Int(
required=False,
load_default=DEFAULT_PAGE_SIZE,
validate=lambda x: x > 0 and x <= MAXIMUM_PAGE_SIZE,
validate=Range(min=1, max=MAXIMUM_PAGE_SIZE),
metadata={"description": "Number of results to return", "example": 50},
error_messages={
"validator_failed": (
"Value must be greater than 0 and "
f"less than or equal to {MAXIMUM_PAGE_SIZE}"
)
},
)
offset = fields.Int(
required=False,
load_default=0,
validate=lambda x: x >= 0,
validate=Range(min=0),
metadata={"description": "Offset for pagination", "example": 0},
error_messages={"validator_failed": "Value must be 0 or greater"},
)


Expand Down
6 changes: 3 additions & 3 deletions acapy_agent/messaging/models/tests/test_paginated_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def test_paginated_query_schema_limit_validation():
with pytest.raises(ValidationError) as exc_info:
schema.load({"limit": 0})
assert (
f"Value must be greater than 0 and less than or equal to {MAXIMUM_PAGE_SIZE}"
f"Must be greater than or equal to 1 and less than or equal to {MAXIMUM_PAGE_SIZE}"
in str(exc_info.value)
)

# Invalid limit (greater than MAXIMUM_PAGE_SIZE)
with pytest.raises(ValidationError) as exc_info:
schema.load({"limit": MAXIMUM_PAGE_SIZE + 1})
assert (
f"Value must be greater than 0 and less than or equal to {MAXIMUM_PAGE_SIZE}"
f"Must be greater than or equal to 1 and less than or equal to {MAXIMUM_PAGE_SIZE}"
in str(exc_info.value)
)

Expand All @@ -64,4 +64,4 @@ def test_paginated_query_schema_offset_validation():
# Invalid offset (less than 0)
with pytest.raises(ValidationError) as exc_info:
schema.load({"offset": -1})
assert "Value must be 0 or greater" in str(exc_info.value)
assert "Must be greater than or equal to 0." in str(exc_info.value)
4 changes: 1 addition & 3 deletions acapy_agent/utils/repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import asyncio
from typing import Optional

import async_timeout


class RepeatAttempt:
"""Represents the current iteration in a repeat sequence."""
Expand Down Expand Up @@ -47,7 +45,7 @@ def next_interval(self) -> float:

def timeout(self, interval: Optional[float] = None):
"""Create a context manager for timing out an attempt."""
return async_timeout.timeout(self.next_interval if interval is None else interval)
return asyncio.timeout(self.next_interval if interval is None else interval)

def __repr__(self) -> str:
"""Format as a string for debugging."""
Expand Down
Loading

0 comments on commit d93518f

Please sign in to comment.