From f308a28412292090293d4ccef20b8d680535d037 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Wed, 15 May 2024 21:54:51 +0200 Subject: [PATCH] Update docker build and workflows to Python 3.11 (#373) * Update docker build and workflows to Python 3.11 * Add changelog and fix test --- .github/workflows/changelog_check.yml | 2 +- .github/workflows/pipeline.yml | 6 +++--- changelog.d/373.misc | 1 + docker/Dockerfile | 4 ++-- tests/asyncio_test_helpers.py | 11 ++++++++--- 5 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 changelog.d/373.misc diff --git a/.github/workflows/changelog_check.yml b/.github/workflows/changelog_check.yml index a8d592b1..a18212c9 100644 --- a/.github/workflows/changelog_check.yml +++ b/.github/workflows/changelog_check.yml @@ -12,6 +12,6 @@ jobs: ref: ${{github.event.pull_request.head.sha}} - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - run: python -m pip install towncrier - run: "scripts-dev/check_newsfragment.sh ${{ github.event.number }}" diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 78fd285e..8dc05fd9 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - run: python -m pip install tox - run: tox -e check_codestyle @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - run: python -m pip install tox - run: tox -e check_types @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - run: python -m pip install -e . - run: python -m twisted.trial tests diff --git a/changelog.d/373.misc b/changelog.d/373.misc new file mode 100644 index 00000000..bfec9b82 --- /dev/null +++ b/changelog.d/373.misc @@ -0,0 +1 @@ +Update docker build and CI workflows to Python 3.11. diff --git a/docker/Dockerfile b/docker/Dockerfile index 0b37cc3f..38b5f578 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,7 +9,7 @@ ### ### Stage 0: builder ### -FROM python:3.10-slim as builder +FROM python:3.11-slim as builder # Install git; Sygnal uses it to obtain the package version from the state of the # git repository. @@ -25,7 +25,7 @@ RUN pip install --prefix="/install" --no-warn-script-location /sygnal ### Stage 1: runtime ### -FROM python:3.10-slim +FROM python:3.11-slim COPY --from=builder /install /usr/local EXPOSE 5000/tcp diff --git a/tests/asyncio_test_helpers.py b/tests/asyncio_test_helpers.py index 32dc7d94..6bd5dc91 100644 --- a/tests/asyncio_test_helpers.py +++ b/tests/asyncio_test_helpers.py @@ -1,7 +1,7 @@ import logging import types from asyncio import AbstractEventLoop, transports -from asyncio.protocols import BaseProtocol, Protocol +from asyncio.protocols import BaseProtocol, BufferedProtocol, Protocol from asyncio.transports import Transport from contextvars import Context from typing import Any, Callable, List, Optional, Tuple @@ -164,8 +164,13 @@ def abort(self) -> None: def pretend_to_receive(self, data: bytes) -> None: proto = self.get_protocol() - assert isinstance(proto, Protocol) - proto.data_received(data) + if isinstance(proto, Protocol): + proto.data_received(data) + elif isinstance(proto, BufferedProtocol): + data_len = len(data) + b = proto.get_buffer(data_len) + b[0:data_len] = data # type: ignore[index] + proto.buffer_updated(data_len) def set_protocol(self, protocol: BaseProtocol) -> None: self.protocol = protocol