diff --git a/nodescraper/configbuilder.py b/nodescraper/configbuilder.py index 354ebc43..7823b95a 100644 --- a/nodescraper/configbuilder.py +++ b/nodescraper/configbuilder.py @@ -109,6 +109,13 @@ def _process_value(cls, value: Any) -> Optional[Union[dict, str, int, float, lis return_dict = {} for key, val in value.items(): return_dict[key] = cls._process_value(val) + return return_dict + + if isinstance(value, list): + return_list = [] + for item in value: + return_list.append(cls._process_value(item)) + return return_list elif not isinstance( value, diff --git a/nodescraper/pluginregistry.py b/nodescraper/pluginregistry.py index 559d96f6..5abc2f84 100644 --- a/nodescraper/pluginregistry.py +++ b/nodescraper/pluginregistry.py @@ -28,7 +28,7 @@ import inspect import pkgutil import types -from typing import Optional +from typing import Iterable, Optional import nodescraper.connection as internal_connections import nodescraper.plugins as internal_plugins @@ -135,6 +135,7 @@ def load_connection_managers_from_entry_points() -> dict[str, type]: managers: dict[str, type] = {} try: + eps: Iterable try: eps = importlib.metadata.entry_points( # type: ignore[call-arg] group="nodescraper.connection_managers" @@ -145,7 +146,7 @@ def load_connection_managers_from_entry_points() -> dict[str, type]: for entry_point in eps: try: - loaded = entry_point.load() # type: ignore[attr-defined] + loaded = entry_point.load() # type: ignore[attr-defined, union-attr] if not ( inspect.isclass(loaded) and issubclass(loaded, ConnectionManager) @@ -177,6 +178,7 @@ def load_plugins_from_entry_points() -> dict[str, type]: plugins = {} try: + eps: Iterable # Python 3.10+ supports group parameter try: eps = importlib.metadata.entry_points(group="nodescraper.plugins") # type: ignore[call-arg] @@ -187,7 +189,7 @@ def load_plugins_from_entry_points() -> dict[str, type]: for entry_point in eps: try: - plugin_class = entry_point.load() # type: ignore[attr-defined] + plugin_class = entry_point.load() # type: ignore[attr-defined, union-attr] if ( inspect.isclass(plugin_class) diff --git a/nodescraper/typeutils.py b/nodescraper/typeutils.py index cd7a4650..c77a9879 100644 --- a/nodescraper/typeutils.py +++ b/nodescraper/typeutils.py @@ -168,7 +168,9 @@ def get_model_types(cls, model: type[BaseModel]) -> dict[str, TypeData]: type_map[name] = TypeData( type_classes=cls.process_type(field.annotation), required=field.is_required(), - default=field.default, + default=( + field.default_factory() if callable(field.default_factory) else field.default + ), ) return type_map diff --git a/test/unit/framework/common/shared_utils.py b/test/unit/framework/common/shared_utils.py index 11e6f541..5b882549 100644 --- a/test/unit/framework/common/shared_utils.py +++ b/test/unit/framework/common/shared_utils.py @@ -95,6 +95,8 @@ def run( self, test_bool_arg: bool = True, test_str_arg: str = "test", + test_list_arg: list[int] = [1], # noqa: B006 + test_dict_arg: dict = {}, # noqa: B006 test_model_arg: Optional[TestModelArg] = None, ): return PluginResult( diff --git a/test/unit/framework/test_cli_helper.py b/test/unit/framework/test_cli_helper.py index 3e09c108..7a29d888 100644 --- a/test/unit/framework/test_cli_helper.py +++ b/test/unit/framework/test_cli_helper.py @@ -140,6 +140,8 @@ def test_config_builder(plugin_registry): "TestPluginA": { "test_bool_arg": True, "test_str_arg": "test", + "test_list_arg": [1], + "test_dict_arg": {}, "test_model_arg": {"model_attr": 123}, }, "ExamplePlugin": {}, diff --git a/test/unit/framework/test_config_builder.py b/test/unit/framework/test_config_builder.py index 862d4011..ede3fac6 100644 --- a/test/unit/framework/test_config_builder.py +++ b/test/unit/framework/test_config_builder.py @@ -36,6 +36,8 @@ def test_config_builder(plugin_registry): "TestPluginA": { "test_bool_arg": True, "test_str_arg": "test", + "test_list_arg": [1], + "test_dict_arg": {}, "test_model_arg": {"model_attr": 123}, } }