Skip to content

Commit

Permalink
Drop Python 3.8 (#2823)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Dec 28, 2024
1 parent 8c15c0d commit e7605e1
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: "actions/checkout@v4"
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
description = "The little ASGI library that shines."
readme = "README.md"
license = "BSD-3-Clause"
requires-python = ">=3.8"
requires-python = ">=3.9"
authors = [{ name = "Tom Christie", email = "tom@tomchristie.com" }]
classifiers = [
"Development Status :: 3 - Alpha",
Expand All @@ -18,7 +18,6 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -70,7 +69,7 @@ combine-as-imports = true
[tool.mypy]
strict = true
ignore_missing_imports = true
python_version = "3.8"
python_version = "3.9"

[[tool.mypy.overrides]]
module = "starlette.testclient.*"
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ pytest==8.3.4
trio==0.27.0

# Documentation
black==24.10.0; python_version >= "3.9"
black==24.10.0
mkdocs==1.6.1
mkdocs-material==9.5.47
mkdocstrings-python<1.12.0; python_version < "3.9"
mkdocstrings-python==1.12.2; python_version >= "3.9"
mkdocstrings-python==1.12.2

# Packaging
build==1.2.2.post1
Expand Down
26 changes: 0 additions & 26 deletions starlette/_compat.py

This file was deleted.

4 changes: 2 additions & 2 deletions starlette/_exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from starlette.types import ASGIApp, ExceptionHandler, Message, Receive, Scope, Send
from starlette.websockets import WebSocket

ExceptionHandlers = typing.Dict[typing.Any, ExceptionHandler]
StatusHandlers = typing.Dict[int, ExceptionHandler]
ExceptionHandlers = dict[typing.Any, ExceptionHandler]
StatusHandlers = dict[int, ExceptionHandler]


def _lookup_exception_handler(exc_handlers: ExceptionHandlers, exc: Exception) -> ExceptionHandler | None:
Expand Down
3 changes: 2 additions & 1 deletion starlette/middleware/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import sys
from typing import Any, Iterator, Protocol
from collections.abc import Iterator
from typing import Any, Protocol

if sys.version_info >= (3, 10): # pragma: no cover
from typing import ParamSpec
Expand Down
4 changes: 2 additions & 2 deletions starlette/responses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import hashlib
import http.cookies
import json
import os
Expand All @@ -17,7 +18,6 @@
import anyio
import anyio.to_thread

from starlette._compat import md5_hexdigest
from starlette.background import BackgroundTask
from starlette.concurrency import iterate_in_threadpool
from starlette.datastructures import URL, Headers, MutableHeaders
Expand Down Expand Up @@ -328,7 +328,7 @@ def set_stat_headers(self, stat_result: os.stat_result) -> None:
content_length = str(stat_result.st_size)
last_modified = formatdate(stat_result.st_mtime, usegmt=True)
etag_base = str(stat_result.st_mtime) + "-" + str(stat_result.st_size)
etag = f'"{md5_hexdigest(etag_base.encode(), usedforsecurity=False)}"'
etag = f'"{hashlib.md5(etag_base.encode(), usedforsecurity=False).hexdigest()}"'

self.headers.setdefault("content-length", content_length)
self.headers.setdefault("last-modified", last_modified)
Expand Down
3 changes: 2 additions & 1 deletion tests/middleware/test_base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import contextvars
from collections.abc import AsyncGenerator, AsyncIterator, Generator
from contextlib import AsyncExitStack
from typing import Any, AsyncGenerator, AsyncIterator, Generator
from typing import Any

import anyio
import pytest
Expand Down
5 changes: 3 additions & 2 deletions tests/middleware/test_wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Any, Callable, Dict, Iterable
from collections.abc import Iterable
from typing import Any, Callable

import pytest

Expand All @@ -9,7 +10,7 @@

WSGIResponse = Iterable[bytes]
StartResponse = Callable[..., Any]
Environment = Dict[str, Any]
Environment = dict[str, Any]


def hello_world(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_applications.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

import os
from collections.abc import AsyncGenerator, AsyncIterator, Generator
from contextlib import asynccontextmanager
from pathlib import Path
from typing import AsyncGenerator, AsyncIterator, Callable, Generator
from typing import Callable

import anyio.from_thread
import pytest
Expand Down
11 changes: 3 additions & 8 deletions tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

import base64
import binascii
from typing import Any, Awaitable, Callable
from collections.abc import Awaitable
from typing import Any, Callable
from urllib.parse import urlencode

import pytest

from starlette.applications import Starlette
from starlette.authentication import (
AuthCredentials,
AuthenticationBackend,
AuthenticationError,
SimpleUser,
requires,
)
from starlette.authentication import AuthCredentials, AuthenticationBackend, AuthenticationError, SimpleUser, requires
from starlette.endpoints import HTTPEndpoint
from starlette.middleware import Middleware
from starlette.middleware.authentication import AuthenticationMiddleware
Expand Down
2 changes: 1 addition & 1 deletion tests/test_concurrency.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Iterator
from contextvars import ContextVar
from typing import Iterator

import anyio
import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/test_convertors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Iterator
from datetime import datetime
from typing import Iterator
from uuid import UUID

import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/test_endpoints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterator
from collections.abc import Iterator

import pytest

Expand Down
2 changes: 1 addition & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings
from typing import Generator
from collections.abc import Generator

import pytest

Expand Down
2 changes: 1 addition & 1 deletion tests/test_formparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from tests.types import TestClientFactory


class ForceMultipartDict(typing.Dict[typing.Any, typing.Any]):
class ForceMultipartDict(dict[typing.Any, typing.Any]):
def __bool__(self) -> bool:
return True

Expand Down
3 changes: 2 additions & 1 deletion tests/test_requests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import sys
from typing import Any, Iterator
from collections.abc import Iterator
from typing import Any

import anyio
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import datetime as dt
import time
from collections.abc import AsyncGenerator, AsyncIterator, Iterator
from http.cookies import SimpleCookie
from pathlib import Path
from typing import Any, AsyncGenerator, AsyncIterator, Iterator
from typing import Any

import anyio
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/test_testclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import itertools
import sys
from asyncio import Task, current_task as asyncio_current_task
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from typing import Any, AsyncGenerator
from typing import Any

import anyio
import anyio.lowlevel
Expand Down
3 changes: 2 additions & 1 deletion tests/test_websockets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Any, MutableMapping
from collections.abc import MutableMapping
from typing import Any

import anyio
import pytest
Expand Down

0 comments on commit e7605e1

Please sign in to comment.