mirror of
https://github.com/beshu-tech/deltaglider.git
synced 2026-03-17 23:03:50 +01:00
ruff & mypy
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
web-ui/
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import boto3
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user