aboutsummaryrefslogtreecommitdiffstats
path: root/backend/route_manager.py
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-07 02:29:26 +0100
committerGravatar Joe Banks <[email protected]>2024-07-08 15:00:10 +0100
commitd0e09d2ba567f23d91ac76d1844966bafb9b063a (patch)
tree9e825e3f09df02ab32e401c7e9555df26356dd4c /backend/route_manager.py
parentChange linting config to Ruff (diff)
Apply fixable lint settings with Ruff
Diffstat (limited to 'backend/route_manager.py')
-rw-r--r--backend/route_manager.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/backend/route_manager.py b/backend/route_manager.py
index 2d95bb2..b35ca0b 100644
--- a/backend/route_manager.py
+++ b/backend/route_manager.py
@@ -1,6 +1,4 @@
-"""
-Module to dynamically generate a Starlette routing map based on a directory tree.
-"""
+"""Module to dynamically generate a Starlette routing map based on a directory tree."""
import importlib
import inspect
@@ -27,7 +25,7 @@ def construct_route_map_from_dict(route_dict: dict) -> list[BaseRoute]:
return route_map
-def is_route_class(member: t.Any) -> bool: # noqa: ANN401
+def is_route_class(member: t.Any) -> bool:
return inspect.isclass(member) and issubclass(member, Route) and member != Route
@@ -35,7 +33,7 @@ def route_classes() -> t.Iterator[tuple[Path, type[Route]]]:
routes_directory = Path("backend") / "routes"
for module_path in routes_directory.rglob("*.py"):
- import_name = f"{'.'.join(module_path.parent.parts)}.{module_path.stem}"
+ import_name = f"{".".join(module_path.parent.parts)}.{module_path.stem}"
route_module = importlib.import_module(import_name)
for _member_name, member in inspect.getmembers(route_module):
if is_route_class(member):
@@ -47,7 +45,7 @@ def create_route_map() -> list[BaseRoute]:
route_dict = nested_dict()
for module_path, member in route_classes():
- # module_path == Path("backend/routes/foo/bar/baz/bin.py")
+ # For Path: "backend/routes/foo/bar/baz/bin.py"
# => levels == ["foo", "bar", "baz"]
levels = module_path.parent.parts[2:]
current_level = None