From 7ac37c3ac6eddbd2b51e7e3a9b2512889eeddb53 Mon Sep 17 00:00:00 2001 From: Peter Schutt Date: Tue, 15 Nov 2022 07:49:19 +1000 Subject: [PATCH] fix(saq): Upgrade to typed release. Upgraded to 0.9.1 which includes types. Removes type:ignore comments. Closes #91 --- poetry.lock | 23 ++++++++++++----------- pyproject.toml | 4 ++-- src/starlite_saqlalchemy/init_plugin.py | 2 +- src/starlite_saqlalchemy/log/worker.py | 2 +- src/starlite_saqlalchemy/worker.py | 12 ++++++------ tests/unit/conftest.py | 2 +- tests/unit/test_log.py | 2 +- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/poetry.lock b/poetry.lock index 1f74d538..96f67bdc 100644 --- a/poetry.lock +++ b/poetry.lock @@ -118,7 +118,7 @@ idna = ">=2.0.0" [[package]] name = "Faker" -version = "15.3.1" +version = "15.3.2" description = "Faker is a Python package that generates fake data for you." category = "main" optional = false @@ -342,7 +342,7 @@ idna2008 = ["idna"] [[package]] name = "saq" -version = "0.9.0" +version = "0.9.1" description = "Distributed Python job queue with asyncio and redis" category = "main" optional = false @@ -353,13 +353,13 @@ croniter = ">=0.3.18" redis = ">=4.2.0" [package.extras] -dev = ["black (==22.3.0)", "pylint"] +dev = ["black", "mypy", "pylint", "types-croniter", "types-redis", "types-setuptools"] hiredis = ["redis[hiredis] (>=4.2.0)"] web = ["aiohttp", "aiohttp-basicauth"] [[package]] name = "sentry-sdk" -version = "1.10.1" +version = "1.11.0" description = "Python client for Sentry (https://sentry.io)" category = "main" optional = false @@ -381,6 +381,7 @@ fastapi = ["fastapi (>=0.79.0)"] flask = ["blinker (>=1.1)", "flask (>=0.11)"] httpx = ["httpx (>=0.16.0)"] pure_eval = ["asttokens", "executing", "pure-eval"] +pymongo = ["pymongo (>=3.1)"] pyspark = ["pyspark (>=2.4.4)"] quart = ["blinker (>=1.1)", "quart (>=0.16.1)"] rq = ["rq (>=0.6)"] @@ -553,7 +554,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "bf8fe18cb7d47b0af7a0a099544dee84eeb84d0b7c8bc70ab47a35b8956f7eea" +content-hash = "07691a7f0125850062204a9f53d6e6f164adb324557c51ea344ae5103029a03f" [metadata.files] anyio = [ @@ -631,8 +632,8 @@ email-validator = [ {file = "email_validator-1.3.0.tar.gz", hash = "sha256:553a66f8be2ec2dea641ae1d3f29017ab89e9d603d4a25cdaac39eefa283d769"}, ] Faker = [ - {file = "Faker-15.3.1-py3-none-any.whl", hash = "sha256:4a3465624515a6807e8aa7e8eeb85bdd86a2fa53de4e258892dd6be95362462e"}, - {file = "Faker-15.3.1.tar.gz", hash = "sha256:b9dd2fd9a9ac68a4e0c5040cd9e9bfaa099fa8dd15bae5f01f224a45431818d5"}, + {file = "Faker-15.3.2-py3-none-any.whl", hash = "sha256:43da04aae745018e8bded768e74c84423d9dc38e4c498a53439e749d90e20bc0"}, + {file = "Faker-15.3.2.tar.gz", hash = "sha256:0094fe3340ad73c490d3ffccc59cc171b161acfccccd52925c70970ba23e6d6b"}, ] greenlet = [ {file = "greenlet-2.0.1-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:9ed358312e63bf683b9ef22c8e442ef6c5c02973f0c2a939ec1d7b50c974015c"}, @@ -980,12 +981,12 @@ rfc3986 = [ {file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"}, ] saq = [ - {file = "saq-0.9.0-py3-none-any.whl", hash = "sha256:0056ad4d42f639eb5c2d575326ae8ce7ffdec05b8ceeafb83de6e73ccff6fec5"}, - {file = "saq-0.9.0.tar.gz", hash = "sha256:73c316c3e7b90e6e4546dec3c4d15926d85b70a71b2fd23df78723ae6a2803e8"}, + {file = "saq-0.9.1-py3-none-any.whl", hash = "sha256:f8f2bff790de6b128a767f5a23cbaa36014c164128beae2910e6e3d5d1c3689c"}, + {file = "saq-0.9.1.tar.gz", hash = "sha256:071348f2132d997f7bbbcfe0628554936a7080b4ae284c0220f9e2e3c945d84b"}, ] sentry-sdk = [ - {file = "sentry-sdk-1.10.1.tar.gz", hash = "sha256:105faf7bd7b7fa25653404619ee261527266b14103fe1389e0ce077bd23a9691"}, - {file = "sentry_sdk-1.10.1-py2.py3-none-any.whl", hash = "sha256:06c0fa9ccfdc80d7e3b5d2021978d6eb9351fa49db9b5847cf4d1f2a473414ad"}, + {file = "sentry-sdk-1.11.0.tar.gz", hash = "sha256:e7b78a1ddf97a5f715a50ab8c3f7a93f78b114c67307785ee828ef67a5d6f117"}, + {file = "sentry_sdk-1.11.0-py2.py3-none-any.whl", hash = "sha256:f467e6c7fac23d4d42bc83eb049c400f756cd2d65ab44f0cc1165d0c7c3d40bc"}, ] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, diff --git a/pyproject.toml b/pyproject.toml index dc8947ad..9ad3a4b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,10 +60,10 @@ orjson = "*" pydantic = "*" python-dotenv = "*" redis = "*" -saq = "*" +saq = "^0.9.1" sentry-sdk = "*" sqlalchemy = "==2.0.0b3" -starlite = "~=1.39" +starlite = "^1.39" structlog = "*" uvicorn = "*" uvloop = "*" diff --git a/src/starlite_saqlalchemy/init_plugin.py b/src/starlite_saqlalchemy/init_plugin.py index beb1a3e8..bc62f58b 100644 --- a/src/starlite_saqlalchemy/init_plugin.py +++ b/src/starlite_saqlalchemy/init_plugin.py @@ -59,7 +59,7 @@ def example_handler() -> dict: from collections.abc import Callable, Sequence from typing import Any - from saq.worker import Worker # type:ignore[import] + from saq.worker import Worker from starlite.config.app import AppConfig from structlog.types import Processor diff --git a/src/starlite_saqlalchemy/log/worker.py b/src/starlite_saqlalchemy/log/worker.py index b297e246..54db051b 100644 --- a/src/starlite_saqlalchemy/log/worker.py +++ b/src/starlite_saqlalchemy/log/worker.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from typing import Any, TypeAlias - from saq import Job # type:ignore[import] + from saq import Job LOGGER = structlog.get_logger() diff --git a/src/starlite_saqlalchemy/worker.py b/src/starlite_saqlalchemy/worker.py index 5a7eb4fd..9eea38c3 100644 --- a/src/starlite_saqlalchemy/worker.py +++ b/src/starlite_saqlalchemy/worker.py @@ -6,12 +6,12 @@ from typing import TYPE_CHECKING, Any import orjson -import saq # type:ignore[import] +import saq from starlite_saqlalchemy import redis if TYPE_CHECKING: - from collections.abc import Callable, Collection + from collections.abc import Awaitable, Callable, Collection from signal import Signals __all__ = [ @@ -22,7 +22,7 @@ ] -class Queue(saq.Queue): # type:ignore[misc] +class Queue(saq.Queue): """[SAQ Queue](https://github.com/tobymao/saq/blob/master/saq/queue.py). Configures `orjson` for JSON serialization/deserialization if not otherwise configured. @@ -38,7 +38,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Worker(saq.Worker): # type:ignore[misc] +class Worker(saq.Worker): """Modify behavior of saq worker for orchestration by Starlite.""" # same issue: https://github.com/samuelcolvin/arq/issues/182 @@ -59,8 +59,8 @@ async def on_app_startup(self) -> None: # pragma: no cover def create_worker_instance( functions: Collection[Callable[..., Any] | tuple[str, Callable]], - before_process: Callable[[dict[str, Any]], None] | None = None, - after_process: Callable[[dict[str, Any]], None] | None = None, + before_process: Callable[[dict[str, Any]], Awaitable[Any]] | None = None, + after_process: Callable[[dict[str, Any]], Awaitable[Any]] | None = None, ) -> Worker: """ diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index f50f080b..caea657c 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -5,7 +5,7 @@ from unittest.mock import MagicMock import pytest -from saq.job import Job # type:ignore[import] +from saq.job import Job from starlite.datastructures import State from starlite.enums import ScopeType from starlite.testing import TestClient diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py index 48324af6..0b41fb77 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_log.py @@ -19,7 +19,7 @@ from typing import Any from pytest import MonkeyPatch - from saq.job import Job # type:ignore[import] + from saq.job import Job from starlite import Starlite, State from starlite.types.asgi_types import ( HTTPResponseBodyEvent,