From 720e8509062be284af3d0c77a07dde0deac1c622 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 4 Jan 2025 14:47:56 +1000 Subject: [PATCH] Immediate mypy fixes --- src/traffcap/core/store.py | 2 +- src/traffcap/repositories/rule_repository.py | 16 ++++++++-------- src/traffcap/routes/traffic.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/traffcap/core/store.py b/src/traffcap/core/store.py index d19c23c..e667acf 100644 --- a/src/traffcap/core/store.py +++ b/src/traffcap/core/store.py @@ -19,7 +19,7 @@ def new_traffic_notification() -> None: global store store["last_message"] += 1 -async def wait_for_notification(seconds: float = 0.5) -> AsyncGenerator[Any, Any]: +async def wait_for_notification() -> AsyncGenerator[Any, Any]: """ Wait for a change in the last_message. By default this uses the stdlib multiprocessing Manager. Which is good for ASGI/WSGI diff --git a/src/traffcap/repositories/rule_repository.py b/src/traffcap/repositories/rule_repository.py index 156279e..58fa591 100644 --- a/src/traffcap/repositories/rule_repository.py +++ b/src/traffcap/repositories/rule_repository.py @@ -54,13 +54,13 @@ async def find_matching_rules(cls, rule: str) -> List[Rule]: """ Find all rules that match this current rule """ - rules = [] - async with cls.session() as session: - results = await session.scalars( - select(RuleModel) - .where(RuleModel.rule == rule) - ) - for rule_item in results.all(): - rules.append(Rule.model_validate(rule_item)) + rules: list[Rule] = [] + # async with cls.session() as session: + # results = await session.scalars( + # select(RuleModel) + # .where(RuleModel.rule == rule) + # ) + # for rule_item in results.all(): + # rules.append(Rule.model_validate(rule_item)) return rules diff --git a/src/traffcap/routes/traffic.py b/src/traffcap/routes/traffic.py index 9dc2843..3cc6f5a 100644 --- a/src/traffcap/routes/traffic.py +++ b/src/traffcap/routes/traffic.py @@ -38,7 +38,7 @@ async def traffic_firehose(websocket: WebSocket): await websocket.send_text(response.model_dump_json()) # Wait for an event from the message broker - async for _ in wait_for_notification(websocket): + async for _ in wait_for_notification(): # Check the connection await sleep(0.5) # TODO: Figure out how to check websocket connections without the ping