From a67c7cd0196ba8f1fcbf236fdb47b4caeb7507f9 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 21 Nov 2024 09:31:01 -0500 Subject: [PATCH 1/2] Fix a test regression with pybind11 2.11.2, 2.12.1, 2.13.6+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “A new self._pybind11_conduit_v1_() method is automatically added to all py::class_-wrapped types, to enable type-safe interoperability between different independent Python/C++ bindings systems, including pybind11 versions with different PYBIND11_INTERNALS_VERSIONs.” https://github.com/pybind/pybind11/releases/tag/v2.13.6 Ensure that `tests/test_0_API.py::test_doc_exists` does not see this as an undocumented API function. --- tests/test_0_API.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_0_API.py b/tests/test_0_API.py index 4d12301c6..470f19331 100644 --- a/tests/test_0_API.py +++ b/tests/test_0_API.py @@ -19,7 +19,9 @@ def test_doc_exists(): morphio.mut.Soma, ] for cls in classes: - public_methods = (method for method in dir(cls) if not method[:2] == '__') + public_methods = ( + method for method in dir(cls) if not method.startswith(("__", "_pybind11")) + ) for method in public_methods: assert getattr(cls, method).__doc__, \ 'Public method {} of class {} is not documented !'.format(method, cls) From 533d2f36edad55b40acc8573367c00a1f6b75f93 Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Mon, 25 Nov 2024 14:12:40 +0100 Subject: [PATCH 2/2] have explicit allowlist of functions to ignore --- tests/test_0_API.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_0_API.py b/tests/test_0_API.py index 470f19331..783a74d49 100644 --- a/tests/test_0_API.py +++ b/tests/test_0_API.py @@ -2,7 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 import morphio - def test_doc_exists(): classes = [ morphio.EndoplasmicReticulum, @@ -18,9 +17,18 @@ def test_doc_exists(): morphio.mut.Section, morphio.mut.Soma, ] + + # we want to makes sure we never forget to add imports in the morphio.__init__ + # however, sometimes pybind adds new functions in that namespace, this is the + # place to explicitly ignore them + ignored_methods = { + "_pybind11_conduit_v1_" + } + for cls in classes: public_methods = ( - method for method in dir(cls) if not method.startswith(("__", "_pybind11")) + method for method in dir(cls) + if not (method.startswith("__") or method in ignored_methods) ) for method in public_methods: assert getattr(cls, method).__doc__, \