From 1adb1c2f84723c32e0889eea0f3352484728d3da Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 7 Jun 2023 21:51:11 +0200 Subject: [PATCH] Drop support for Python 3.7 --- .github/workflows/publish.yml | 2 +- .github/workflows/test-suite.yml | 2 +- README.md | 2 +- pyproject.toml | 6 +----- tests/test_config.py | 7 +------ uvicorn/config.py | 9 ++------- uvicorn/logging.py | 7 +------ uvicorn/loops/asyncio.py | 2 +- uvicorn/protocols/http/h11_impl.py | 7 +------ uvicorn/protocols/http/httptools_impl.py | 7 +------ uvicorn/protocols/websockets/websockets_impl.py | 7 +------ uvicorn/protocols/websockets/wsproto_impl.py | 7 +------ 12 files changed, 13 insertions(+), 52 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d87dd2d36e..f773100891 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,7 @@ jobs: - uses: "actions/checkout@v3" - uses: "actions/setup-python@v4" with: - python-version: 3.7 + python-version: "3.8" - name: "Install dependencies" run: "scripts/install" - name: "Build package & docs" diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index ff82ebdfba..e1346b11ab 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -13,7 +13,7 @@ jobs: runs-on: "${{ matrix.os }}" strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11"] os: [windows-latest, ubuntu-latest, macos-latest] steps: - uses: "actions/checkout@v3" diff --git a/README.md b/README.md index 7cd56398bd..82bc373797 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ **Documentation**: [https://www.uvicorn.org](https://www.uvicorn.org) -**Requirements**: Python 3.7+ (For Python 3.6 support, install version 0.16.0.) +**Requirements**: Python 3.8+ Uvicorn is an ASGI web server implementation for Python. diff --git a/pyproject.toml b/pyproject.toml index 0a2de826c1..e32343f0d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "The lightning-fast ASGI server." readme = "README.md" license = "BSD-3-Clause" -requires-python = ">=3.7" +requires-python = ">=3.8" authors = [ { name = "Tom Christie", email = "tom@tomchristie.com" }, ] @@ -19,7 +19,6 @@ classifiers = [ "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -31,7 +30,6 @@ classifiers = [ dependencies = [ "click>=7.0", "h11>=0.8", - "typing-extensions;python_version < '3.8'", ] [project.optional-dependencies] @@ -115,7 +113,5 @@ py-win32 = "sys_platform == 'win32'" py-not-win32 = "sys_platform != 'win32'" py-linux = "sys_platform == 'linux'" py-darwin = "sys_platform == 'darwin'" -py-gte-38 = "sys_version_info >= (3, 8)" -py-lt-38 = "sys_version_info < (3, 8)" py-gte-39 = "sys_version_info < (3, 9)" py-lt-39 = "sys_version_info < (3, 9)" diff --git a/tests/test_config.py b/tests/test_config.py index 803edc2e17..a8787055ff 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -5,7 +5,7 @@ import sys import typing from pathlib import Path -from typing import Optional +from typing import Literal, Optional from unittest.mock import MagicMock import pytest @@ -19,11 +19,6 @@ from uvicorn.middleware.wsgi import WSGIMiddleware from uvicorn.protocols.http.h11_impl import H11Protocol -if sys.version_info < (3, 8): # pragma: py-gte-38 - from typing_extensions import Literal -else: # pragma: py-lt-38 - from typing import Literal - if typing.TYPE_CHECKING: from asgiref.typing import ( ASGIApplication, diff --git a/uvicorn/config.py b/uvicorn/config.py index 9c5214e1f7..0d07062d31 100644 --- a/uvicorn/config.py +++ b/uvicorn/config.py @@ -15,22 +15,17 @@ Callable, Dict, List, + Literal, Optional, Tuple, Type, Union, ) -from uvicorn.logging import TRACE_LOG_LEVEL - -if sys.version_info < (3, 8): # pragma: py-gte-38 - from typing_extensions import Literal -else: # pragma: py-lt-38 - from typing import Literal - import click from uvicorn.importer import ImportFromStringError, import_from_string +from uvicorn.logging import TRACE_LOG_LEVEL from uvicorn.middleware.asgi2 import ASGI2Middleware from uvicorn.middleware.message_logger import MessageLoggerMiddleware from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware diff --git a/uvicorn/logging.py b/uvicorn/logging.py index b12a710d0c..c88d5fe55a 100644 --- a/uvicorn/logging.py +++ b/uvicorn/logging.py @@ -2,15 +2,10 @@ import logging import sys from copy import copy -from typing import Optional +from typing import Literal, Optional import click -if sys.version_info < (3, 8): # pragma: py-gte-38 - from typing_extensions import Literal -else: # pragma: py-lt-38 - from typing import Literal - TRACE_LOG_LEVEL = 5 diff --git a/uvicorn/loops/asyncio.py b/uvicorn/loops/asyncio.py index 867545f2af..959cfc7feb 100644 --- a/uvicorn/loops/asyncio.py +++ b/uvicorn/loops/asyncio.py @@ -6,5 +6,5 @@ def asyncio_setup(use_subprocess: bool = False) -> None: # pragma: no cover - if sys.version_info >= (3, 8) and sys.platform == "win32" and use_subprocess: + if sys.platform == "win32" and use_subprocess: asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) diff --git a/uvicorn/protocols/http/h11_impl.py b/uvicorn/protocols/http/h11_impl.py index d0b202e3a2..b86d098d57 100644 --- a/uvicorn/protocols/http/h11_impl.py +++ b/uvicorn/protocols/http/h11_impl.py @@ -1,13 +1,13 @@ import asyncio import http import logging -import sys from typing import ( TYPE_CHECKING, Any, Callable, Dict, List, + Literal, Optional, Tuple, Union, @@ -35,11 +35,6 @@ ) from uvicorn.server import ServerState -if sys.version_info < (3, 8): # pragma: py-gte-38 - from typing_extensions import Literal -else: # pragma: py-lt-38 - from typing import Literal - if TYPE_CHECKING: from asgiref.typing import ( ASGI3Application, diff --git a/uvicorn/protocols/http/httptools_impl.py b/uvicorn/protocols/http/httptools_impl.py index 59db0fa047..e31147ce72 100644 --- a/uvicorn/protocols/http/httptools_impl.py +++ b/uvicorn/protocols/http/httptools_impl.py @@ -2,7 +2,6 @@ import http import logging import re -import sys import urllib from asyncio.events import TimerHandle from collections import deque @@ -13,6 +12,7 @@ Deque, Dict, List, + Literal, Optional, Tuple, Union, @@ -38,11 +38,6 @@ ) from uvicorn.server import ServerState -if sys.version_info < (3, 8): # pragma: py-gte-38 - from typing_extensions import Literal -else: # pragma: py-lt-38 - from typing import Literal - if TYPE_CHECKING: from asgiref.typing import ( ASGI3Application, diff --git a/uvicorn/protocols/websockets/websockets_impl.py b/uvicorn/protocols/websockets/websockets_impl.py index 3ee3086ddb..3bf372420e 100644 --- a/uvicorn/protocols/websockets/websockets_impl.py +++ b/uvicorn/protocols/websockets/websockets_impl.py @@ -1,12 +1,12 @@ import asyncio import http import logging -import sys from typing import ( TYPE_CHECKING, Any, Dict, List, + Literal, Optional, Sequence, Tuple, @@ -33,11 +33,6 @@ ) from uvicorn.server import ServerState -if sys.version_info < (3, 8): # pragma: py-gte-38 - from typing_extensions import Literal -else: # pragma: py-lt-38 - from typing import Literal - if TYPE_CHECKING: from asgiref.typing import ( ASGISendEvent, diff --git a/uvicorn/protocols/websockets/wsproto_impl.py b/uvicorn/protocols/websockets/wsproto_impl.py index 206eb6c302..f6fc942303 100644 --- a/uvicorn/protocols/websockets/wsproto_impl.py +++ b/uvicorn/protocols/websockets/wsproto_impl.py @@ -1,7 +1,7 @@ import asyncio import logging -import sys import typing +from typing import Literal from urllib.parse import unquote import wsproto @@ -38,11 +38,6 @@ "WebSocketConnectEvent", ] -if sys.version_info < (3, 8): # pragma: py-gte-38 - from typing_extensions import Literal -else: # pragma: py-lt-38 - from typing import Literal - class WSProtocol(asyncio.Protocol): def __init__(