remove bare list, dict, Sequence, None, Any (#25058)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
@@ -49,7 +49,7 @@ class ClickzettaConfig(BaseModel):
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def validate_config(cls, values: dict) -> dict:
|
||||
def validate_config(cls, values: dict):
|
||||
"""
|
||||
Validate the configuration values.
|
||||
"""
|
||||
@@ -134,7 +134,7 @@ class ClickzettaConnectionPool:
|
||||
|
||||
raise RuntimeError(f"Failed to create ClickZetta connection after {max_retries} attempts")
|
||||
|
||||
def _configure_connection(self, connection: "Connection") -> None:
|
||||
def _configure_connection(self, connection: "Connection"):
|
||||
"""Configure connection session settings."""
|
||||
try:
|
||||
with connection.cursor() as cursor:
|
||||
@@ -221,7 +221,7 @@ class ClickzettaConnectionPool:
|
||||
# No valid connection found, create new one
|
||||
return self._create_connection(config)
|
||||
|
||||
def return_connection(self, config: ClickzettaConfig, connection: "Connection") -> None:
|
||||
def return_connection(self, config: ClickzettaConfig, connection: "Connection"):
|
||||
"""Return a connection to the pool."""
|
||||
config_key = self._get_config_key(config)
|
||||
|
||||
@@ -243,7 +243,7 @@ class ClickzettaConnectionPool:
|
||||
with contextlib.suppress(Exception):
|
||||
connection.close()
|
||||
|
||||
def _cleanup_expired_connections(self) -> None:
|
||||
def _cleanup_expired_connections(self):
|
||||
"""Clean up expired connections from all pools."""
|
||||
current_time = time.time()
|
||||
|
||||
@@ -265,7 +265,7 @@ class ClickzettaConnectionPool:
|
||||
|
||||
self._pools[config_key] = valid_connections
|
||||
|
||||
def _start_cleanup_thread(self) -> None:
|
||||
def _start_cleanup_thread(self):
|
||||
"""Start background thread for connection cleanup."""
|
||||
|
||||
def cleanup_worker():
|
||||
@@ -280,7 +280,7 @@ class ClickzettaConnectionPool:
|
||||
self._cleanup_thread = threading.Thread(target=cleanup_worker, daemon=True)
|
||||
self._cleanup_thread.start()
|
||||
|
||||
def shutdown(self) -> None:
|
||||
def shutdown(self):
|
||||
"""Shutdown connection pool and close all connections."""
|
||||
self._shutdown = True
|
||||
|
||||
@@ -319,7 +319,7 @@ class ClickzettaVector(BaseVector):
|
||||
"""Get a connection from the pool."""
|
||||
return self._connection_pool.get_connection(self._config)
|
||||
|
||||
def _return_connection(self, connection: "Connection") -> None:
|
||||
def _return_connection(self, connection: "Connection"):
|
||||
"""Return a connection to the pool."""
|
||||
self._connection_pool.return_connection(self._config, connection)
|
||||
|
||||
@@ -342,7 +342,7 @@ class ClickzettaVector(BaseVector):
|
||||
"""Get a connection context manager."""
|
||||
return self.ConnectionContext(self)
|
||||
|
||||
def _parse_metadata(self, raw_metadata: str, row_id: str) -> dict:
|
||||
def _parse_metadata(self, raw_metadata: str, row_id: str):
|
||||
"""
|
||||
Parse metadata from JSON string with proper error handling and fallback.
|
||||
|
||||
@@ -723,7 +723,7 @@ class ClickzettaVector(BaseVector):
|
||||
result = cursor.fetchone()
|
||||
return result[0] > 0 if result else False
|
||||
|
||||
def delete_by_ids(self, ids: list[str]) -> None:
|
||||
def delete_by_ids(self, ids: list[str]):
|
||||
"""Delete documents by IDs."""
|
||||
if not ids:
|
||||
return
|
||||
@@ -736,7 +736,7 @@ class ClickzettaVector(BaseVector):
|
||||
# Execute delete through write queue
|
||||
self._execute_write(self._delete_by_ids_impl, ids)
|
||||
|
||||
def _delete_by_ids_impl(self, ids: list[str]) -> None:
|
||||
def _delete_by_ids_impl(self, ids: list[str]):
|
||||
"""Implementation of delete by IDs (executed in write worker thread)."""
|
||||
safe_ids = [self._safe_doc_id(id) for id in ids]
|
||||
|
||||
@@ -748,7 +748,7 @@ class ClickzettaVector(BaseVector):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(sql, binding_params=safe_ids)
|
||||
|
||||
def delete_by_metadata_field(self, key: str, value: str) -> None:
|
||||
def delete_by_metadata_field(self, key: str, value: str):
|
||||
"""Delete documents by metadata field."""
|
||||
# Check if table exists before attempting delete
|
||||
if not self._table_exists():
|
||||
@@ -758,7 +758,7 @@ class ClickzettaVector(BaseVector):
|
||||
# Execute delete through write queue
|
||||
self._execute_write(self._delete_by_metadata_field_impl, key, value)
|
||||
|
||||
def _delete_by_metadata_field_impl(self, key: str, value: str) -> None:
|
||||
def _delete_by_metadata_field_impl(self, key: str, value: str):
|
||||
"""Implementation of delete by metadata field (executed in write worker thread)."""
|
||||
with self.get_connection_context() as connection:
|
||||
with connection.cursor() as cursor:
|
||||
@@ -1027,7 +1027,7 @@ class ClickzettaVector(BaseVector):
|
||||
|
||||
return documents
|
||||
|
||||
def delete(self) -> None:
|
||||
def delete(self):
|
||||
"""Delete the entire collection."""
|
||||
with self.get_connection_context() as connection:
|
||||
with connection.cursor() as cursor:
|
||||
|
||||
Reference in New Issue
Block a user