fix: add comprehensive type annotations for mypy

- database.py: add type hints for Path, Flask, Any, BaseException
- pki.py: add assertions to narrow Optional types after has_ca() checks
- routes.py: annotate config values to avoid Any return types
- api/__init__.py: use float for cleanup timestamps (time.time())
- __init__.py: remove unused return from setup_rate_limiting
This commit is contained in:
Username
2025-12-22 19:11:11 +01:00
parent 680b068c00
commit ca9342e92d
5 changed files with 36 additions and 20 deletions

View File

@@ -9,10 +9,10 @@ bp = Blueprint("api", __name__)
# Thread-safe cleanup scheduling
_cleanup_lock = threading.Lock()
_cleanup_times = {
"pastes": 0,
"hashes": 0,
"rate_limits": 0,
_cleanup_times: dict[str, float] = {
"pastes": 0.0,
"hashes": 0.0,
"rate_limits": 0.0,
}
_CLEANUP_INTERVALS = {
"pastes": 3600, # 1 hour
@@ -25,7 +25,7 @@ def reset_cleanup_times() -> None:
"""Reset cleanup timestamps. For testing only."""
with _cleanup_lock:
for key in _cleanup_times:
_cleanup_times[key] = 0
_cleanup_times[key] = 0.0
@bp.before_request