From d14fa66d3c986228ec3c9250cbec71fe86b19fa0 Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Fri, 5 Jul 2024 21:44:58 +0300 Subject: [PATCH] Add support for Python 3.13 Fixes https://github.com/celery/kombu/issues/2051. --- .github/workflows/ci.yaml | 16 ++++++++++++++-- kombu/transport/redis.py | 2 +- requirements/extras/confluentkafka.txt | 2 +- requirements/extras/zstd.txt | 2 +- t/unit/transport/test_redis.py | 15 ++++++++++----- tox.ini | 18 ++++++++++-------- 6 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8692461a1..041e857f5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Install system packages run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev @@ -17,6 +17,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: Allow pre-releases in tox on Python 3.13 + run: echo "PIP_PRE=1" >> $GITHUB_ENV + if: ${{ matrix.python-version == '3.13' }} - name: Install dependencies run: pip install --upgrade pip wheel tox tox-docker - name: Run unittest @@ -29,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8,3.9,"3.10","3.11","3.12"] + python-version: [3.8,3.9,"3.10","3.11","3.12","3.13"] experimental: [false] include: - python-version: pypy3.9 @@ -44,6 +48,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: Allow pre-releases in tox on Python 3.13 + run: echo "PIP_PRE=1" >> $GITHUB_ENV + if: ${{ matrix.python-version == '3.13' }} - name: Install dependencies run: pip install --upgrade pip wheel tox tox-docker # Tox fails if a Python versions contains a hyphen, this changes "pypy-3.9" to "pypy3.9". @@ -74,6 +82,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: Allow pre-releases in tox on Python 3.13 + run: echo "PIP_PRE=1" >> $GITHUB_ENV + if: ${{ matrix.python-version == '3.13' }} - name: Install dependencies run: pip install --upgrade pip wheel tox tox-docker - name: Run flake8 diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py index 515d6f7d7..29909dbe5 100644 --- a/kombu/transport/redis.py +++ b/kombu/transport/redis.py @@ -89,7 +89,7 @@ logger = get_logger('kombu.transport.redis') -crit, warn = logger.critical, logger.warn +crit, warn = logger.critical, logger.warning DEFAULT_PORT = 6379 DEFAULT_DB = 0 diff --git a/requirements/extras/confluentkafka.txt b/requirements/extras/confluentkafka.txt index 746267a87..d8f7d651a 100644 --- a/requirements/extras/confluentkafka.txt +++ b/requirements/extras/confluentkafka.txt @@ -1 +1 @@ -confluent-kafka>=2.2.0 +confluent-kafka>=2.2.0 ; python_version < "3.13" diff --git a/requirements/extras/zstd.txt b/requirements/extras/zstd.txt index 864700d2b..6b7101804 100644 --- a/requirements/extras/zstd.txt +++ b/requirements/extras/zstd.txt @@ -1 +1 @@ -zstandard +zstandard ; python_version < "3.13" diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py index 778d18047..bbb2d7c75 100644 --- a/t/unit/transport/test_redis.py +++ b/t/unit/transport/test_redis.py @@ -1326,11 +1326,16 @@ def pipeline(transaction=True, shard_hint=None): channel.qos.restore_by_tag('test-tag') assert mock_execute_command is not None - assert mock_execute_command.mock_calls == [ - call('WATCH', 'foo_unacked'), - call('HGET', 'foo_unacked', 'test-tag'), - call('ZREM', 'foo_unacked_index', 'test-tag'), - call('HDEL', 'foo_unacked', 'test-tag') + # https://github.com/redis/redis-py/pull/3038 (redis>=5.1.0a1) + # adds keyword argument `keys` to redis client. + # To be compatible with all supported redis versions, + # take into account only `call.args`. + call_args = [call.args for call in mock_execute_command.mock_calls] + assert call_args == [ + ('WATCH', 'foo_unacked'), + ('HGET', 'foo_unacked', 'test-tag'), + ('ZREM', 'foo_unacked_index', 'test-tag'), + ('HDEL', 'foo_unacked', 'test-tag') ] diff --git a/tox.ini b/tox.ini index 3f48d5b6a..d52bc44a1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,10 @@ [tox] envlist = - {pypy3.9,3.8,3.9,3.10,3.11,3.12}-unit - {pypy3.9,3.8,3.9,3.10,3.11,3.12}-linux-integration-py-amqp + {pypy3.9,3.8,3.9,3.10,3.11,3.12,3.13}-unit + {pypy3.9,3.8,3.9,3.10,3.11,3.12,3.13}-linux-integration-py-amqp {pypy3.9,3.8,3.9,3.10,3.11}-linux-integration-redis {pypy3.9,3.8,3.9,3.10,3.11}-linux-integration-mongodb - {3.8,3.9,3.10,3.11,3.12}-linux-integration-kafka + {3.8,3.9,3.10,3.11,3.12,3.13}-linux-integration-kafka flake8 apicheck pydocstyle @@ -20,6 +20,7 @@ python = 3.10: py310, mypy 3.11: py311 3.12: py312 + 3.13: py313 [testenv] sitepackages = False @@ -28,10 +29,10 @@ passenv = DISTUTILS_USE_SDK deps= -r{toxinidir}/requirements/dev.txt - apicheck,pypy3.9,3.8,3.9,3.10,3.11,3.12: -r{toxinidir}/requirements/default.txt - apicheck,pypy3.9,3.8,3.9,3.10,3.11,3.12: -r{toxinidir}/requirements/test.txt - apicheck,pypy3.9,3.8,3.9,3.10,3.11,3.12: -r{toxinidir}/requirements/test-ci.txt - apicheck,3.8-linux,3.9-linux,3.10-linux,3.11-linux,3.12-linux: -r{toxinidir}/requirements/extras/confluentkafka.txt + apicheck,pypy3.9,3.8,3.9,3.10,3.11,3.12,3.13: -r{toxinidir}/requirements/default.txt + apicheck,pypy3.9,3.8,3.9,3.10,3.11,3.12,3.13: -r{toxinidir}/requirements/test.txt + apicheck,pypy3.9,3.8,3.9,3.10,3.11,3.12,3.13: -r{toxinidir}/requirements/test-ci.txt + apicheck,3.8-linux,3.9-linux,3.10-linux,3.11-linux,3.12-linux,3.13-linux: -r{toxinidir}/requirements/extras/confluentkafka.txt apicheck,linkcheck: -r{toxinidir}/requirements/docs.txt flake8,pydocstyle,mypy: -r{toxinidir}/requirements/pkgutils.txt @@ -50,6 +51,7 @@ basepython = 3.10,apicheck,pydocstyle,flake8,linkcheck,cov,mypy: python3.10 3.11: python3.11 3.12: python3.12 + 3.13: python3.13 install_command = python -m pip --disable-pip-version-check install {opts} {packages} @@ -135,4 +137,4 @@ commands = pydocstyle {toxinidir}/kombu [testenv:mypy] -commands = python -m mypy --config-file setup.cfg \ No newline at end of file +commands = python -m mypy --config-file setup.cfg