Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nodescraper/configbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions nodescraper/pluginregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion nodescraper/typeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/unit/framework/common/shared_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions test/unit/framework/test_cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
2 changes: 2 additions & 0 deletions test/unit/framework/test_config_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}
}
Loading