From 417785293f6c1351be6ea10b6b9f57abff03fdfc Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:10:29 +0200 Subject: [PATCH] Add support for Python 3.12 and drop 3.7 (#1297) --- .github/workflows/tests.yml | 26 ++++++++++---------------- .readthedocs.yaml | 2 +- pyproject.toml | 2 +- src/socketio/tornado.py | 12 +++++------- tests/async/test_client.py | 2 -- tests/async/test_manager.py | 2 -- tests/async/test_pubsub_manager.py | 2 -- tests/async/test_server.py | 2 -- tests/common/test_client.py | 2 -- tox.ini | 4 ++-- 10 files changed, 19 insertions(+), 37 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ddc190c8..60a6b04a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,18 +1,12 @@ name: build -on: - push: - branches: - - main - pull_request: - branches: - - main +on: [push, pull_request, workflow_dispatch] jobs: lint: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - run: python -m pip install --upgrade pip wheel - run: pip install tox tox-gh-actions - run: tox -eflake8 @@ -21,17 +15,17 @@ jobs: name: tests strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.9'] + os: [windows-latest, macos-latest, ubuntu-latest] + python: ['pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12'] exclude: # pypy3 currently fails to run on Windows - os: windows-latest - python: pypy-3.9 + python: pypy-3.10 fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - run: python -m pip install --upgrade pip wheel @@ -41,8 +35,8 @@ jobs: name: coverage runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - run: python -m pip install --upgrade pip wheel - run: pip install tox tox-gh-actions - run: tox diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 26768c7d..4358e806 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3" sphinx: configuration: docs/conf.py diff --git a/pyproject.toml b/pyproject.toml index ed941fa1..d8d7594e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] -requires-python = ">=3.6" +requires-python = ">=3.8" dependencies = [ "bidict >= 0.21.0", "python-engineio >= 4.8.0", diff --git a/src/socketio/tornado.py b/src/socketio/tornado.py index 5b2e6f68..160bd329 100644 --- a/src/socketio/tornado.py +++ b/src/socketio/tornado.py @@ -1,10 +1,8 @@ -import sys -if sys.version_info >= (3, 5): - try: - from engineio.async_drivers.tornado import get_tornado_handler as \ - get_engineio_handler - except ImportError: # pragma: no cover - get_engineio_handler = None +try: + from engineio.async_drivers.tornado import get_tornado_handler as \ + get_engineio_handler +except ImportError: # pragma: no cover + get_engineio_handler = None def get_tornado_handler(socketio_server): # pragma: no cover diff --git a/tests/async/test_client.py b/tests/async/test_client.py index d2a2b8c6..8b8f97a1 100644 --- a/tests/async/test_client.py +++ b/tests/async/test_client.py @@ -1,5 +1,4 @@ import asyncio -import sys import unittest from unittest import mock @@ -13,7 +12,6 @@ from .helpers import AsyncMock, _run -@unittest.skipIf(sys.version_info < (3, 5), 'only for Python 3.5+') class TestAsyncClient(unittest.TestCase): def test_is_asyncio_based(self): c = async_client.AsyncClient() diff --git a/tests/async/test_manager.py b/tests/async/test_manager.py index 0b2fc93f..90d4ad1d 100644 --- a/tests/async/test_manager.py +++ b/tests/async/test_manager.py @@ -1,4 +1,3 @@ -import sys import unittest from unittest import mock @@ -7,7 +6,6 @@ from .helpers import AsyncMock, _run -@unittest.skipIf(sys.version_info < (3, 5), 'only for Python 3.5+') class TestAsyncManager(unittest.TestCase): def setUp(self): id = 0 diff --git a/tests/async/test_pubsub_manager.py b/tests/async/test_pubsub_manager.py index 579452aa..28812992 100644 --- a/tests/async/test_pubsub_manager.py +++ b/tests/async/test_pubsub_manager.py @@ -1,6 +1,5 @@ import asyncio import functools -import sys import unittest from unittest import mock @@ -12,7 +11,6 @@ from .helpers import AsyncMock, _run -@unittest.skipIf(sys.version_info < (3, 5), 'only for Python 3.5+') class TestAsyncPubSubManager(unittest.TestCase): def setUp(self): id = 0 diff --git a/tests/async/test_server.py b/tests/async/test_server.py index bc83bdcf..256545eb 100644 --- a/tests/async/test_server.py +++ b/tests/async/test_server.py @@ -1,6 +1,5 @@ import asyncio import logging -import sys import unittest from unittest import mock @@ -16,7 +15,6 @@ from .helpers import AsyncMock, _run -@unittest.skipIf(sys.version_info < (3, 5), 'only for Python 3.5+') @mock.patch('socketio.server.engineio.AsyncServer', **{ 'return_value.generate_id.side_effect': [str(i) for i in range(1, 10)], 'return_value.send_packet': AsyncMock()}) diff --git a/tests/common/test_client.py b/tests/common/test_client.py index 637e7d52..d1fcf8e3 100644 --- a/tests/common/test_client.py +++ b/tests/common/test_client.py @@ -1,5 +1,4 @@ import logging -import sys import unittest from unittest import mock @@ -155,7 +154,6 @@ def __init__(self, n): with pytest.raises(ValueError): c.register_namespace(n) - @unittest.skipIf(sys.version_info < (3, 0), 'only for Python 3') def test_namespace_handler_wrong_async(self): class MyNamespace(async_namespace.AsyncClientNamespace): pass diff --git a/tox.ini b/tox.ini index 29294571..12deda1c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,14 @@ [tox] -envlist=flake8,py37,py38,py39,py310,py311,pypy3,docs +envlist=flake8,py{38,39,310,311,312,py3},docs skip_missing_interpreters=True [gh-actions] python = - 3.7: py37 3.8: py38 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 pypy-3: pypy3 [testenv]