Skip to content

Commit 69ec85e

Browse files
committed
Drop support for Python 3.9.
1 parent fc7cafe commit 69ec85e

File tree

23 files changed

+68
-127
lines changed

23 files changed

+68
-127
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ jobs:
5555
strategy:
5656
matrix:
5757
python:
58-
- "3.9"
5958
- "3.10"
6059
- "3.11"
6160
- "3.12"

docs/intro/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Getting started
66
Requirements
77
------------
88

9-
websockets requires Python ≥ 3.9.
9+
websockets requires Python ≥ 3.10.
1010

1111
.. admonition:: Use the most recent Python release
1212
:class: tip

docs/project/changelog.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@ fixing regressions shortly after a release.
2525
Only documented APIs are public. Undocumented, private APIs may change without
2626
notice.
2727

28-
.. _15.1:
28+
.. _16.0:
2929

30-
15.1
30+
16.0
3131
----
3232

3333
*In development*
3434

35+
Backwards-incompatible changes
36+
..............................
37+
38+
.. admonition:: websockets 16.0 requires Python ≥ 3.10.
39+
:class: tip
40+
41+
websockets 15.0 is the last version supporting Python 3.9.
42+
3543
Improvements
3644
............
3745

docs/topics/logging.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ Here's how to include them in logs, assuming they're in the
133133

134134
async with serve(
135135
...,
136-
# Python < 3.10 requires passing None as the second argument.
137-
logger=LoggerAdapter(logging.getLogger("websockets.server"), None),
136+
logger=LoggerAdapter(logging.getLogger("websockets.server")),
138137
):
139138
...
140139

@@ -176,8 +175,7 @@ a :class:`~logging.LoggerAdapter`::
176175

177176
async with serve(
178177
...,
179-
# Python < 3.10 requires passing None as the second argument.
180-
logger=LoggerAdapter(logging.getLogger("websockets.server"), None),
178+
logger=LoggerAdapter(logging.getLogger("websockets.server")),
181179
):
182180
...
183181

example/deployment/kubernetes/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9-alpine
1+
FROM python:3.13-alpine
22

33
RUN pip install websockets
44

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "websockets"
77
description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)"
8-
requires-python = ">=3.9"
8+
requires-python = ">=3.10"
99
license = { text = "BSD-3-Clause" }
1010
authors = [
1111
{ name = "Aymeric Augustin", email = "[email protected]" },
@@ -19,7 +19,6 @@ classifiers = [
1919
"Operating System :: OS Independent",
2020
"Programming Language :: Python",
2121
"Programming Language :: Python :: 3",
22-
"Programming Language :: Python :: 3.9",
2322
"Programming Language :: Python :: 3.10",
2423
"Programming Language :: Python :: 3.11",
2524
"Programming Language :: Python :: 3.12",

src/websockets/asyncio/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ async def __await_impl__(self) -> ClientConnection:
579579
# Re-raise exception with an informative error message.
580580
raise TimeoutError("timed out during opening handshake") from exc
581581

582-
# ... = yield from connect(...) - remove when dropping Python < 3.10
582+
# ... = yield from connect(...) - remove when dropping Python < 3.11
583583

584584
__iter__ = __await__
585585

@@ -629,8 +629,7 @@ async def __aiter__(self) -> AsyncIterator[ClientConnection]:
629629
self.logger.info(
630630
"connect failed; reconnecting in %.1f seconds: %s",
631631
delay,
632-
# Remove first argument when dropping Python 3.9.
633-
traceback.format_exception_only(type(exc), exc)[0].strip(),
632+
traceback.format_exception_only(exc)[0].strip(),
634633
)
635634
await asyncio.sleep(delay)
636635
continue

src/websockets/asyncio/connection.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,7 @@ def broadcast(
12241224
else:
12251225
connection.logger.warning(
12261226
"skipped broadcast: failed to write message: %s",
1227-
traceback.format_exception_only(
1228-
# Remove first argument when dropping Python 3.9.
1229-
type(write_exception),
1230-
write_exception,
1231-
)[0].strip(),
1227+
traceback.format_exception_only(write_exception)[0].strip(),
12321228
)
12331229

12341230
if raise_exceptions and exceptions:

src/websockets/asyncio/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ async def __await_impl__(self) -> Server:
834834
self.server.wrap(server)
835835
return self.server
836836

837-
# ... = yield from serve(...) - remove when dropping Python < 3.10
837+
# ... = yield from serve(...) - remove when dropping Python < 3.11
838838

839839
__iter__ = __await__
840840

src/websockets/datastructures.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Iterable, Iterator, Mapping, MutableMapping
4-
from typing import Any, Protocol, Union
4+
from typing import Any, Protocol
55

66

77
__all__ = [
@@ -171,13 +171,9 @@ def keys(self) -> Iterable[str]: ...
171171
def __getitem__(self, key: str) -> str: ...
172172

173173

174-
# Change to Headers | Mapping[str, str] | ... when dropping Python < 3.10.
175-
HeadersLike = Union[
176-
Headers,
177-
Mapping[str, str],
178-
Iterable[tuple[str, str]],
179-
SupportsKeysAndGetItem,
180-
]
174+
HeadersLike = (
175+
Headers | Mapping[str, str] | Iterable[tuple[str, str]] | SupportsKeysAndGetItem
176+
)
181177
"""
182178
Types accepted where :class:`Headers` is expected.
183179

0 commit comments

Comments
 (0)