ruff & mypy

This commit is contained in:
Simone Scarduzio
2025-09-25 17:05:35 +02:00
parent f1cdc10fd5
commit 02120a764e
4 changed files with 8 additions and 8 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
web-ui/
# Python
__pycache__/
*.py[cod]

View File

@@ -2,7 +2,6 @@
import logging
from datetime import datetime
from typing import Any
import boto3
from botocore.exceptions import ClientError

View File

@@ -17,6 +17,7 @@ from ...adapters import (
XdeltaAdapter,
)
from ...core import DeltaService, DeltaSpace, ObjectKey
from ...ports import MetricsPort
from .aws_compat import (
copy_s3_to_s3,
determine_operation,
@@ -58,6 +59,7 @@ def create_service(
logger = StdLoggerAdapter(level=log_level)
# Create metrics adapter based on configuration
metrics: MetricsPort
if metrics_type == "cloudwatch":
# Import here to avoid dependency if not used
from ...adapters.metrics_cloudwatch import CloudWatchMetricsAdapter

View File

@@ -262,7 +262,7 @@ class DeltaGliderClient:
MaxKeys: int = 1000,
ContinuationToken: str | None = None,
StartAfter: str | None = None,
**kwargs,
**kwargs: Any,
) -> ListObjectsResponse:
"""List objects in bucket (boto3-compatible).
@@ -452,7 +452,7 @@ class DeltaGliderClient:
}
)
response = {"Deleted": deleted}
response: dict[str, Any] = {"Deleted": deleted}
if errors:
response["Errors"] = errors
@@ -913,7 +913,7 @@ class DeltaGliderClient:
MaxKeys=1000,
)
similar = []
similar: list[dict[str, Any]] = []
base_name = Path(filename).stem
ext = Path(filename).suffix
@@ -952,7 +952,7 @@ class DeltaGliderClient:
)
# Sort by similarity
similar.sort(key=lambda x: x.get("Similarity", 0), reverse=True)
similar.sort(key=lambda x: x["Similarity"], reverse=True) # type: ignore
return similar[:limit]
@@ -1080,7 +1080,7 @@ class DeltaGliderClient:
Params=Params,
ExpiresIn=ExpiresIn,
)
return url
return str(url)
except Exception as e:
# Fall back to manual URL construction if needed
self.service.logger.warning(f"Failed to generate presigned URL: {e}")
@@ -1131,7 +1131,7 @@ class DeltaGliderClient:
Conditions=Conditions,
ExpiresIn=ExpiresIn,
)
return response
return dict(response)
except Exception as e:
self.service.logger.warning(f"Failed to generate presigned POST: {e}")