diff --git a/frontik/dependency_manager/__init__.py b/frontik/dependency_manager/__init__.py index 26f7f646a..62dd4e7c6 100644 --- a/frontik/dependency_manager/__init__.py +++ b/frontik/dependency_manager/__init__.py @@ -2,10 +2,10 @@ from typing import TYPE_CHECKING, Any -from frontik.preprocessors import DependencyGroupMarker, Preprocessor from frontik.dependency_manager.dependencies import DependencyMarker +from frontik.dependency_manager.graph_builder import build_sub_graph, get_dependency_graph from frontik.dependency_manager.graph_runner import execute_graph -from frontik.dependency_manager.graph_builder import get_dependency_graph, build_sub_graph +from frontik.preprocessors import DependencyGroupMarker, Preprocessor if TYPE_CHECKING: from collections.abc import Callable diff --git a/frontik/dependency_manager/dependencies.py b/frontik/dependency_manager/dependencies.py index 6e78df3a7..fdd6ce56e 100644 --- a/frontik/dependency_manager/dependencies.py +++ b/frontik/dependency_manager/dependencies.py @@ -2,10 +2,13 @@ import asyncio from graphlib import TopologicalSorter -from frontik.preprocessors import make_full_name -from collections.abc import Callable from typing import TYPE_CHECKING + +from frontik.preprocessors import make_full_name + if TYPE_CHECKING: + from collections.abc import Callable + from frontik.handler import PageHandler diff --git a/frontik/dependency_manager/graph_builder.py b/frontik/dependency_manager/graph_builder.py index 7559fe5b6..3959ef6a8 100644 --- a/frontik/dependency_manager/graph_builder.py +++ b/frontik/dependency_manager/graph_builder.py @@ -5,17 +5,22 @@ from itertools import chain from typing import TYPE_CHECKING, Any +from frontik.dependency_manager.dependencies import ( + Dependency, + DependencyGraph, + DependencyMarker, + get_handler, + make_stub_dependency, +) from frontik.preprocessors import ( Preprocessor, get_all_preprocessors_functions, get_simple_preprocessors_functions, make_full_name, ) -from frontik.dependency_manager.dependencies import (DependencyGraph, Dependency, DependencyMarker, - make_stub_dependency, get_handler) if TYPE_CHECKING: - from collections.abc import Callable + from collections.abc import Callable, Iterable from frontik.handler import PageHandler @@ -79,14 +84,19 @@ def get_dependency_graph(page_method_func: Callable, handler_cls: type) -> Depen return deepcopy(meta_graph) -def _register_side_dependencies(graph, root_dep, side_dependencies, deep_scan): +def _register_side_dependencies( + graph: DependencyGraph, + root_dep: Dependency, + side_dependencies: Iterable, + deep_scan: bool, +) -> None: for function_or_preprocessor in side_dependencies: dependency = _make_dependency_for_graph(graph, function_or_preprocessor, deep_scan=deep_scan) if deep_scan: _register_sub_dependency(graph, root_dep, dependency, add_to_args=False) -def _register_async_dependencies(graph, async_dependencies): +def _register_async_dependencies(graph: DependencyGraph, async_dependencies: Iterable) -> None: root_dep = make_stub_dependency() for dependency_function in async_dependencies: dependency = _make_dependency_for_graph(graph, dependency_function, deep_scan=True) diff --git a/frontik/dependency_manager/graph_runner.py b/frontik/dependency_manager/graph_runner.py index 49445b175..fc27f8fa4 100644 --- a/frontik/dependency_manager/graph_runner.py +++ b/frontik/dependency_manager/graph_runner.py @@ -3,9 +3,8 @@ import asyncio from typing import TYPE_CHECKING -from frontik.dependency_manager.dependencies import Dependency, DependencyGraph - if TYPE_CHECKING: + from frontik.dependency_manager.dependencies import Dependency, DependencyGraph from frontik.handler import PageHandler diff --git a/tests/test_dependencies.py b/tests/test_dependencies.py index aa7102196..1109e4ca7 100644 --- a/tests/test_dependencies.py +++ b/tests/test_dependencies.py @@ -3,7 +3,7 @@ import pytest -from frontik.dependency_manager import build_and_run_sub_graph, dep, execute_page_method_with_dependencies, async_deps +from frontik.dependency_manager import async_deps, build_and_run_sub_graph, dep, execute_page_method_with_dependencies from frontik.handler import PageHandler