From fe87568f0b08e2aab552410cc588663ceac33e1b Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Mon, 3 Feb 2025 16:52:04 +1100 Subject: [PATCH 1/4] PyPy 3.11 does not implement Py_TPFLAGS_MANAGED_DICT (#5508) * PyPy 3.11 does not implement Py_TPFLAGS_MANAGED_DICT * add a comment (from review) * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/pybind11/detail/class.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h index f501467ded..1ed2e90c2c 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h @@ -574,9 +574,9 @@ extern "C" inline int pybind11_clear(PyObject *self) { inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) { auto *type = &heap_type->ht_type; type->tp_flags |= Py_TPFLAGS_HAVE_GC; -#if PY_VERSION_HEX < 0x030B0000 - type->tp_dictoffset = type->tp_basicsize; // place dict at the end - type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it +#if PY_VERSION_HEX < 0x030B0000 || defined(PYPY_VERSION) // For PyPy see PR #5508 + type->tp_dictoffset = type->tp_basicsize; // place dict at the end + type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it #else type->tp_flags |= Py_TPFLAGS_MANAGED_DICT; #endif From 8862cd4e7d44a78d061534223df11e586fc85847 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Feb 2025 21:54:30 -0800 Subject: [PATCH 2/4] chore(deps): bump seanmiddleditch/gha-setup-ninja in the actions group (#5509) Bumps the actions group with 1 update: [seanmiddleditch/gha-setup-ninja](https://github.com/seanmiddleditch/gha-setup-ninja). Updates `seanmiddleditch/gha-setup-ninja` from 5 to 6 - [Release notes](https://github.com/seanmiddleditch/gha-setup-ninja/releases) - [Commits](https://github.com/seanmiddleditch/gha-setup-ninja/compare/v5...v6) --- updated-dependencies: - dependency-name: seanmiddleditch/gha-setup-ninja dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72fb9594dc..e09540b3e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1124,7 +1124,7 @@ jobs: uses: jwlawson/actions-setup-cmake@v2.0 - name: Install ninja-build tool - uses: seanmiddleditch/gha-setup-ninja@v5 + uses: seanmiddleditch/gha-setup-ninja@v6 - name: Run pip installs run: | From ab44b307b278b24ca81c339f40f7810d2fd2b389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20=C5=A0im=C3=A1=C4=8Dek?= Date: Tue, 4 Feb 2025 16:48:47 +0100 Subject: [PATCH 3/4] Skip transient crash on GraalPy on OS X (#5514) --- tests/test_gil_scoped.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_gil_scoped.py b/tests/test_gil_scoped.py index 257e66612f..2db771a508 100644 --- a/tests/test_gil_scoped.py +++ b/tests/test_gil_scoped.py @@ -108,6 +108,10 @@ def test_nested_acquire(): @pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads") +@pytest.mark.skipif( + env.GRAALPY and sys.platform == "darwin", + reason="Transiently crashes on GraalPy on OS X", +) def test_multi_acquire_release_cross_module(): for bits in range(16 * 8): internals_ids = m.test_multi_acquire_release_cross_module(bits) From d2e7e8c68711d1ebfb02e2f20bd1cb3bfc5647c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 08:36:08 -0800 Subject: [PATCH 4/4] chore(deps): update pre-commit hooks (#5513) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update pre-commit hooks updates: - [github.com/pre-commit/mirrors-clang-format: v19.1.6 → v19.1.7](https://github.com/pre-commit/mirrors-clang-format/compare/v19.1.6...v19.1.7) - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.6...v0.9.4) - [github.com/codespell-project/codespell: v2.3.0 → v2.4.1](https://github.com/codespell-project/codespell/compare/v2.3.0...v2.4.1) - [github.com/PyCQA/pylint: v3.3.3 → v3.3.4](https://github.com/PyCQA/pylint/compare/v3.3.3...v3.3.4) - [github.com/python-jsonschema/check-jsonschema: 0.30.0 → 0.31.1](https://github.com/python-jsonschema/check-jsonschema/compare/0.30.0...0.31.1) * style: pre-commit fixes * Rename `lins` to `lst` in test_pytypes.py to resolve codespell errors: ``` codespell................................................................Failed - hook id: codespell - exit code: 65 tests/test_pytypes.py:55: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:56: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:58: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:70: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:71: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:72: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:73: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:74: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:75: lins ==> lines, links, lions, loins, limns tests/test_pytypes.py:76: lins ==> lines, links, lions, loins, limns ``` --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve --- .pre-commit-config.yaml | 10 +++++----- tests/conftest.py | 6 +++--- tests/test_eigen_matrix.py | 6 +++--- tests/test_pytypes.py | 20 ++++++++++---------- tests/test_smart_ptr.py | 5 ++--- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d08dffde09..1abc48072a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,14 +25,14 @@ repos: # Clang format the codebase automatically - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v19.1.6" + rev: "v19.1.7" hooks: - id: clang-format types_or: [c++, c, cuda] # Ruff, the Python auto-correcting linter/formatter written in Rust - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.9.4 hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -119,7 +119,7 @@ repos: # Use tools/codespell_ignore_lines_from_errors.py # to rebuild .codespell-ignore-lines - repo: https://github.com/codespell-project/codespell - rev: "v2.3.0" + rev: "v2.4.1" hooks: - id: codespell exclude: ".supp$" @@ -142,14 +142,14 @@ repos: # PyLint has native support - not always usable, but works for us - repo: https://github.com/PyCQA/pylint - rev: "v3.3.3" + rev: "v3.3.4" hooks: - id: pylint files: ^pybind11 # Check schemas on some of our YAML files - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.30.0 + rev: 0.31.1 hooks: - id: check-readthedocs - id: check-github-workflows diff --git a/tests/conftest.py b/tests/conftest.py index 8eb803d2f3..a018a3f795 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -212,9 +212,9 @@ def pytest_configure(): def pytest_report_header(config): del config # Unused. - assert ( - pybind11_tests.compiler_info is not None - ), "Please update pybind11_tests.cpp if this assert fails." + assert pybind11_tests.compiler_info is not None, ( + "Please update pybind11_tests.cpp if this assert fails." + ) return ( "C++ Info:" f" {pybind11_tests.compiler_info}" diff --git a/tests/test_eigen_matrix.py b/tests/test_eigen_matrix.py index 5093ce7d88..47efc9d8f7 100644 --- a/tests/test_eigen_matrix.py +++ b/tests/test_eigen_matrix.py @@ -244,9 +244,9 @@ def test_eigen_ref_to_python(): chols = [m.cholesky1, m.cholesky2, m.cholesky3, m.cholesky4] for i, chol in enumerate(chols, start=1): mymat = chol(np.array([[1.0, 2, 4], [2, 13, 23], [4, 23, 77]])) - assert np.all( - mymat == np.array([[1, 0, 0], [2, 3, 0], [4, 5, 6]]) - ), f"cholesky{i}" + assert np.all(mymat == np.array([[1, 0, 0], [2, 3, 0], [4, 5, 6]])), ( + f"cholesky{i}" + ) def assign_both(a1, a2, r, c, v): diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index 469137cc3c..18932311e7 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -52,10 +52,10 @@ def test_from_iterable(pytype, from_iter_func): def test_iterable(doc): assert doc(m.get_iterable) == "get_iterable() -> Iterable" - lins = [1, 2, 3] - i = m.get_first_item_from_iterable(lins) + lst = [1, 2, 3] + i = m.get_first_item_from_iterable(lst) assert i == 1 - i = m.get_second_item_from_iterable(lins) + i = m.get_second_item_from_iterable(lst) assert i == 2 @@ -67,13 +67,13 @@ def test_list(capture, doc): assert m.list_no_args() == [] assert m.list_ssize_t() == [] assert m.list_size_t() == [] - lins = [1, 2] - m.list_insert_ssize_t(lins) - assert lins == [1, 83, 2] - m.list_insert_size_t(lins) - assert lins == [1, 83, 2, 57] - m.list_clear(lins) - assert lins == [] + lst = [1, 2] + m.list_insert_ssize_t(lst) + assert lst == [1, 83, 2] + m.list_insert_size_t(lst) + assert lst == [1, 83, 2, 57] + m.list_clear(lst) + assert lst == [] with capture: lst = m.get_list() diff --git a/tests/test_smart_ptr.py b/tests/test_smart_ptr.py index 9729004ffc..ab8a1ce62e 100644 --- a/tests/test_smart_ptr.py +++ b/tests/test_smart_ptr.py @@ -313,9 +313,8 @@ def test_smart_ptr_from_default(): instance = m.HeldByDefaultHolder() with pytest.raises(RuntimeError) as excinfo: m.HeldByDefaultHolder.load_shared_ptr(instance) - assert ( - "Unable to load a custom holder type from a " - "default-holder instance" in str(excinfo.value) + assert "Unable to load a custom holder type from a default-holder instance" in str( + excinfo.value )