Skip to content

Commit

Permalink
Add Python 3.11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
seedofjoy committed Nov 30, 2022
1 parent 40ebfef commit b4dd9fe
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Expand Up @@ -8,10 +8,10 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Expand Up @@ -9,6 +9,10 @@ jobs:
strategy:
matrix:
python-version: [3.7.7, 3.8, 3.9, 3.10.2]
aioredis-dep: ["aioredis==1.3.1", "evo-aioredis==1.3.4"]
include:
- python-version: 3.11
aioredis-dep: "evo-aioredis==1.3.4"

env:
PYTHON: ${{ matrix.python-version }}
Expand All @@ -33,6 +37,7 @@ jobs:
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -e .[watch]
pip install ${{ matrix.aioredis-dep }}
- name: Lint with mypy
run: mypy darq/
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,7 @@ Changelog
0.11.1 (unreleased)
...................
* Remove ``pydantic`` dependency
* Remove ``aioredis`` from dependencies to allow choose between ``aioredis`` and ``evo-aioredis`` - fork with Python 3.11 compatability

0.11.0 (2022-08-03)
...................
Expand Down
19 changes: 19 additions & 0 deletions README.rst
Expand Up @@ -21,6 +21,25 @@ Features
* Graceful shutdown: waits until running tasks are finished


Installation
------------
Darq uses ``aioredis`` 1.x as Redis client. Unfortunately, this library has been abandoned, and does not support Python 3.11. I made a fork with compatability fixes: ``evo-aioredis`` (https://github.com/evo-company/aioredis-py).

Because of this, ``aioredis`` is not currently added as Darq dependency, and you must install it yourself:

For Python<3.11 you can use:

.. code:: shell
pip install aioredis<2.0.0
For Python 3.11 (and older versions too) you can use fork:

.. code:: shell
pip install evo-aioredis<2.0.0
Quick start
-----------

Expand Down
10 changes: 10 additions & 0 deletions darq/__init__.py
Expand Up @@ -5,4 +5,14 @@
from .version import __version__
from .worker import Retry

try:
from aioredis import __version__ as aioredis_version
except ImportError:
raise ImportError(
'Please, install "aioredis" (or "evo-aioredis" - for Python 3.11+)')

AIOREDIS_MAJOR_VERSION = int(aioredis_version.split('.')[0])
if AIOREDIS_MAJOR_VERSION > 1:
raise ImportError('Darq only supports "aioredis" versions <2.0')

__all__ = ['Darq', 'JobCtx', 'RedisSettings', 'cron', 'Retry', '__version__']
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -38,14 +38,14 @@ def readfile(filename: str) -> str:
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Typing :: Typed',
],
entry_points={
'console_scripts': ['darq = darq.cli:cli'],
},
install_requires=[
'async-timeout>=3.0.0, <5.0',
'aioredis>=1.1.0, <2.0',
'click>=6.7',
'typing_extensions>=4.0; python_version<"3.8"',
],
Expand Down
1 change: 0 additions & 1 deletion tests/requirements.txt
Expand Up @@ -2,7 +2,6 @@ pytest==7.2.0
pytest-aiohttp==1.0.4
pytest-mock==3.10.0
pytest-cov==4.0.0
asynctest==0.13.0
mypy==0.982
flake8==5.0.4
flake8-quotes==3.3.1
Expand Down
17 changes: 12 additions & 5 deletions tests/test_app.py
@@ -1,11 +1,12 @@
import asyncio
import datetime
import logging
import re
from unittest.mock import call
from unittest.mock import Mock
from unittest.mock import patch

import pytest
from asynctest import CoroutineMock
from asynctest import patch

from darq import Darq
from darq.app import DarqConnectionError
Expand Down Expand Up @@ -174,9 +175,15 @@ async def prepublish_side_effect(
'job_try': None,
}

on_job_prerun = CoroutineMock()
on_job_postrun = CoroutineMock()
on_job_prepublish = CoroutineMock(side_effect=prepublish_side_effect)
on_job_prerun_future = asyncio.Future()
on_job_prerun_future.set_result(None)
on_job_prerun = Mock(return_value=on_job_prerun_future)

on_job_postrun_future = asyncio.Future()
on_job_postrun_future.set_result(None)
on_job_postrun = Mock(return_value=on_job_postrun_future)

on_job_prepublish = Mock(side_effect=prepublish_side_effect)

darq = Darq(
redis_settings=redis_settings,
Expand Down

0 comments on commit b4dd9fe

Please sign in to comment.