Skip to content

Commit

Permalink
Remove Python3.7 support (#2777)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins committed Jul 9, 2023
1 parent 5dd1623 commit 4a2b82e
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 78 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr-bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-python-pypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/pr-python37.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/pr-type-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/pr-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions sanic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,18 +1227,9 @@ def _loop_add_task(
) -> 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
Expand Down
17 changes: 3 additions & 14 deletions sanic/models/asgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import sys

from typing import Any, Awaitable, Callable, MutableMapping, Optional, Union

Expand All @@ -16,20 +15,10 @@

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()
Expand Down
5 changes: 1 addition & 4 deletions sanic/server/runners.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import sys

from ssl import SSLContext
from typing import TYPE_CHECKING, Dict, Optional, Type, Union

Expand Down Expand Up @@ -251,8 +249,7 @@ def _cleanup():
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
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ def str_to_bool(val: str) -> bool:
"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",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_signal_handlers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4a2b82e

Please sign in to comment.