diff --git a/.github/workflows/pr-bandit.yml b/.github/workflows/pr-bandit.yml index 392ac867..85b14286 100644 --- a/.github/workflows/pr-bandit.yml +++ b/.github/workflows/pr-bandit.yml @@ -17,7 +17,6 @@ jobs: matrix: os: [ubuntu-latest] config: - - { python-version: 3.7, tox-env: security} - { python-version: 3.8, tox-env: security} - { python-version: 3.9, tox-env: security} - { python-version: "3.10", tox-env: security} diff --git a/.github/workflows/pr-python-pypy.yml b/.github/workflows/pr-python-pypy.yml index c1a6c7cf..5a657c47 100644 --- a/.github/workflows/pr-python-pypy.yml +++ b/.github/workflows/pr-python-pypy.yml @@ -5,11 +5,11 @@ on: tox-env: description: "Tox Env to run on the PyPy Infra" required: false - default: "pypy37" + default: "pypy310" pypy-version: description: "Version of PyPy to use" required: false - default: "pypy-3.7" + default: "pypy-3.10" jobs: testPyPy: name: ut-${{ matrix.config.tox-env }}-${{ matrix.os }} diff --git a/.github/workflows/pr-python37.yml b/.github/workflows/pr-python37.yml deleted file mode 100644 index a0c5be23..00000000 --- a/.github/workflows/pr-python37.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Python 3.7 Tests -on: - pull_request: - branches: - - main - - current-release - - "*LTS" - types: [opened, synchronize, reopened, ready_for_review] - -jobs: - testPy37: - if: github.event.pull_request.draft == false - name: ut-${{ matrix.config.tox-env }}-${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - # os: [ubuntu-latest, macos-latest] - os: [ubuntu-latest] - config: - - { python-version: 3.7, tox-env: py37 } - - { python-version: 3.7, tox-env: py37-no-ext } - steps: - - name: Checkout the Repository - uses: actions/checkout@v2 - id: checkout-branch - - - name: Run Unit Tests - uses: harshanarayana/custom-actions@main - with: - python-version: ${{ matrix.config.python-version }} - test-infra-tool: tox - test-infra-version: latest - action: tests - test-additional-args: "-e=${{ matrix.config.tox-env }}" - test-failure-retry: "3" diff --git a/.github/workflows/pr-type-check.yml b/.github/workflows/pr-type-check.yml index d9ce1d28..9e250b52 100644 --- a/.github/workflows/pr-type-check.yml +++ b/.github/workflows/pr-type-check.yml @@ -17,7 +17,6 @@ jobs: matrix: os: [ubuntu-latest] config: - # - { python-version: 3.7, tox-env: type-checking} - { python-version: 3.8, tox-env: type-checking} - { python-version: 3.9, tox-env: type-checking} - { python-version: "3.10", tox-env: type-checking} diff --git a/.github/workflows/pr-windows.yml b/.github/workflows/pr-windows.yml index 4ae0b5be..8f7fb23c 100644 --- a/.github/workflows/pr-windows.yml +++ b/.github/workflows/pr-windows.yml @@ -16,12 +16,10 @@ jobs: fail-fast: false matrix: config: - - { python-version: 3.7, tox-env: py37-no-ext } - { python-version: 3.8, tox-env: py38-no-ext } - { python-version: 3.9, tox-env: py39-no-ext } - { python-version: "3.10", tox-env: py310-no-ext } - { python-version: "3.11", tox-env: py310-no-ext } - - { python-version: pypy-3.7, tox-env: pypy37-no-ext } steps: - name: Checkout Repository diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 48454e1e..7f329fa8 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - name: Checkout repository diff --git a/sanic/app.py b/sanic/app.py index 73874239..cdad5e83 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -1227,18 +1227,9 @@ class Sanic(StaticHandleMixin, BaseSanic, StartupMixin, metaclass=TouchUpMeta): ) -> Task: if not isinstance(task, Future): prepped = cls._prep_task(task, app, loop) - if sys.version_info < (3, 8): # no cov - task = loop.create_task(prepped) - if name: - error_logger.warning( - "Cannot set a name for a task when using Python 3.7. " - "Your task will be created without a name." - ) - task.get_name = lambda: name - else: - task = loop.create_task(prepped, name=name) + task = loop.create_task(prepped, name=name) - if name and register and sys.version_info > (3, 7): + if name and register: app._task_registry[name] = task return task diff --git a/sanic/models/asgi.py b/sanic/models/asgi.py index df6ab3d2..838842b8 100644 --- a/sanic/models/asgi.py +++ b/sanic/models/asgi.py @@ -1,5 +1,4 @@ import asyncio -import sys from typing import Any, Awaitable, Callable, MutableMapping, Optional, Union @@ -16,20 +15,10 @@ ASGIReceive = Callable[[], Awaitable[ASGIMessage]] class MockProtocol: # no cov def __init__(self, transport: "MockTransport", loop): - # This should be refactored when < 3.8 support is dropped self.transport = transport - # Fixup for 3.8+; Sanic still supports 3.7 where loop is required - loop = loop if sys.version_info[:2] < (3, 8) else None - # Optional in 3.9, necessary in 3.10 because the parameter "loop" - # was completely removed - if not loop: - self._not_paused = asyncio.Event() - self._not_paused.set() - self._complete = asyncio.Event() - else: - self._not_paused = asyncio.Event(loop=loop) - self._not_paused.set() - self._complete = asyncio.Event(loop=loop) + self._not_paused = asyncio.Event() + self._not_paused.set() + self._complete = asyncio.Event() def pause_writing(self) -> None: self._not_paused.clear() diff --git a/sanic/server/runners.py b/sanic/server/runners.py index f56168f9..e56e8f37 100644 --- a/sanic/server/runners.py +++ b/sanic/server/runners.py @@ -1,7 +1,5 @@ from __future__ import annotations -import sys - from ssl import SSLContext from typing import TYPE_CHECKING, Dict, Optional, Type, Union @@ -251,8 +249,7 @@ def _serve_http_1( loop.run_until_complete(asyncio.sleep(0.1)) start_shutdown = start_shutdown + 0.1 - if sys.version_info > (3, 7): - app.shutdown_tasks(graceful - start_shutdown) + app.shutdown_tasks(graceful - start_shutdown) # Force close non-idle connection after waiting for # graceful_shutdown_timeout diff --git a/setup.py b/setup.py index e0170f52..bf172c20 100644 --- a/setup.py +++ b/setup.py @@ -83,12 +83,11 @@ setup_kwargs = { "packages": find_packages(exclude=("tests", "tests.*")), "package_data": {"sanic": ["py.typed", "pages/styles/*"]}, "platforms": "any", - "python_requires": ">=3.7", + "python_requires": ">=3.8", "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/tests/test_signal_handlers.py b/tests/test_signal_handlers.py index 401353e9..43f40e13 100644 --- a/tests/test_signal_handlers.py +++ b/tests/test_signal_handlers.py @@ -1,12 +1,14 @@ import asyncio import os import signal + from queue import Queue from types import SimpleNamespace from typing import Optional from unittest.mock import MagicMock import pytest + from sanic_testing.testing import HOST, PORT from sanic import Sanic diff --git a/tox.ini b/tox.ini index 27e19b6c..fabf3bb9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,14 @@ [tox] -envlist = py37, py38, py39, py310, py311, pyNightly, pypy37, {py37,py38,py39,py310,py311,pyNightly,pypy37}-no-ext, lint, check, security, docs, type-checking +envlist = py38, py39, py310, py311, pyNightly, pypy310, {py38,py39,py310,py311,pyNightly,pypy310}-no-ext, lint, check, security, docs, type-checking [testenv] usedevelop = true setenv = - {py37,py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UJSON=1 - {py37,py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UVLOOP=1 + {py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UJSON=1 + {py38,py39,py310,py311,pyNightly}-no-ext: SANIC_NO_UVLOOP=1 extras = test, http3 deps = - httpx==0.23 + httpx>=0.23 allowlist_externals = pytest coverage