refactor(types): Phase 4 type hint sweep — core modules

This commit is contained in:
2026-02-28 15:13:55 -05:00
parent ca04026db5
commit 46c2f9a0ca
10 changed files with 52 additions and 42 deletions

View File

@@ -1,3 +1,4 @@
from __future__ import annotations
import tomli_w
import tomllib
from datetime import datetime
@@ -9,7 +10,7 @@ class LogRegistry:
Tracks session paths, start times, whitelisting status, and metadata.
"""
def __init__(self, registry_path):
def __init__(self, registry_path: str) -> None:
"""
Initializes the LogRegistry with a path to the registry file.
@@ -81,7 +82,7 @@ class LogRegistry:
except Exception as e:
print(f"Error saving registry to {self.registry_path}: {e}")
def register_session(self, session_id, path, start_time):
def register_session(self, session_id: str, path: str, start_time: datetime | str) -> None:
"""
Registers a new session in the registry.
@@ -105,7 +106,7 @@ class LogRegistry:
}
self.save_registry()
def update_session_metadata(self, session_id, message_count, errors, size_kb, whitelisted, reason):
def update_session_metadata(self, session_id: str, message_count: int, errors: int, size_kb: int, whitelisted: bool, reason: str) -> None:
"""
Updates metadata fields for an existing session.
@@ -135,7 +136,7 @@ class LogRegistry:
self.data[session_id]['whitelisted'] = whitelisted
self.save_registry() # Save after update
def is_session_whitelisted(self, session_id):
def is_session_whitelisted(self, session_id: str) -> bool:
"""
Checks if a specific session is marked as whitelisted.
@@ -209,7 +210,7 @@ class LogRegistry:
reason=reason
)
def get_old_non_whitelisted_sessions(self, cutoff_datetime):
def get_old_non_whitelisted_sessions(self, cutoff_datetime: datetime) -> list[dict]:
"""
Retrieves a list of sessions that are older than a specific cutoff time
and are not marked as whitelisted.