From e4383c4234e0c727a1981ca5aa50b09c484d5f6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 30 Aug 2026 13:19:09 +0000 Subject: [PATCH 1/2] Bump the dev-tools group with 4 updates Updates the requirements on [pytest](https://github.com/pytest-dev/pytest), [pytest-cov](https://github.com/pytest-dev/pytest-cov), [ruff](https://github.com/astral-sh/ruff) and [mypy](https://github.com/python/mypy) to permit the latest version. Updates `pytest` from 9.0.3 to 9.1.1 - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/9.0.3...9.1.1) Updates `pytest-cov` to 7.1.0 - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v6.0.0...v7.1.0) Updates `ruff` from 0.14.4 to 0.16.4 - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.14.4...0.16.4) Updates `mypy` from 1.18.2 to 2.3.1 - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.18.2...v2.3.1) --- updated-dependencies: - dependency-name: pytest dependency-version: 9.1.1 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-tools - dependency-name: pytest-cov dependency-version: 7.1.0 dependency-type: direct:development dependency-group: dev-tools - dependency-name: ruff dependency-version: 0.16.4 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-tools - dependency-name: mypy dependency-version: 2.3.1 dependency-type: direct:development update-type: version-update:semver-major dependency-group: dev-tools ... Signed-off-by: dependabot[bot] --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1ecc535..a2e84a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,10 +25,10 @@ dependencies = ["chess==1.10.0"] [project.optional-dependencies] dev = [ - "pytest==9.0.3", - "pytest-cov>=6", - "ruff==0.14.4", - "mypy==1.18.2", + "pytest==9.1.1", + "pytest-cov>=7.1.0", + "ruff==0.16.4", + "mypy==2.3.1", "pre-commit>=3", ] From 07579ac141b6330078d8bda62ee9642262c9b641 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 30 Aug 2026 13:29:11 +0000 Subject: [PATCH 2/2] Merge main and fix mypy 2.3.1 optional-buffer errors in shared_tt Co-authored-by: cjunius <41166228+cjunius@users.noreply.github.com> --- src/pychess/shared_tt.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pychess/shared_tt.py b/src/pychess/shared_tt.py index abc7a9c..4c5d8a9 100644 --- a/src/pychess/shared_tt.py +++ b/src/pychess/shared_tt.py @@ -25,6 +25,14 @@ _U64 = (1 << 64) - 1 +def _buffer(shm: shared_memory.SharedMemory) -> memoryview: + """Return the segment's buffer, which is ``None`` only once it is closed.""" + buf = shm.buf + if buf is None: # pragma: no cover - a live segment always has a buffer + raise RuntimeError("shared memory segment is closed") + return buf + + def _pack_move(move: chess.Move | None) -> int: if move is None: return 0 @@ -74,7 +82,7 @@ def probe( self, key: int, depth: int, alpha: int, beta: int ) -> tuple[bool, int, chess.Move | None]: off = (key & self.mask) * ENTRY_SIZE - word0, data = _ENTRY.unpack_from(self.shm.buf, off) + word0, data = _ENTRY.unpack_from(_buffer(self.shm), off) if data == 0 or (word0 ^ data) != key: return False, 0, None move, score, e_depth, flag = _unpack_data(data) @@ -89,11 +97,11 @@ def probe( def store(self, key: int, depth: int, score: int, flag: int, move: chess.Move | None) -> None: off = (key & self.mask) * ENTRY_SIZE - word0, old = _ENTRY.unpack_from(self.shm.buf, off) + word0, old = _ENTRY.unpack_from(_buffer(self.shm), off) if old and (word0 ^ old) == key and _unpack_data(old)[2] > depth: return # keep the deeper entry for this position data = _pack_data(move, score, depth, flag) - _ENTRY.pack_into(self.shm.buf, off, (key ^ data) & _U64, data) + _ENTRY.pack_into(_buffer(self.shm), off, (key ^ data) & _U64, data) def close(self) -> None: with contextlib.suppress(Exception): @@ -110,16 +118,16 @@ class SharedFlag: def __init__(self, name: str | None = None, create: bool = True) -> None: if create: self.shm = shared_memory.SharedMemory(create=True, size=1) - self.shm.buf[0] = 0 + _buffer(self.shm)[0] = 0 else: self.shm = shared_memory.SharedMemory(name=name) self.name = self.shm.name def set(self) -> None: - self.shm.buf[0] = 1 + _buffer(self.shm)[0] = 1 def is_set(self) -> bool: - return self.shm.buf[0] != 0 + return _buffer(self.shm)[0] != 0 def close(self) -> None: with contextlib.suppress(Exception):