From 37150ebc9cb8566fa616c21a48e911a90f44bcf9 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Thu, 20 Nov 2025 03:08:58 +0530 Subject: [PATCH 01/30] ENH: add regression test for HTML repr of meta-objects (fixes #163) --- .../tests/test_object_html_repr.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 skbase/base/_pretty_printing/tests/test_object_html_repr.py diff --git a/skbase/base/_pretty_printing/tests/test_object_html_repr.py b/skbase/base/_pretty_printing/tests/test_object_html_repr.py new file mode 100644 index 00000000..015ff285 --- /dev/null +++ b/skbase/base/_pretty_printing/tests/test_object_html_repr.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +"""Tests for HTML representation of meta-objects (regression for #160/#163).""" + +from skbase.base import BaseObject +from skbase.base._meta import BaseMetaObject +from skbase.base._pretty_printing._object_html_repr import _object_html_repr + + +class ComponentDummy(BaseObject): + def __init__(self, a=1): + self.a = a + super().__init__() + + +class MetaObjectForHtml(BaseMetaObject): + def __init__(self, steps=None): + self.steps = steps + super().__init__() + + +def test_meta_object_html_repr_does_not_raise(): + """Ensure HTML repr for a meta-object does not raise (regression test). + + This covers the failure case where displaying meta-objects as HTML used an + incorrect VisualBlock import and would crash. The function should return + an HTML string and not raise an exception. + """ + steps = [("comp", ComponentDummy(42))] + meta = MetaObjectForHtml(steps=steps) + + html_repr = _object_html_repr(meta) + + assert isinstance(html_repr, str) + # should include the class name and at least one html tag + assert meta.__class__.__name__ in html_repr + assert " Date: Thu, 20 Nov 2025 03:29:18 +0530 Subject: [PATCH 02/30] ENH: add test for all_objects tag filtering (regression for #161/#162) --- skbase/tests/test_lookup.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/skbase/tests/test_lookup.py b/skbase/tests/test_lookup.py index bb985b10..30232d4a 100644 --- a/skbase/tests/test_lookup.py +++ b/skbase/tests/test_lookup.py @@ -33,3 +33,29 @@ def test_all_objects_returns_class_name_for_alias(tmp_path, monkeypatch): sys.modules.pop(f"{pkg_name}.module", None) sys.modules.pop(pkg_name, None) + + +def test_all_objects_filter_tags_returns_matches(tmp_path, monkeypatch): + """Test that all_objects honors the filter_tags argument and returns matching classes.""" + pkg_name = "pkg_tag_case" + root = tmp_path / pkg_name + root.mkdir() + + (root / "__init__.py").write_text( + "from .module import MyClass\n" "__all__ = ['MyClass']\n" + ) + (root / "module.py").write_text( + "from skbase.base import BaseObject\n\n" + "class MyClass(BaseObject):\n" + " _tags = {'special_tag': True}\n" + ) + monkeypatch.syspath_prepend(str(tmp_path)) + importlib.invalidate_caches() + + objs = all_objects(package_name=pkg_name, path=str(root), filter_tags="special_tag") + assert len(objs) == 1 + name, klass = objs[0] + assert name == klass.__name__ == "MyClass" + + sys.modules.pop(f"{pkg_name}.module", None) + sys.modules.pop(pkg_name, None) From b06f1fb4473336e085b152074d90b2795efe949e Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Thu, 20 Nov 2025 03:33:04 +0530 Subject: [PATCH 03/30] Delete skbase/base/_pretty_printing/tests/test_object_html_repr.py --- .../tests/test_object_html_repr.py | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 skbase/base/_pretty_printing/tests/test_object_html_repr.py diff --git a/skbase/base/_pretty_printing/tests/test_object_html_repr.py b/skbase/base/_pretty_printing/tests/test_object_html_repr.py deleted file mode 100644 index 015ff285..00000000 --- a/skbase/base/_pretty_printing/tests/test_object_html_repr.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -"""Tests for HTML representation of meta-objects (regression for #160/#163).""" - -from skbase.base import BaseObject -from skbase.base._meta import BaseMetaObject -from skbase.base._pretty_printing._object_html_repr import _object_html_repr - - -class ComponentDummy(BaseObject): - def __init__(self, a=1): - self.a = a - super().__init__() - - -class MetaObjectForHtml(BaseMetaObject): - def __init__(self, steps=None): - self.steps = steps - super().__init__() - - -def test_meta_object_html_repr_does_not_raise(): - """Ensure HTML repr for a meta-object does not raise (regression test). - - This covers the failure case where displaying meta-objects as HTML used an - incorrect VisualBlock import and would crash. The function should return - an HTML string and not raise an exception. - """ - steps = [("comp", ComponentDummy(42))] - meta = MetaObjectForHtml(steps=steps) - - html_repr = _object_html_repr(meta) - - assert isinstance(html_repr, str) - # should include the class name and at least one html tag - assert meta.__class__.__name__ in html_repr - assert " Date: Thu, 20 Nov 2025 03:43:12 +0530 Subject: [PATCH 04/30] STYLE: wrap long docstring to satisfy flake8 E501 --- skbase/tests/test_lookup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skbase/tests/test_lookup.py b/skbase/tests/test_lookup.py index 30232d4a..f7d927a7 100644 --- a/skbase/tests/test_lookup.py +++ b/skbase/tests/test_lookup.py @@ -36,7 +36,10 @@ def test_all_objects_returns_class_name_for_alias(tmp_path, monkeypatch): def test_all_objects_filter_tags_returns_matches(tmp_path, monkeypatch): - """Test that all_objects honors the filter_tags argument and returns matching classes.""" + """Test that all_objects honors the filter_tags argument. + + Ensure the function returns matching classes when a tag is provided. + """ pkg_name = "pkg_tag_case" root = tmp_path / pkg_name root.mkdir() From 72a688c1474fd1225cc9d551d1f0b9cd074e7b9d Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Fri, 21 Nov 2025 23:41:51 +0530 Subject: [PATCH 05/30] tests(lookup): restrict package_name to skbase.tests to reduce scan scope (fix issue #114) --- skbase/lookup/tests/test_lookup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/skbase/lookup/tests/test_lookup.py b/skbase/lookup/tests/test_lookup.py index 8bec321b..4aa117de 100644 --- a/skbase/lookup/tests/test_lookup.py +++ b/skbase/lookup/tests/test_lookup.py @@ -926,7 +926,7 @@ def test_all_objects_class_filter(class_filter): """Test all_objects filters by class type as expected.""" # Results applying filter objs = all_objects( - package_name="skbase", + package_name="skbase.tests", return_names=True, as_dataframe=True, return_tags=None, @@ -940,7 +940,7 @@ def test_all_objects_class_filter(class_filter): # Results without filter objs = all_objects( - package_name="skbase", + package_name="skbase.tests", return_names=True, as_dataframe=True, return_tags=None, @@ -966,7 +966,7 @@ def test_all_object_tag_filter(tag_filter): """Test all_objects filters by tag as expected.""" # Results applying filter objs = all_objects( - package_name="skbase", + package_name="skbase.tests", return_names=True, as_dataframe=True, return_tags=None, @@ -980,7 +980,7 @@ def test_all_object_tag_filter(tag_filter): # Results without filter objs = all_objects( - package_name="skbase", + package_name="skbase.tests", return_names=True, as_dataframe=True, return_tags=None, @@ -1041,7 +1041,7 @@ def test_all_object_class_lookup(class_lookup, class_filter): """Test all_objects class_lookup parameter works as expected..""" # Results applying filter objs = all_objects( - package_name="skbase", + package_name="skbase.tests", return_names=True, as_dataframe=True, return_tags=None, @@ -1064,7 +1064,7 @@ def test_all_object_class_lookup_invalid_object_types_raises( # Results applying filter with pytest.raises(ValueError): all_objects( - package_name="skbase", + package_name="skbase.tests", return_names=True, as_dataframe=True, return_tags=None, From ef2a3dea499c86ff317316c1db8571c7b5517ebd Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 22 Nov 2025 13:12:34 +0530 Subject: [PATCH 06/30] tests(lookup): use dedicated mock_package fixtures; add fixtures and isolate tests to skbase.tests.mock_package (fix #114) --- skbase/lookup/tests/test_lookup.py | 18 ++++---- skbase/tests/mock_package/__init__.py | 25 ++++++++++- skbase/tests/mock_package/fixtures.py | 42 +++++++++++++++++++ .../tests/mock_package/test_mock_package.py | 7 ++++ 4 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 skbase/tests/mock_package/fixtures.py diff --git a/skbase/lookup/tests/test_lookup.py b/skbase/lookup/tests/test_lookup.py index 4aa117de..f99419cd 100644 --- a/skbase/lookup/tests/test_lookup.py +++ b/skbase/lookup/tests/test_lookup.py @@ -35,13 +35,13 @@ SKBASE_PUBLIC_CLASSES_BY_MODULE, SKBASE_PUBLIC_FUNCTIONS_BY_MODULE, SKBASE_PUBLIC_MODULES, - ClassWithABTrue, - Parent, ) -from skbase.tests.mock_package.test_mock_package import ( +from skbase.tests.mock_package import ( MOCK_PACKAGE_OBJECTS, CompositionDummy, NotABaseObject, + Parent, + ClassWithABTrue, ) __author__: List[str] = ["RNKuhns", "fkiraly"] @@ -926,7 +926,7 @@ def test_all_objects_class_filter(class_filter): """Test all_objects filters by class type as expected.""" # Results applying filter objs = all_objects( - package_name="skbase.tests", + package_name="skbase.tests.mock_package", return_names=True, as_dataframe=True, return_tags=None, @@ -940,7 +940,7 @@ def test_all_objects_class_filter(class_filter): # Results without filter objs = all_objects( - package_name="skbase.tests", + package_name="skbase.tests.mock_package", return_names=True, as_dataframe=True, return_tags=None, @@ -966,7 +966,7 @@ def test_all_object_tag_filter(tag_filter): """Test all_objects filters by tag as expected.""" # Results applying filter objs = all_objects( - package_name="skbase.tests", + package_name="skbase.tests.mock_package", return_names=True, as_dataframe=True, return_tags=None, @@ -980,7 +980,7 @@ def test_all_object_tag_filter(tag_filter): # Results without filter objs = all_objects( - package_name="skbase.tests", + package_name="skbase.tests.mock_package", return_names=True, as_dataframe=True, return_tags=None, @@ -1041,7 +1041,7 @@ def test_all_object_class_lookup(class_lookup, class_filter): """Test all_objects class_lookup parameter works as expected..""" # Results applying filter objs = all_objects( - package_name="skbase.tests", + package_name="skbase.tests.mock_package", return_names=True, as_dataframe=True, return_tags=None, @@ -1064,7 +1064,7 @@ def test_all_object_class_lookup_invalid_object_types_raises( # Results applying filter with pytest.raises(ValueError): all_objects( - package_name="skbase.tests", + package_name="skbase.tests.mock_package", return_names=True, as_dataframe=True, return_tags=None, diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index c790c746..4d4ccca9 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -1,5 +1,28 @@ # -*- coding: utf-8 -*- -"""Mock package for skbase testing.""" +"""Mock package for skbase testing. + +This package contains controlled test fixtures used by lookup tests. +""" from typing import List +from .test_mock_package import ( + CompositionDummy, + InheritsFromBaseObject, + AnotherClass, + NotABaseObject, + MOCK_PACKAGE_OBJECTS, +) +from .fixtures import Parent, Child, ClassWithABTrue + +__all__: List[str] = [ + "CompositionDummy", + "InheritsFromBaseObject", + "AnotherClass", + "NotABaseObject", + "MOCK_PACKAGE_OBJECTS", + "Parent", + "Child", + "ClassWithABTrue", +] + __author__: List[str] = ["fkiraly", "RNKuhns"] diff --git a/skbase/tests/mock_package/fixtures.py b/skbase/tests/mock_package/fixtures.py new file mode 100644 index 00000000..192ea42c --- /dev/null +++ b/skbase/tests/mock_package/fixtures.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +"""Additional fixture classes for the mock package used in lookup tests.""" +from typing import List + +from skbase.base import BaseObject + +__author__: List[str] = ["fkiraly", "RNKuhns"] + + +class Parent(BaseObject): + """Parent class to test tag inheritance and class filters.""" + + _tags = {"A": "1", "B": 2, "C": 1234, "3": "D"} + + def __init__(self, a="something", b=7, c=None): + self.a = a + self.b = b + self.c = c + super().__init__() + + def some_method(self): + pass + + +class Child(Parent): + """Child class that overrides some tags.""" + + _tags = {"A": 42, "3": "E"} + __author__ = ["fkiraly", "RNKuhns"] + + def some_method(self): + pass + + +class ClassWithABTrue(Parent): + """Child class that sets A, B tags to True.""" + + _tags = {"A": True, "B": True} + __author__ = ["fkiraly", "RNKuhns"] + + def some_method(self): + pass diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index eac22637..09b92219 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -4,12 +4,16 @@ from typing import List from skbase.base import BaseObject +from .fixtures import Parent, Child, ClassWithABTrue __all__: List[str] = [ "CompositionDummy", "InheritsFromBaseObject", "AnotherClass", "NotABaseObject", + "Parent", + "Child", + "ClassWithABTrue", ] __author__: List[str] = ["fkiraly", "RNKuhns"] @@ -71,4 +75,7 @@ class _NonPublicClass(BaseObject): CompositionDummy, InheritsFromBaseObject, _NonPublicClass, + Parent, + Child, + ClassWithABTrue, ] From 9dd4cd9a2064ea37b334fa292ab7c111af60d905 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 22 Nov 2025 13:15:15 +0530 Subject: [PATCH 07/30] tests(mock_package): add public module, private module, and subpackage to improve mock coverage (edge cases) --- skbase/tests/mock_package/_private_module.py | 18 ++++++++++++++ skbase/tests/mock_package/module_public.py | 26 ++++++++++++++++++++ skbase/tests/mock_package/subpkg/__init__.py | 3 +++ skbase/tests/mock_package/subpkg/module_b.py | 10 ++++++++ 4 files changed, 57 insertions(+) create mode 100644 skbase/tests/mock_package/_private_module.py create mode 100644 skbase/tests/mock_package/module_public.py create mode 100644 skbase/tests/mock_package/subpkg/__init__.py create mode 100644 skbase/tests/mock_package/subpkg/module_b.py diff --git a/skbase/tests/mock_package/_private_module.py b/skbase/tests/mock_package/_private_module.py new file mode 100644 index 00000000..49d13e66 --- /dev/null +++ b/skbase/tests/mock_package/_private_module.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +"""Non-public module in mock package; contains a non-public BaseObject subclass. + +This module's class name begins with an underscore and should be ignored by +`all_objects` when `exclude_non_public_items` is True. +""" + +from skbase.base import BaseObject + + +class _PrivateThing(BaseObject): + """A non-public BaseObject subclass that should be ignored by discovery.""" + + def __init__(self): + super().__init__() + + +__all__ = ["_PrivateThing"] diff --git a/skbase/tests/mock_package/module_public.py b/skbase/tests/mock_package/module_public.py new file mode 100644 index 00000000..cb0743a0 --- /dev/null +++ b/skbase/tests/mock_package/module_public.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +"""Public module in mock package with decorated and plain functions.""" + +from functools import wraps + + +def simple_function(x): + """A plain function for testing function discovery.""" + return x * 2 + + +def my_decorator(func): + @wraps(func) + def wrapper(*args, **kwargs): + return func(*args, **kwargs) + + return wrapper + + +@my_decorator +def decorated_function(y): + """A decorated function to ensure unwrapping works in member discovery.""" + return y + 1 + + +__all__ = ["simple_function", "decorated_function"] diff --git a/skbase/tests/mock_package/subpkg/__init__.py b/skbase/tests/mock_package/subpkg/__init__.py new file mode 100644 index 00000000..e4385f99 --- /dev/null +++ b/skbase/tests/mock_package/subpkg/__init__.py @@ -0,0 +1,3 @@ +"""Subpackage in mock package to test recursive walking.""" + +__all__ = ["module_b"] diff --git a/skbase/tests/mock_package/subpkg/module_b.py b/skbase/tests/mock_package/subpkg/module_b.py new file mode 100644 index 00000000..cda14abe --- /dev/null +++ b/skbase/tests/mock_package/subpkg/module_b.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +"""Module inside subpackage to test recursive discovery.""" + + +def subpkg_fn(): + """Simple function in subpackage module.""" + return "ok" + + +__all__ = ["subpkg_fn"] From 15b7935b3a90cdc3c878ac0809d98cc58e8b100c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Nov 2025 08:06:22 +0000 Subject: [PATCH 08/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- skbase/lookup/tests/test_lookup.py | 2 +- skbase/tests/mock_package/__init__.py | 28 +++++++++---------- .../tests/mock_package/test_mock_package.py | 3 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/skbase/lookup/tests/test_lookup.py b/skbase/lookup/tests/test_lookup.py index f99419cd..989befa6 100644 --- a/skbase/lookup/tests/test_lookup.py +++ b/skbase/lookup/tests/test_lookup.py @@ -38,10 +38,10 @@ ) from skbase.tests.mock_package import ( MOCK_PACKAGE_OBJECTS, + ClassWithABTrue, CompositionDummy, NotABaseObject, Parent, - ClassWithABTrue, ) __author__: List[str] = ["RNKuhns", "fkiraly"] diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index 4d4ccca9..5b8feaf7 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -5,24 +5,24 @@ """ from typing import List +from .fixtures import Child, ClassWithABTrue, Parent from .test_mock_package import ( - CompositionDummy, - InheritsFromBaseObject, - AnotherClass, - NotABaseObject, - MOCK_PACKAGE_OBJECTS, + MOCK_PACKAGE_OBJECTS, + AnotherClass, + CompositionDummy, + InheritsFromBaseObject, + NotABaseObject, ) -from .fixtures import Parent, Child, ClassWithABTrue __all__: List[str] = [ - "CompositionDummy", - "InheritsFromBaseObject", - "AnotherClass", - "NotABaseObject", - "MOCK_PACKAGE_OBJECTS", - "Parent", - "Child", - "ClassWithABTrue", + "CompositionDummy", + "InheritsFromBaseObject", + "AnotherClass", + "NotABaseObject", + "MOCK_PACKAGE_OBJECTS", + "Parent", + "Child", + "ClassWithABTrue", ] __author__: List[str] = ["fkiraly", "RNKuhns"] diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index 09b92219..e05cdcb0 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -4,7 +4,8 @@ from typing import List from skbase.base import BaseObject -from .fixtures import Parent, Child, ClassWithABTrue + +from .fixtures import Child, ClassWithABTrue, Parent __all__: List[str] = [ "CompositionDummy", From d670fa2ab3265dbc7c601ebc4bbc46b2707081e9 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 22 Nov 2025 13:37:09 +0530 Subject: [PATCH 09/30] style(tests): fix indentation (replace tabs with spaces) in mock_package __init__ --- skbase/tests/mock_package/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index 5b8feaf7..a83d79ec 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -7,11 +7,11 @@ from .fixtures import Child, ClassWithABTrue, Parent from .test_mock_package import ( - MOCK_PACKAGE_OBJECTS, - AnotherClass, CompositionDummy, InheritsFromBaseObject, + AnotherClass, NotABaseObject, + MOCK_PACKAGE_OBJECTS, ) __all__: List[str] = [ @@ -23,6 +23,14 @@ "Parent", "Child", "ClassWithABTrue", + "CompositionDummy", + "InheritsFromBaseObject", + "AnotherClass", + "NotABaseObject", + "MOCK_PACKAGE_OBJECTS", + "Parent", + "Child", + "ClassWithABTrue", ] __author__: List[str] = ["fkiraly", "RNKuhns"] From 95db0d05ca2bfa40849bbf371759997c5d6b5b1b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Nov 2025 08:07:54 +0000 Subject: [PATCH 10/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- skbase/tests/mock_package/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index a83d79ec..f22331fb 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -7,11 +7,11 @@ from .fixtures import Child, ClassWithABTrue, Parent from .test_mock_package import ( + MOCK_PACKAGE_OBJECTS, + AnotherClass, CompositionDummy, InheritsFromBaseObject, - AnotherClass, NotABaseObject, - MOCK_PACKAGE_OBJECTS, ) __all__: List[str] = [ From 08054cb1e0468a30c8ca036f0c62106cb5e842ce Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 22 Nov 2025 13:41:35 +0530 Subject: [PATCH 11/30] tests(mock_package): remove old files renamed to test_* counterparts --- skbase/tests/mock_package/_private_module.py | 18 --------- skbase/tests/mock_package/fixtures.py | 42 -------------------- skbase/tests/mock_package/module_public.py | 26 ------------ skbase/tests/mock_package/subpkg/module_b.py | 10 ----- 4 files changed, 96 deletions(-) delete mode 100644 skbase/tests/mock_package/_private_module.py delete mode 100644 skbase/tests/mock_package/fixtures.py delete mode 100644 skbase/tests/mock_package/module_public.py delete mode 100644 skbase/tests/mock_package/subpkg/module_b.py diff --git a/skbase/tests/mock_package/_private_module.py b/skbase/tests/mock_package/_private_module.py deleted file mode 100644 index 49d13e66..00000000 --- a/skbase/tests/mock_package/_private_module.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -"""Non-public module in mock package; contains a non-public BaseObject subclass. - -This module's class name begins with an underscore and should be ignored by -`all_objects` when `exclude_non_public_items` is True. -""" - -from skbase.base import BaseObject - - -class _PrivateThing(BaseObject): - """A non-public BaseObject subclass that should be ignored by discovery.""" - - def __init__(self): - super().__init__() - - -__all__ = ["_PrivateThing"] diff --git a/skbase/tests/mock_package/fixtures.py b/skbase/tests/mock_package/fixtures.py deleted file mode 100644 index 192ea42c..00000000 --- a/skbase/tests/mock_package/fixtures.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- -"""Additional fixture classes for the mock package used in lookup tests.""" -from typing import List - -from skbase.base import BaseObject - -__author__: List[str] = ["fkiraly", "RNKuhns"] - - -class Parent(BaseObject): - """Parent class to test tag inheritance and class filters.""" - - _tags = {"A": "1", "B": 2, "C": 1234, "3": "D"} - - def __init__(self, a="something", b=7, c=None): - self.a = a - self.b = b - self.c = c - super().__init__() - - def some_method(self): - pass - - -class Child(Parent): - """Child class that overrides some tags.""" - - _tags = {"A": 42, "3": "E"} - __author__ = ["fkiraly", "RNKuhns"] - - def some_method(self): - pass - - -class ClassWithABTrue(Parent): - """Child class that sets A, B tags to True.""" - - _tags = {"A": True, "B": True} - __author__ = ["fkiraly", "RNKuhns"] - - def some_method(self): - pass diff --git a/skbase/tests/mock_package/module_public.py b/skbase/tests/mock_package/module_public.py deleted file mode 100644 index cb0743a0..00000000 --- a/skbase/tests/mock_package/module_public.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -"""Public module in mock package with decorated and plain functions.""" - -from functools import wraps - - -def simple_function(x): - """A plain function for testing function discovery.""" - return x * 2 - - -def my_decorator(func): - @wraps(func) - def wrapper(*args, **kwargs): - return func(*args, **kwargs) - - return wrapper - - -@my_decorator -def decorated_function(y): - """A decorated function to ensure unwrapping works in member discovery.""" - return y + 1 - - -__all__ = ["simple_function", "decorated_function"] diff --git a/skbase/tests/mock_package/subpkg/module_b.py b/skbase/tests/mock_package/subpkg/module_b.py deleted file mode 100644 index cda14abe..00000000 --- a/skbase/tests/mock_package/subpkg/module_b.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -"""Module inside subpackage to test recursive discovery.""" - - -def subpkg_fn(): - """Simple function in subpackage module.""" - return "ok" - - -__all__ = ["subpkg_fn"] From cfc4d149963781658869a6c9561da5b946f3eb2d Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 22 Nov 2025 13:44:17 +0530 Subject: [PATCH 12/30] correcting test file names --- skbase/tests/mock_package/__init__.py | 10 +--- skbase/tests/mock_package/subpkg/__init__.py | 2 +- .../mock_package/subpkg/test_module_b.py | 10 ++++ skbase/tests/mock_package/test_fixtures.py | 46 +++++++++++++++++++ .../tests/mock_package/test_mock_package.py | 2 +- .../tests/mock_package/test_module_public.py | 26 +++++++++++ .../tests/mock_package/test_private_module.py | 18 ++++++++ 7 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 skbase/tests/mock_package/subpkg/test_module_b.py create mode 100644 skbase/tests/mock_package/test_fixtures.py create mode 100644 skbase/tests/mock_package/test_module_public.py create mode 100644 skbase/tests/mock_package/test_private_module.py diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index f22331fb..cb7806b6 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -5,7 +5,7 @@ """ from typing import List -from .fixtures import Child, ClassWithABTrue, Parent +from .test_fixtures import Child, ClassWithABTrue, Parent from .test_mock_package import ( MOCK_PACKAGE_OBJECTS, AnotherClass, @@ -23,14 +23,6 @@ "Parent", "Child", "ClassWithABTrue", - "CompositionDummy", - "InheritsFromBaseObject", - "AnotherClass", - "NotABaseObject", - "MOCK_PACKAGE_OBJECTS", - "Parent", - "Child", - "ClassWithABTrue", ] __author__: List[str] = ["fkiraly", "RNKuhns"] diff --git a/skbase/tests/mock_package/subpkg/__init__.py b/skbase/tests/mock_package/subpkg/__init__.py index e4385f99..2ad3b493 100644 --- a/skbase/tests/mock_package/subpkg/__init__.py +++ b/skbase/tests/mock_package/subpkg/__init__.py @@ -1,3 +1,3 @@ """Subpackage in mock package to test recursive walking.""" -__all__ = ["module_b"] +__all__ = ["test_module_b"] diff --git a/skbase/tests/mock_package/subpkg/test_module_b.py b/skbase/tests/mock_package/subpkg/test_module_b.py new file mode 100644 index 00000000..ec10b405 --- /dev/null +++ b/skbase/tests/mock_package/subpkg/test_module_b.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +"""Module inside subpackage to test recursive discovery.""" + + +def subpkg_fn(): + """Return the string "ok" to indicate functionality.""" + return "ok" + + +__all__ = ["subpkg_fn"] diff --git a/skbase/tests/mock_package/test_fixtures.py b/skbase/tests/mock_package/test_fixtures.py new file mode 100644 index 00000000..e4b209b4 --- /dev/null +++ b/skbase/tests/mock_package/test_fixtures.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +"""Additional fixture classes for the mock package used in lookup tests.""" +from typing import List + +from skbase.base import BaseObject + +__author__: List[str] = ["fkiraly", "RNKuhns"] + + +class Parent(BaseObject): + """Parent class to test tag inheritance and class filters.""" + + _tags = {"A": "1", "B": 2, "C": 1234, "3": "D"} + + def __init__(self, a="something", b=7, c=None): + """Initialize the fixture with simple attributes.""" + self.a = a + self.b = b + self.c = c + super().__init__() + + def some_method(self): + """Placeholder method used in tests.""" + pass + + +class Child(Parent): + """Child class that overrides some tags.""" + + _tags = {"A": 42, "3": "E"} + __author__ = ["fkiraly", "RNKuhns"] + + def some_method(self): + """Child placeholder method used in tests.""" + pass + + +class ClassWithABTrue(Parent): + """Child class that sets A and B tags to True.""" + + _tags = {"A": True, "B": True} + __author__ = ["fkiraly", "RNKuhns"] + + def some_method(self): + """Placeholder method used in tests.""" + pass diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index e05cdcb0..08240d2f 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -5,7 +5,7 @@ from skbase.base import BaseObject -from .fixtures import Child, ClassWithABTrue, Parent +from .test_fixtures import Child, ClassWithABTrue, Parent __all__: List[str] = [ "CompositionDummy", diff --git a/skbase/tests/mock_package/test_module_public.py b/skbase/tests/mock_package/test_module_public.py new file mode 100644 index 00000000..1d6a1a39 --- /dev/null +++ b/skbase/tests/mock_package/test_module_public.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +"""Public module in mock package with decorated and plain functions.""" + +from functools import wraps + + +def simple_function(x): + """Double the given input and return the result.""" + return x * 2 + + +def my_decorator(func): + @wraps(func) + def wrapper(*args, **kwargs): + return func(*args, **kwargs) + + return wrapper + + +@my_decorator +def decorated_function(y): + """Increment the given input by one and return the result.""" + return y + 1 + + +__all__ = ["simple_function", "decorated_function"] diff --git a/skbase/tests/mock_package/test_private_module.py b/skbase/tests/mock_package/test_private_module.py new file mode 100644 index 00000000..49d13e66 --- /dev/null +++ b/skbase/tests/mock_package/test_private_module.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +"""Non-public module in mock package; contains a non-public BaseObject subclass. + +This module's class name begins with an underscore and should be ignored by +`all_objects` when `exclude_non_public_items` is True. +""" + +from skbase.base import BaseObject + + +class _PrivateThing(BaseObject): + """A non-public BaseObject subclass that should be ignored by discovery.""" + + def __init__(self): + super().__init__() + + +__all__ = ["_PrivateThing"] From 6e009818a14d47b60f859009aa32ef1087b88b42 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Fri, 28 Nov 2025 15:03:31 +0530 Subject: [PATCH 13/30] fixing tags --- skbase/testing/test_all_objects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skbase/testing/test_all_objects.py b/skbase/testing/test_all_objects.py index 1bed605b..7574fb96 100644 --- a/skbase/testing/test_all_objects.py +++ b/skbase/testing/test_all_objects.py @@ -744,7 +744,7 @@ def test_object_tags(self, object_class): assert isinstance(tags, dict), msg assert len(tags) > 0, f"_tags dict of class {object_class} is empty" if self.valid_tags is None: - invalid_tags = tags + invalid_tags = [] else: invalid_tags = [ tag for tag in tags.keys() if tag not in self.valid_tags From 0174af9b5ad83550dc7c73b6dde36871e082a138 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Mon, 15 Dec 2025 21:19:42 +0530 Subject: [PATCH 14/30] Fix flake8 B043 error: use variable for delattr attribute name --- skbase/tests/test_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skbase/tests/test_base.py b/skbase/tests/test_base.py index 1a0a9436..2ccbed26 100644 --- a/skbase/tests/test_base.py +++ b/skbase/tests/test_base.py @@ -386,7 +386,8 @@ def test_set_tags_works_with_missing_tags_dynamic_attribute( ): """Test set_tags will still work if _tags_dynamic is missing.""" base_obj = deepcopy(fixture_tag_class_object) - delattr(base_obj, "_tags_dynamic") + attr_name = "_tags_dynamic" + delattr(base_obj, attr_name) # noqa: B009 assert not hasattr(base_obj, "_tags_dynamic") base_obj.set_tags(some_tag="something") tags = base_obj.get_tags() From cea639d6972b6a0a25b8ec904b6631c597fe092c Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Mon, 15 Dec 2025 21:28:11 +0530 Subject: [PATCH 15/30] Add arnavk23 (Arnav Kapoor) to contributors list --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8c6ffcde..0e40cbad 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -161,6 +161,16 @@ "code", "test" ] + }, + { + "login": "arnavk23", + "name": "Arnav Kapoor", + "avatar_url": "https://avatars.githubusercontent.com/u/arnavk23?v=4", + "profile": "https://github.com/arnavk23", + "contributions": [ + "code", + "test" + ] } ], "projectName": "skbase", From d36b14ada37913654608befed191eabfe88db51b Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sun, 23 Nov 2025 05:45:56 +0530 Subject: [PATCH 16/30] actual representation against the expected representation --- .../tests/test_object_html_repr.py | 50 +++++++++ skbase/lookup/tests/test_lookup.py | 106 ++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 skbase/base/_pretty_printing/tests/test_object_html_repr.py diff --git a/skbase/base/_pretty_printing/tests/test_object_html_repr.py b/skbase/base/_pretty_printing/tests/test_object_html_repr.py new file mode 100644 index 00000000..14976830 --- /dev/null +++ b/skbase/base/_pretty_printing/tests/test_object_html_repr.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +"""Tests for HTML representation of meta-objects (regression for #160/#163).""" + +from skbase.base import BaseObject +from skbase.base._meta import BaseMetaObject +from skbase.base._pretty_printing._object_html_repr import _object_html_repr + + +class ComponentDummy(BaseObject): + def __init__(self, a=1): + self.a = a + super().__init__() + + def __eq__(self, other): + """Equality for test helper: objects equal if same type and `a` equals. + + This silences static analysis warnings about adding attributes + without overriding `__eq__` and provides sensible equality for + test comparisons. We intentionally do not implement `__hash__` + because instances are mutable in tests. + """ + if not isinstance(other, ComponentDummy): + return NotImplemented + return getattr(self, "a", None) == getattr(other, "a", None) + + __hash__ = None + + +class MetaObjectForHtml(BaseMetaObject): + def __init__(self, steps=None): + self.steps = steps + super().__init__() + + +def test_meta_object_html_repr_does_not_raise(): + """Ensure HTML repr for a meta-object does not raise (regression test). + + This covers the failure case where displaying meta-objects as HTML used an + incorrect VisualBlock import and would crash. The function should return + an HTML string and not raise an exception. + """ + steps = [("comp", ComponentDummy(42))] + meta = MetaObjectForHtml(steps=steps) + + html_repr = _object_html_repr(meta) + + assert isinstance(html_repr, str) + # should include the class name and at least one html tag + assert meta.__class__.__name__ in html_repr + assert " Date: Mon, 15 Dec 2025 21:32:01 +0530 Subject: [PATCH 17/30] Fix test_get_package_metadata: remove imported classes from __all__ in mock_package modules Classes defined in test_fixtures.py should only appear in that module's metadata, not in __init__.py or test_mock_package.py where they're imported. Removed Parent, Child, ClassWithABTrue from __all__ lists to match the test's expectation that get_package_metadata only reports classes actually defined in each module (cls.__module__ == module.__name__). --- skbase/tests/mock_package/__init__.py | 7 ------- skbase/tests/mock_package/test_mock_package.py | 3 --- 2 files changed, 10 deletions(-) diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index cb7806b6..fbfbbd3e 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -15,14 +15,7 @@ ) __all__: List[str] = [ - "CompositionDummy", - "InheritsFromBaseObject", - "AnotherClass", - "NotABaseObject", "MOCK_PACKAGE_OBJECTS", - "Parent", - "Child", - "ClassWithABTrue", ] __author__: List[str] = ["fkiraly", "RNKuhns"] diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index 08240d2f..2591e867 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -12,9 +12,6 @@ "InheritsFromBaseObject", "AnotherClass", "NotABaseObject", - "Parent", - "Child", - "ClassWithABTrue", ] __author__: List[str] = ["fkiraly", "RNKuhns"] From 5467010b7cd975a8dce5556d7f4ccde74be9407e Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Mon, 15 Dec 2025 21:34:58 +0530 Subject: [PATCH 18/30] Fix flake8 F401: add noqa comments for re-exported classes in mock_package Classes are imported for re-export to maintain the module's public API but are intentionally not listed in __all__ to ensure get_package_metadata only reports classes defined in each module. --- skbase/tests/mock_package/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index fbfbbd3e..88f1a083 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -5,14 +5,14 @@ """ from typing import List -from .test_fixtures import Child, ClassWithABTrue, Parent -from .test_mock_package import ( - MOCK_PACKAGE_OBJECTS, - AnotherClass, - CompositionDummy, - InheritsFromBaseObject, - NotABaseObject, -) +from .test_fixtures import Child # noqa: F401 +from .test_fixtures import ClassWithABTrue # noqa: F401 +from .test_fixtures import Parent # noqa: F401 +from .test_mock_package import AnotherClass # noqa: F401 +from .test_mock_package import CompositionDummy # noqa: F401 +from .test_mock_package import InheritsFromBaseObject # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_OBJECTS # noqa: F401 +from .test_mock_package import NotABaseObject # noqa: F401 __all__: List[str] = [ "MOCK_PACKAGE_OBJECTS", From 3a45ea6222c4485f293b947b67015185f7db9f22 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 16:05:26 +0000 Subject: [PATCH 19/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- skbase/tests/mock_package/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index 88f1a083..2353417f 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -8,10 +8,10 @@ from .test_fixtures import Child # noqa: F401 from .test_fixtures import ClassWithABTrue # noqa: F401 from .test_fixtures import Parent # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_OBJECTS # noqa: F401 from .test_mock_package import AnotherClass # noqa: F401 from .test_mock_package import CompositionDummy # noqa: F401 from .test_mock_package import InheritsFromBaseObject # noqa: F401 -from .test_mock_package import MOCK_PACKAGE_OBJECTS # noqa: F401 from .test_mock_package import NotABaseObject # noqa: F401 __all__: List[str] = [ From fac3d04673ebfb9e33eba6e2d933b89a10e1d2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Sun, 4 Jan 2026 00:43:52 +0100 Subject: [PATCH 20/30] Update test_base.py --- skbase/tests/test_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skbase/tests/test_base.py b/skbase/tests/test_base.py index 91af2635..097dcc16 100644 --- a/skbase/tests/test_base.py +++ b/skbase/tests/test_base.py @@ -386,7 +386,8 @@ def test_set_tags_works_with_missing_tags_dynamic_attribute( ): """Test set_tags will still work if _tags_dynamic is missing.""" base_obj = deepcopy(fixture_tag_class_object) - delattr(base_obj, "_tags_dynamic") # noqa: B043 + attr_name = "_tags_dynamic" + delattr(base_obj, attr_name) # noqa assert not hasattr(base_obj, "_tags_dynamic") base_obj.set_tags(some_tag="something") tags = base_obj.get_tags() From 36e61c32d370d3d2a1f5dbb8dbfabe3956ca4b38 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:10:29 +0000 Subject: [PATCH 21/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- skbase/tests/mock_package/test_fixtures.py | 1 + 1 file changed, 1 insertion(+) diff --git a/skbase/tests/mock_package/test_fixtures.py b/skbase/tests/mock_package/test_fixtures.py index e4b209b4..23a618ca 100644 --- a/skbase/tests/mock_package/test_fixtures.py +++ b/skbase/tests/mock_package/test_fixtures.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- """Additional fixture classes for the mock package used in lookup tests.""" + from typing import List from skbase.base import BaseObject From c86f4e4e6cec6d050b63f21243e49c947dd0c47c Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 14 Feb 2026 12:56:51 +0530 Subject: [PATCH 22/30] removal of tests that are not relevant to the lookup tests, and to restrict the lookup tests to only those that are relevant to the issue at hand. --- skbase/lookup/tests/test_lookup.py | 100 ------------ skbase/tests/conftest.py | 234 ----------------------------- 2 files changed, 334 deletions(-) diff --git a/skbase/lookup/tests/test_lookup.py b/skbase/lookup/tests/test_lookup.py index ebe209ee..ec33e089 100644 --- a/skbase/lookup/tests/test_lookup.py +++ b/skbase/lookup/tests/test_lookup.py @@ -31,11 +31,7 @@ ) from skbase.tests.conftest import ( SKBASE_BASE_CLASSES, - SKBASE_CLASSES_BY_MODULE, - SKBASE_FUNCTIONS_BY_MODULE, SKBASE_MODULES, - SKBASE_PUBLIC_CLASSES_BY_MODULE, - SKBASE_PUBLIC_FUNCTIONS_BY_MODULE, SKBASE_PUBLIC_MODULES, ) from skbase.tests.mock_package import ( @@ -715,102 +711,6 @@ def test_get_package_metadata_tag_filter(tag_filter): assert len(unfiltered_classes) > len(filtered_classes) -@pytest.mark.parametrize("exclude_non_public_modules", [True, False]) -@pytest.mark.parametrize("exclude_non_public_items", [True, False]) -def test_get_package_metadata_returns_expected_results( - exclude_non_public_modules, exclude_non_public_items -): - """Test that get_package_metadata_returns expected results using skbase.""" - results = get_package_metadata( - "skbase", - exclude_non_public_items=exclude_non_public_items, - exclude_non_public_modules=exclude_non_public_modules, - package_base_classes=SKBASE_BASE_CLASSES, - modules_to_ignore="tests", - classes_to_exclude=TagAliaserMixin, - suppress_import_stdout=False, - ) - public_modules_excluding_tests = [ - module - for module in SKBASE_PUBLIC_MODULES - if not _is_ignored_module(module, modules_to_ignore="tests") - ] - modules_excluding_tests = [ - module - for module in SKBASE_MODULES - if not _is_ignored_module(module, modules_to_ignore="tests") - ] - if exclude_non_public_modules: - assert tuple(results.keys()) == tuple(public_modules_excluding_tests) - else: - assert tuple(results.keys()) == tuple(modules_excluding_tests) - - for module in results: - if exclude_non_public_items: - module_funcs = SKBASE_PUBLIC_FUNCTIONS_BY_MODULE.get(module, ()) - module_classes = SKBASE_PUBLIC_CLASSES_BY_MODULE.get(module, ()) - which_str = "public" - fun_str = "SKBASE_PUBLIC_FUNCTIONS_BY_MODULE" - cls_str = "SKBASE_PUBLIC_CLASSES_BY_MODULE" - else: - module_funcs = SKBASE_FUNCTIONS_BY_MODULE.get(module, ()) - module_classes = SKBASE_CLASSES_BY_MODULE.get(module, ()) - which_str = "all" - fun_str = "SKBASE_FUNCTIONS_BY_MODULE" - cls_str = "SKBASE_CLASSES_BY_MODULE" - - # Verify expected functions are returned - retrieved_funcs = set(results[module]["functions"].keys()) - expected_funcs = set(module_funcs) - - if retrieved_funcs != expected_funcs: - msg = ( - "When using get_package_metadata utility, retrieved objects " - f"for {which_str} functions in module {module} do not match expected. " - f"Expected: {expected_funcs}; " - f"retrieved: {retrieved_funcs}. " - f"Expected functions are stored in {fun_str}, in test_lookup." - ) - raise AssertionError(msg) - - # Verify expected classes are returned - retrieved_cls = set(results[module]["classes"].keys()) - expected_cls = set(module_classes) - - if retrieved_cls != expected_cls: - msg = ( - "When using get_package_metadata utility, retrieved objects " - f"for {which_str} classes in module {module} do not match expected. " - f"Expected: {expected_cls}; " - f"retrieved: {retrieved_cls}. " - f"Expected functions are stored in {cls_str}, in test_lookup." - ) - raise AssertionError(msg) - - # Verify class metadata attributes correct - for klass, klass_metadata in results[module]["classes"].items(): - if klass_metadata["klass"] in SKBASE_BASE_CLASSES: - assert ( - klass_metadata["is_base_class"] is True - ), f"{klass} should be base class." - else: - assert ( - klass_metadata["is_base_class"] is False - ), f"{klass} should not be base class." - - if issubclass(klass_metadata["klass"], BaseObject): - assert klass_metadata["is_base_object"] is True - else: - assert klass_metadata["is_base_object"] is False - - if ( - issubclass(klass_metadata["klass"], SKBASE_BASE_CLASSES) - and klass_metadata["klass"] not in SKBASE_BASE_CLASSES - ): - assert klass_metadata["is_concrete_implementation"] is True - else: - assert klass_metadata["is_concrete_implementation"] is False - def test_get_return_tags(): """Test _get_return_tags returns expected.""" diff --git a/skbase/tests/conftest.py b/skbase/tests/conftest.py index dec1b79b..206acf10 100644 --- a/skbase/tests/conftest.py +++ b/skbase/tests/conftest.py @@ -9,10 +9,6 @@ "SKBASE_BASE_CLASSES", "SKBASE_MODULES", "SKBASE_PUBLIC_MODULES", - "SKBASE_PUBLIC_CLASSES_BY_MODULE", - "SKBASE_CLASSES_BY_MODULE", - "SKBASE_PUBLIC_FUNCTIONS_BY_MODULE", - "SKBASE_FUNCTIONS_BY_MODULE", ] __author__: List[str] = ["fkiraly", "RNKuhns"] @@ -96,236 +92,6 @@ "skbase.utils.stdout_mute", "skbase.validate", ) -SKBASE_PUBLIC_CLASSES_BY_MODULE = { - "skbase._exceptions": ("FixtureGenerationError", "NotFittedError"), - "skbase.base": ( - "BaseEstimator", - "BaseMetaEstimator", - "BaseMetaEstimatorMixin", - "BaseMetaObject", - "BaseMetaObjectMixin", - "BaseObject", - ), - "skbase.base._base": ("BaseEstimator", "BaseObject"), - "skbase.base._clone_plugins": ("BaseCloner",), - "skbase.base._meta": ( - "BaseMetaObject", - "BaseMetaObjectMixin", - "BaseMetaEstimator", - "BaseMetaEstimatorMixin", - ), - "skbase.base._pretty_printing._pprint": ("KeyValTuple", "KeyValTupleParam"), - "skbase.lookup._lookup": ("StdoutMuteNCatchMNF",), - "skbase.testing": ("BaseFixtureGenerator", "QuickTester", "TestAllObjects"), - "skbase.testing.test_all_objects": ( - "BaseFixtureGenerator", - "QuickTester", - "TestAllObjects", - ), - "skbase.utils.dependencies._import": IMPORT_CLS, - "skbase.utils.stderr_mute": ("StderrMute",), - "skbase.utils.stdout_mute": ("StdoutMute",), -} -SKBASE_CLASSES_BY_MODULE = SKBASE_PUBLIC_CLASSES_BY_MODULE.copy() -SKBASE_CLASSES_BY_MODULE.update( - { - "skbase.base._clone_plugins": ( - "BaseCloner", - "_CloneClass", - "_CloneSkbase", - "_CloneSklearn", - "_CloneDict", - "_CloneListTupleSet", - "_CloneGetParams", - "_CloneCatchAll", - ), - "skbase.base._meta": ( - "BaseMetaObject", - "BaseMetaObjectMixin", - "BaseMetaEstimator", - "BaseMetaEstimatorMixin", - "_MetaObjectMixin", - "_MetaTagLogicMixin", - ), - "skbase.base._pretty_printing._object_html_repr": ("_VisualBlock",), - "skbase.base._pretty_printing._pprint": ( - "KeyValTuple", - "KeyValTupleParam", - "_BaseObjectPrettyPrinter", - ), - "skbase.base._tagmanager": ("_FlagManager",), - } -) -SKBASE_PUBLIC_FUNCTIONS_BY_MODULE = { - "skbase.lookup": ("all_objects", "get_package_metadata"), - "skbase.lookup._lookup": ("all_objects", "get_package_metadata"), - "skbase.testing.utils._conditional_fixtures": ( - "create_conditional_fixtures_and_names", - ), - "skbase.validate": ( - "check_sequence_named_objects", - "check_sequence", - "check_type", - "is_named_object_tuple", - "is_sequence", - "is_sequence_named_objects", - ), - "skbase.validate._named_objects": ( - "check_sequence_named_objects", - "is_named_object_tuple", - "is_sequence_named_objects", - ), - "skbase.utils": ( - "check_random_state", - "deep_equals", - "git_diff", - "flatten", - "is_flat", - "make_strings_unique", - "sample_dependent_seed", - "set_random_state", - "subset_dict_keys", - "unflat_len", - "unflatten", - ), - "skbase.utils._iter": ("make_strings_unique",), - "skbase.utils._nested_iter": ( - "flatten", - "is_flat", - "unflat_len", - "unflatten", - ), - "skbase.utils._utils": ("subset_dict_keys",), - "skbase.utils.deep_equals": ("deep_equals",), - "skbase.utils.deep_equals._deep_equals": ("deep_equals", "deep_equals_custom"), - "skbase.utils.doctest_run": ("run_doctest",), - "skbase.utils.git_diff": ("git_diff",), - "skbase.utils.random_state": ( - "check_random_state", - "sample_dependent_seed", - "set_random_state", - ), - "skbase.validate._types": ("check_sequence", "check_type", "is_sequence"), -} -SKBASE_FUNCTIONS_BY_MODULE = SKBASE_PUBLIC_FUNCTIONS_BY_MODULE.copy() -SKBASE_FUNCTIONS_BY_MODULE.update( - { - "skbase.base._clone_base": {"_check_clone", "_clone"}, - "skbase.base._clone_plugins": ( - "_default_clone", - "_get_sklearn_clone", - "_is_sklearn_present", - ), - "skbase.base._pretty_printing._object_html_repr": ( - "_get_visual_block", - "_object_html_repr", - "_write_base_object_html", - "_write_label_html", - ), - "skbase.base._pretty_printing._pprint": ("_changed_params", "_safe_repr"), - "skbase.lookup._lookup": ( - "all_objects", - "get_package_metadata", - "_check_object_types", - "_coerce_to_tuple", - "_determine_module_path", - "_filter_by_tags", - "_filter_by_class", - "_get_members_uw", - "_get_module_info", - "_get_return_tags", - "_import_module", - "_is_ignored_module", - "_is_non_public_module", - "_make_dataframe", - "_walk", - "_walk_and_retrieve_all_objs", - ), - "skbase.testing.utils.inspect": ("_get_args",), - "skbase.utils._check": ("_is_scalar_nan",), - "skbase.utils.dependencies": ( - "_check_soft_dependencies", - "_check_python_version", - "_check_estimator_deps", - "_safe_import", - ), - "skbase.utils.dependencies._import": ("_safe_import", "_create_mock_class"), - "skbase.utils._iter": ( - "_format_seq_to_str", - "_remove_type_text", - "_scalar_to_seq", - "make_strings_unique", - ), - "skbase.utils._nested_iter": ( - "flatten", - "is_flat", - "_remove_single", - "unflat_len", - "unflatten", - ), - "skbase.utils._utils": ("subset_dict_keys",), - "skbase.utils.deep_equals": ("deep_equals",), - "skbase.utils.deep_equals._common": ("_make_ret", "_ret"), - "skbase.utils.deep_equals._deep_equals": ( - "_coerce_list", - "_dict_equals", - "_fh_equals_plugin", - "_is_npnan", - "_is_npndarray", - "_is_pandas", - "_jax_equals_plugin", - "_numpy_equals_plugin", - "_pandas_equals", - "_pandas_equals_plugin", - "_safe_any_unequal", - "_safe_len", - "_softdep_available", - "_tuple_equals", - "deep_equals", - "deep_equals_custom", - ), - "skbase.utils.git_diff": ( - "_get_packages_with_changed_specs", - "git_diff", - "_get_packages_with_changed_specs_list", - "_get_module_from_class", - "_get_path_from_module", - "_get_changed_lines", - "_run_git_diff", - "_is_module_changed", - "_is_class_changed", - ), - "skbase.utils.dependencies._dependencies": ( - "_check_env_marker", - "_check_estimator_deps", - "_check_python_version", - "_check_soft_dependencies", - "_get_pkg_version", - "_get_installed_packages", - "_get_installed_packages_private", - "_normalize_requirement", - "_normalize_version", - "_raise_at_severity", - ), - "skbase.utils.random_state": ( - "check_random_state", - "sample_dependent_seed", - "set_random_state", - ), - "skbase.validate._named_objects": ( - "check_sequence_named_objects", - "is_named_object_tuple", - "is_sequence_named_objects", - "_named_baseobject_error_msg", - ), - "skbase.validate._types": ( - "check_sequence", - "check_type", - "is_sequence", - "_convert_scalar_seq_type_input_to_tuple", - ), - } -) # Fixture class for testing tag system From 3b74e8687c2d3580f3f34445986d7ca99b96bd7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Feb 2026 07:27:50 +0000 Subject: [PATCH 23/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- skbase/lookup/tests/test_lookup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/skbase/lookup/tests/test_lookup.py b/skbase/lookup/tests/test_lookup.py index ec33e089..05ee8599 100644 --- a/skbase/lookup/tests/test_lookup.py +++ b/skbase/lookup/tests/test_lookup.py @@ -711,7 +711,6 @@ def test_get_package_metadata_tag_filter(tag_filter): assert len(unfiltered_classes) > len(filtered_classes) - def test_get_return_tags(): """Test _get_return_tags returns expected.""" From 46e0a8b23b7a4bfbda9a2fc79409783387958e54 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Sat, 14 Feb 2026 17:24:48 +0530 Subject: [PATCH 24/30] flake8 --- skbase/lookup/tests/test_lookup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/skbase/lookup/tests/test_lookup.py b/skbase/lookup/tests/test_lookup.py index 05ee8599..6a4b3829 100644 --- a/skbase/lookup/tests/test_lookup.py +++ b/skbase/lookup/tests/test_lookup.py @@ -31,8 +31,6 @@ ) from skbase.tests.conftest import ( SKBASE_BASE_CLASSES, - SKBASE_MODULES, - SKBASE_PUBLIC_MODULES, ) from skbase.tests.mock_package import ( MOCK_PACKAGE_OBJECTS, From e3e889eae93a6b9b9c70afc28525ab9fe3aa0d55 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Fri, 6 Mar 2026 09:01:34 +0530 Subject: [PATCH 25/30] Update test_lookup.py --- skbase/tests/test_lookup.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/skbase/tests/test_lookup.py b/skbase/tests/test_lookup.py index f7d927a7..bb985b10 100644 --- a/skbase/tests/test_lookup.py +++ b/skbase/tests/test_lookup.py @@ -33,32 +33,3 @@ def test_all_objects_returns_class_name_for_alias(tmp_path, monkeypatch): sys.modules.pop(f"{pkg_name}.module", None) sys.modules.pop(pkg_name, None) - - -def test_all_objects_filter_tags_returns_matches(tmp_path, monkeypatch): - """Test that all_objects honors the filter_tags argument. - - Ensure the function returns matching classes when a tag is provided. - """ - pkg_name = "pkg_tag_case" - root = tmp_path / pkg_name - root.mkdir() - - (root / "__init__.py").write_text( - "from .module import MyClass\n" "__all__ = ['MyClass']\n" - ) - (root / "module.py").write_text( - "from skbase.base import BaseObject\n\n" - "class MyClass(BaseObject):\n" - " _tags = {'special_tag': True}\n" - ) - monkeypatch.syspath_prepend(str(tmp_path)) - importlib.invalidate_caches() - - objs = all_objects(package_name=pkg_name, path=str(root), filter_tags="special_tag") - assert len(objs) == 1 - name, klass = objs[0] - assert name == klass.__name__ == "MyClass" - - sys.modules.pop(f"{pkg_name}.module", None) - sys.modules.pop(pkg_name, None) From acc90cda47200f770b78a104b695fb0d710c6342 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Fri, 6 Mar 2026 09:03:00 +0530 Subject: [PATCH 26/30] Update .all-contributorsrc --- .all-contributorsrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index c7c9c8b5..f3f37cfd 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -168,6 +168,11 @@ "avatar_url": "https://avatars.githubusercontent.com/u/arnavk23?v=4", "profile": "https://github.com/arnavk23", "contributions": [ + "bug", + "code", + "test" + ] + }, "login": "RecreationalMath", "name": "Nirbhai Singh", "avatar_url": "https://avatars.githubusercontent.com/u/6928297?v=4", From 188b76a026e6df18154e5dde88deebc89eea68fb Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Fri, 6 Mar 2026 10:50:46 +0530 Subject: [PATCH 27/30] adding changes --- skbase/lookup/tests/test_lookup.py | 103 ++++++++++++++++++ skbase/tests/mock_package/__init__.py | 12 ++ .../tests/mock_package/test_mock_package.py | 67 ++++++++++++ 3 files changed, 182 insertions(+) diff --git a/skbase/lookup/tests/test_lookup.py b/skbase/lookup/tests/test_lookup.py index 6a4b3829..feb63535 100644 --- a/skbase/lookup/tests/test_lookup.py +++ b/skbase/lookup/tests/test_lookup.py @@ -33,7 +33,13 @@ SKBASE_BASE_CLASSES, ) from skbase.tests.mock_package import ( + MOCK_PACKAGE_CLASSES_BY_MODULE, + MOCK_PACKAGE_FUNCTIONS_BY_MODULE, + MOCK_PACKAGE_MODULES, MOCK_PACKAGE_OBJECTS, + MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE, + MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE, + MOCK_PACKAGE_PUBLIC_MODULES, ClassWithABTrue, CompositionDummy, NotABaseObject, @@ -735,6 +741,103 @@ def _test_get_return_tags_output(results, num_requested_tags): assert _test_get_return_tags_output(results, len(tag_names)) and results[0] is None +@pytest.mark.parametrize("exclude_non_public_modules", [True, False]) +@pytest.mark.parametrize("exclude_non_public_items", [True, False]) +def test_get_package_metadata_returns_expected_results_mock_package( + exclude_non_public_modules, exclude_non_public_items +): + """Test that get_package_metadata returns expected results for mock package. + + This test validates the lookup retrieval against configuration constants + that define the expected classes and functions for each module in the + mock package, checking both public and non-public items. + """ + results = get_package_metadata( + "skbase.tests.mock_package", + exclude_non_public_items=exclude_non_public_items, + exclude_non_public_modules=exclude_non_public_modules, + package_base_classes=SKBASE_BASE_CLASSES, + modules_to_ignore=None, + suppress_import_stdout=True, + ) + + # Determine which modules to expect based on parameters + if exclude_non_public_modules: + expected_modules = MOCK_PACKAGE_PUBLIC_MODULES + else: + expected_modules = MOCK_PACKAGE_MODULES + + # Verify we got the expected modules + assert set(results.keys()) == set(expected_modules) + + # Verify each module has the expected classes and functions + for module in results: + if exclude_non_public_items: + module_funcs = MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE.get(module, ()) + module_classes = MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE.get(module, ()) + which_str = "public" + fun_str = "MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE" + cls_str = "MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE" + else: + module_funcs = MOCK_PACKAGE_FUNCTIONS_BY_MODULE.get(module, ()) + module_classes = MOCK_PACKAGE_CLASSES_BY_MODULE.get(module, ()) + which_str = "all" + fun_str = "MOCK_PACKAGE_FUNCTIONS_BY_MODULE" + cls_str = "MOCK_PACKAGE_CLASSES_BY_MODULE" + + # Verify expected functions are returned + retrieved_funcs = set(results[module]["functions"].keys()) + expected_funcs = set(module_funcs) + + if retrieved_funcs != expected_funcs: + msg = ( + "When using get_package_metadata utility, retrieved objects " + f"for {which_str} functions in module {module} do not match expected. " + f"Expected: {expected_funcs}; " + f"retrieved: {retrieved_funcs}. " + f"Expected functions are stored in {fun_str}, in mock_package." + ) + raise AssertionError(msg) + + # Verify expected classes are returned + retrieved_cls = set(results[module]["classes"].keys()) + expected_cls = set(module_classes) + + if retrieved_cls != expected_cls: + msg = ( + "When using get_package_metadata utility, retrieved objects " + f"for {which_str} classes in module {module} do not match expected. " + f"Expected: {expected_cls}; " + f"retrieved: {retrieved_cls}. " + f"Expected classes are stored in {cls_str}, in mock_package." + ) + raise AssertionError(msg) + + # Verify class metadata attributes are correct + for klass, klass_metadata in results[module]["classes"].items(): + if klass_metadata["klass"] in SKBASE_BASE_CLASSES: + assert ( + klass_metadata["is_base_class"] is True + ), f"{klass} should be base class." + else: + assert ( + klass_metadata["is_base_class"] is False + ), f"{klass} should not be base class." + + if issubclass(klass_metadata["klass"], BaseObject): + assert klass_metadata["is_base_object"] is True + else: + assert klass_metadata["is_base_object"] is False + + if ( + issubclass(klass_metadata["klass"], SKBASE_BASE_CLASSES) + and klass_metadata["klass"] not in SKBASE_BASE_CLASSES + ): + assert klass_metadata["is_concrete_implementation"] is True + else: + assert klass_metadata["is_concrete_implementation"] is False + + def test_get_package_metadata_matches_expected_representation_mock_package(): """Verify get_package_metadata returns the expected representation for the controlled `skbase.tests.mock_package` mock package. diff --git a/skbase/tests/mock_package/__init__.py b/skbase/tests/mock_package/__init__.py index 9b158b9f..a8bc0c67 100644 --- a/skbase/tests/mock_package/__init__.py +++ b/skbase/tests/mock_package/__init__.py @@ -6,7 +6,13 @@ from .test_fixtures import Child # noqa: F401 from .test_fixtures import ClassWithABTrue # noqa: F401 from .test_fixtures import Parent # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_CLASSES_BY_MODULE # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_FUNCTIONS_BY_MODULE # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_MODULES # noqa: F401 from .test_mock_package import MOCK_PACKAGE_OBJECTS # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE # noqa: F401 +from .test_mock_package import MOCK_PACKAGE_PUBLIC_MODULES # noqa: F401 from .test_mock_package import AnotherClass # noqa: F401 from .test_mock_package import CompositionDummy # noqa: F401 from .test_mock_package import InheritsFromBaseObject # noqa: F401 @@ -14,6 +20,12 @@ __all__: List[str] = [ "MOCK_PACKAGE_OBJECTS", + "MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE", + "MOCK_PACKAGE_CLASSES_BY_MODULE", + "MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE", + "MOCK_PACKAGE_FUNCTIONS_BY_MODULE", + "MOCK_PACKAGE_PUBLIC_MODULES", + "MOCK_PACKAGE_MODULES", ] __author__: List[str] = ["fkiraly", "RNKuhns"] diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index 500c16bf..1ea55b91 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -78,3 +78,70 @@ class _NonPublicClass(BaseObject): Child, ClassWithABTrue, ] + +# Expected public classes by module for validation +MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE = { + "skbase.tests.mock_package.test_mock_package": ( + "AnotherClass", + "CompositionDummy", + "InheritsFromBaseObject", + "NotABaseObject", + ), + "skbase.tests.mock_package.test_fixtures": ( + "Child", + "ClassWithABTrue", + "Parent", + ), +} + +# Expected all classes by module (including non-public) for validation +MOCK_PACKAGE_CLASSES_BY_MODULE = { + "skbase.tests.mock_package.test_mock_package": ( + "AnotherClass", + "CompositionDummy", + "InheritsFromBaseObject", + "NotABaseObject", + "_NonPublicClass", + ), + "skbase.tests.mock_package.test_fixtures": ( + "Child", + "ClassWithABTrue", + "Parent", + ), + "skbase.tests.mock_package.test_private_module": ("_PrivateThing",), +} + +# Expected public functions by module for validation +MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE = { + "skbase.tests.mock_package.test_module_public": ( + "decorated_function", + "my_decorator", + "simple_function", + ), + "skbase.tests.mock_package.subpkg.test_module_b": ("subpkg_fn",), +} + +# Expected all functions by module (including non-public) for validation +MOCK_PACKAGE_FUNCTIONS_BY_MODULE = { + "skbase.tests.mock_package.test_module_public": ( + "decorated_function", + "my_decorator", + "simple_function", + ), + "skbase.tests.mock_package.subpkg.test_module_b": ("subpkg_fn",), +} + +# List of all public modules in mock package +MOCK_PACKAGE_PUBLIC_MODULES = ( + "skbase.tests.mock_package", + "skbase.tests.mock_package.subpkg", + "skbase.tests.mock_package.subpkg.test_module_b", + "skbase.tests.mock_package.test_fixtures", + "skbase.tests.mock_package.test_mock_package", + "skbase.tests.mock_package.test_module_public", + "skbase.tests.mock_package.test_private_module", +) + +# List of all modules (including non-public) in mock package +# Since no modules have names starting with _, all are considered public +MOCK_PACKAGE_MODULES = MOCK_PACKAGE_PUBLIC_MODULES From bd77634866ce4068daa243b8d4f4f03d5c4ba25f Mon Sep 17 00:00:00 2001 From: arnavk23 Date: Mon, 20 Apr 2026 01:13:22 +0530 Subject: [PATCH 28/30] added private class and function to mock package and added tests for them. Also added a test for the lookup function to check that it does not return private members. --- skbase/tests/conftest.py | 81 ------------------- skbase/tests/mock_package/_private_module.py | 30 +++++++ .../tests/mock_package/test_mock_package.py | 25 +++++- .../tests/mock_package/test_module_public.py | 5 ++ 4 files changed, 58 insertions(+), 83 deletions(-) create mode 100644 skbase/tests/mock_package/_private_module.py diff --git a/skbase/tests/conftest.py b/skbase/tests/conftest.py index caf5e6fd..cd9145e8 100644 --- a/skbase/tests/conftest.py +++ b/skbase/tests/conftest.py @@ -7,91 +7,10 @@ __all__: List[str] = [ "SKBASE_BASE_CLASSES", - "SKBASE_MODULES", - "SKBASE_PUBLIC_MODULES", ] __author__: List[str] = ["fkiraly", "RNKuhns"] -# bug 442 fixed: metaclasses now discovered correctly on all Python versions -IMPORT_CLS = ("CommonMagicMeta", "MagicAttribute") - SKBASE_BASE_CLASSES = (BaseObject, BaseEstimator) -SKBASE_MODULES = ( - "skbase", - "skbase._exceptions", - "skbase._nopytest_tests", - "skbase.base", - "skbase.base._base", - "skbase.base._clone_base", - "skbase.base._clone_plugins", - "skbase.base._meta", - "skbase.base._pretty_printing", - "skbase.base._pretty_printing._object_html_repr", - "skbase.base._pretty_printing._pprint", - "skbase.base._tagmanager", - "skbase.lookup", - "skbase.lookup.tests", - "skbase.lookup.tests.test_lookup", - "skbase.lookup._lookup", - "skbase.testing", - "skbase.testing.test_all_objects", - "skbase.testing.utils", - "skbase.testing.utils._conditional_fixtures", - "skbase.testing.utils.inspect", - "skbase.testing.utils.tests", - "skbase.testing.utils.tests.test_deep_equals", - "skbase.tests", - "skbase.tests.conftest", - "skbase.tests.test_base", - "skbase.tests.test_baseestimator", - "skbase.tests.mock_package.test_mock_package", - "skbase.utils", - "skbase.utils._check", - "skbase.utils._iter", - "skbase.utils._nested_iter", - "skbase.utils._utils", - "skbase.utils.deep_equals", - "skbase.utils.deep_equals._common", - "skbase.utils.deep_equals._deep_equals", - "skbase.utils.dependencies", - "skbase.utils.dependencies._dependencies", - "skbase.utils.dependencies._import", - "skbase.utils.doctest_run", - "skbase.utils.git_diff", - "skbase.utils.random_state", - "skbase.utils.stderr_mute", - "skbase.utils.stdout_mute", - "skbase.validate", - "skbase.validate._named_objects", - "skbase.validate._type_checks", -) -SKBASE_PUBLIC_MODULES = ( - "skbase", - "skbase.base", - "skbase.lookup", - "skbase.lookup.tests", - "skbase.lookup.tests.test_lookup", - "skbase.testing", - "skbase.testing.test_all_objects", - "skbase.testing.utils", - "skbase.testing.utils.inspect", - "skbase.testing.utils.tests", - "skbase.testing.utils.tests.test_deep_equals", - "skbase.tests", - "skbase.tests.conftest", - "skbase.tests.test_base", - "skbase.tests.test_baseestimator", - "skbase.tests.mock_package.test_mock_package", - "skbase.utils", - "skbase.utils.deep_equals", - "skbase.utils.dependencies", - "skbase.utils.doctest_run", - "skbase.utils.git_diff", - "skbase.utils.random_state", - "skbase.utils.stderr_mute", - "skbase.utils.stdout_mute", - "skbase.validate", -) # Fixture class for testing tag system diff --git a/skbase/tests/mock_package/_private_module.py b/skbase/tests/mock_package/_private_module.py new file mode 100644 index 00000000..22ac3e9b --- /dev/null +++ b/skbase/tests/mock_package/_private_module.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +"""Private module in mock package for lookup non-public coverage.""" + +from skbase.base import BaseObject + + +class PrivateModuleClass(BaseObject): + """Publicly named class living in a private module.""" + + +class _PrivateModuleHiddenClass(BaseObject): + """Non-public class living in a private module.""" + + +def private_module_public_function(): + """Function with public name in a private module.""" + return "visible-only-when-non-public-modules-included" + + +def _private_module_hidden_function(): + """Function with private name in a private module.""" + return "visible-only-when-non-public-items-included" + + +__all__ = [ + "PrivateModuleClass", + "_PrivateModuleHiddenClass", + "private_module_public_function", + "_private_module_hidden_function", +] \ No newline at end of file diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index 1ea55b91..0a14d2d4 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -81,6 +81,7 @@ class _NonPublicClass(BaseObject): # Expected public classes by module for validation MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE = { + "skbase.tests.mock_package._private_module": ("PrivateModuleClass",), "skbase.tests.mock_package.test_mock_package": ( "AnotherClass", "CompositionDummy", @@ -96,6 +97,10 @@ class _NonPublicClass(BaseObject): # Expected all classes by module (including non-public) for validation MOCK_PACKAGE_CLASSES_BY_MODULE = { + "skbase.tests.mock_package._private_module": ( + "PrivateModuleClass", + "_PrivateModuleHiddenClass", + ), "skbase.tests.mock_package.test_mock_package": ( "AnotherClass", "CompositionDummy", @@ -113,6 +118,9 @@ class _NonPublicClass(BaseObject): # Expected public functions by module for validation MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE = { + "skbase.tests.mock_package._private_module": ( + "private_module_public_function", + ), "skbase.tests.mock_package.test_module_public": ( "decorated_function", "my_decorator", @@ -123,8 +131,13 @@ class _NonPublicClass(BaseObject): # Expected all functions by module (including non-public) for validation MOCK_PACKAGE_FUNCTIONS_BY_MODULE = { + "skbase.tests.mock_package._private_module": ( + "private_module_public_function", + "_private_module_hidden_function", + ), "skbase.tests.mock_package.test_module_public": ( "decorated_function", + "_private_helper", "my_decorator", "simple_function", ), @@ -143,5 +156,13 @@ class _NonPublicClass(BaseObject): ) # List of all modules (including non-public) in mock package -# Since no modules have names starting with _, all are considered public -MOCK_PACKAGE_MODULES = MOCK_PACKAGE_PUBLIC_MODULES +MOCK_PACKAGE_MODULES = ( + "skbase.tests.mock_package", + "skbase.tests.mock_package._private_module", + "skbase.tests.mock_package.subpkg", + "skbase.tests.mock_package.subpkg.test_module_b", + "skbase.tests.mock_package.test_fixtures", + "skbase.tests.mock_package.test_mock_package", + "skbase.tests.mock_package.test_module_public", + "skbase.tests.mock_package.test_private_module", +) diff --git a/skbase/tests/mock_package/test_module_public.py b/skbase/tests/mock_package/test_module_public.py index 1d6a1a39..a352fd0c 100644 --- a/skbase/tests/mock_package/test_module_public.py +++ b/skbase/tests/mock_package/test_module_public.py @@ -23,4 +23,9 @@ def decorated_function(y): return y + 1 +def _private_helper(z): + """Private helper to exercise non-public function filtering.""" + return z - 1 + + __all__ = ["simple_function", "decorated_function"] From b675afad832eb35e59464678b361a9942cee455b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 19:44:51 +0000 Subject: [PATCH 29/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- skbase/tests/mock_package/_private_module.py | 2 +- skbase/tests/mock_package/test_mock_package.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/skbase/tests/mock_package/_private_module.py b/skbase/tests/mock_package/_private_module.py index 22ac3e9b..75de2762 100644 --- a/skbase/tests/mock_package/_private_module.py +++ b/skbase/tests/mock_package/_private_module.py @@ -27,4 +27,4 @@ def _private_module_hidden_function(): "_PrivateModuleHiddenClass", "private_module_public_function", "_private_module_hidden_function", -] \ No newline at end of file +] diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index 0a14d2d4..4f20f827 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -118,9 +118,7 @@ class _NonPublicClass(BaseObject): # Expected public functions by module for validation MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE = { - "skbase.tests.mock_package._private_module": ( - "private_module_public_function", - ), + "skbase.tests.mock_package._private_module": ("private_module_public_function",), "skbase.tests.mock_package.test_module_public": ( "decorated_function", "my_decorator", From 69d395af5156d6b74584dc7d6bac394610d1ee73 Mon Sep 17 00:00:00 2001 From: arnavk23 Date: Mon, 20 Apr 2026 01:42:03 +0530 Subject: [PATCH 30/30] pre-commit --- skbase/tests/mock_package/_private_pkg/__init__.py | 2 ++ .../test_module.py} | 12 ++++++------ skbase/tests/mock_package/test_mock_package.py | 11 ++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 skbase/tests/mock_package/_private_pkg/__init__.py rename skbase/tests/mock_package/{_private_module.py => _private_pkg/test_module.py} (60%) diff --git a/skbase/tests/mock_package/_private_pkg/__init__.py b/skbase/tests/mock_package/_private_pkg/__init__.py new file mode 100644 index 00000000..1520548d --- /dev/null +++ b/skbase/tests/mock_package/_private_pkg/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +"""Private subpackage for mock lookup discovery tests.""" diff --git a/skbase/tests/mock_package/_private_module.py b/skbase/tests/mock_package/_private_pkg/test_module.py similarity index 60% rename from skbase/tests/mock_package/_private_module.py rename to skbase/tests/mock_package/_private_pkg/test_module.py index 22ac3e9b..0ec0b109 100644 --- a/skbase/tests/mock_package/_private_module.py +++ b/skbase/tests/mock_package/_private_pkg/test_module.py @@ -1,24 +1,24 @@ # -*- coding: utf-8 -*- -"""Private module in mock package for lookup non-public coverage.""" +"""Private module in mock package for non-public lookup coverage.""" from skbase.base import BaseObject class PrivateModuleClass(BaseObject): - """Publicly named class living in a private module.""" + """Represent a publicly named class in a private module.""" class _PrivateModuleHiddenClass(BaseObject): - """Non-public class living in a private module.""" + """Represent a non-public class in a private module.""" def private_module_public_function(): - """Function with public name in a private module.""" + """Return marker for a public function in a private module.""" return "visible-only-when-non-public-modules-included" def _private_module_hidden_function(): - """Function with private name in a private module.""" + """Return marker for a private function in a private module.""" return "visible-only-when-non-public-items-included" @@ -27,4 +27,4 @@ def _private_module_hidden_function(): "_PrivateModuleHiddenClass", "private_module_public_function", "_private_module_hidden_function", -] \ No newline at end of file +] diff --git a/skbase/tests/mock_package/test_mock_package.py b/skbase/tests/mock_package/test_mock_package.py index 0a14d2d4..6254b6df 100644 --- a/skbase/tests/mock_package/test_mock_package.py +++ b/skbase/tests/mock_package/test_mock_package.py @@ -81,7 +81,7 @@ class _NonPublicClass(BaseObject): # Expected public classes by module for validation MOCK_PACKAGE_PUBLIC_CLASSES_BY_MODULE = { - "skbase.tests.mock_package._private_module": ("PrivateModuleClass",), + "skbase.tests.mock_package._private_pkg.test_module": ("PrivateModuleClass",), "skbase.tests.mock_package.test_mock_package": ( "AnotherClass", "CompositionDummy", @@ -97,7 +97,7 @@ class _NonPublicClass(BaseObject): # Expected all classes by module (including non-public) for validation MOCK_PACKAGE_CLASSES_BY_MODULE = { - "skbase.tests.mock_package._private_module": ( + "skbase.tests.mock_package._private_pkg.test_module": ( "PrivateModuleClass", "_PrivateModuleHiddenClass", ), @@ -118,7 +118,7 @@ class _NonPublicClass(BaseObject): # Expected public functions by module for validation MOCK_PACKAGE_PUBLIC_FUNCTIONS_BY_MODULE = { - "skbase.tests.mock_package._private_module": ( + "skbase.tests.mock_package._private_pkg.test_module": ( "private_module_public_function", ), "skbase.tests.mock_package.test_module_public": ( @@ -131,7 +131,7 @@ class _NonPublicClass(BaseObject): # Expected all functions by module (including non-public) for validation MOCK_PACKAGE_FUNCTIONS_BY_MODULE = { - "skbase.tests.mock_package._private_module": ( + "skbase.tests.mock_package._private_pkg.test_module": ( "private_module_public_function", "_private_module_hidden_function", ), @@ -158,7 +158,8 @@ class _NonPublicClass(BaseObject): # List of all modules (including non-public) in mock package MOCK_PACKAGE_MODULES = ( "skbase.tests.mock_package", - "skbase.tests.mock_package._private_module", + "skbase.tests.mock_package._private_pkg", + "skbase.tests.mock_package._private_pkg.test_module", "skbase.tests.mock_package.subpkg", "skbase.tests.mock_package.subpkg.test_module_b", "skbase.tests.mock_package.test_fixtures",