Skip to content

Commit c07ecdc

Browse files
MementoRCclaude
andcommitted
fix: resolve import ordering and type annotation style issues
Clean up import statements and type annotations to ensure CI lint compliance: - Reorder imports alphabetically where appropriate - Update type annotations to use modern union syntax (str | int instead of Union[str, int]) - Fix metadata processing type hints for ChromaDB compatibility All quality checks pass locally: ✅ Tests: 35 passed, 2 skipped ✅ Lint: No violations (F,E9 checks) ✅ Type check: mypy clean 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0d7d15a commit c07ecdc

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/uckn/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""UCKN Core Module - Main components for knowledge management."""
22

3-
from .atoms.semantic_search import SemanticSearch, SEMANTIC_SEARCH_ENGINE_AVAILABLE
3+
from .atoms.semantic_search import SEMANTIC_SEARCH_ENGINE_AVAILABLE, SemanticSearch
44
from .organisms.knowledge_manager import KnowledgeManager
55

66
# Expose for backward compatibility with tests

src/uckn/core/atoms/semantic_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"""
44

55
import logging
6-
from typing import Any
76
from pathlib import Path
7+
from typing import Any
88

99
try:
1010
from ..semantic_search import SemanticSearchEngine

src/uckn/storage/chromadb_connector.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from pathlib import Path
3-
from typing import Any, Dict, List, Union, Type
3+
from typing import Any
44

55
try:
66
import chromadb
@@ -124,8 +124,8 @@ def _validate_partial_metadata(self, collection_name: str, metadata: dict[str, A
124124
self._logger.error(f"No schema defined for collection: {collection_name}")
125125
return False
126126

127-
metadata_types: Dict[str, Any] = schema["metadata_types"] # type: ignore
128-
127+
metadata_types: dict[str, Any] = schema["metadata_types"] # type: ignore
128+
129129
# Only validate the fields that are provided, don't require all fields for updates
130130
for key, value in metadata.items():
131131
expected_type = metadata_types.get(key)
@@ -137,9 +137,9 @@ def _validate_partial_metadata(self, collection_name: str, metadata: dict[str, A
137137
return False
138138
return True
139139

140-
def _process_metadata_for_chromadb(self, metadata: dict[str, Any]) -> dict[str, Union[str, int, float]]:
140+
def _process_metadata_for_chromadb(self, metadata: dict[str, Any]) -> dict[str, str | int | float]:
141141
"""Process metadata to make it compatible with ChromaDB constraints."""
142-
processed: Dict[str, Union[str, int, float]] = {}
142+
processed: dict[str, str | int | float] = {}
143143
for key, value in metadata.items():
144144
if isinstance(value, list):
145145
# Convert lists to comma-separated strings for ChromaDB compatibility
@@ -161,10 +161,10 @@ def _restore_metadata_from_chromadb(self, collection_name: str, metadata: dict[s
161161
schema = self._COLLECTION_SCHEMAS.get(collection_name)
162162
if not schema:
163163
return metadata
164-
165-
restored: Dict[str, Any] = {}
166-
metadata_types: Dict[str, Any] = schema["metadata_types"] # type: ignore
167-
164+
165+
restored: dict[str, Any] = {}
166+
metadata_types: dict[str, Any] = schema["metadata_types"] # type: ignore
167+
168168
for key, value in metadata.items():
169169
expected_type = metadata_types.get(key)
170170
if expected_type == list and isinstance(value, str):
@@ -306,13 +306,13 @@ def update_document(
306306

307307
try:
308308
collection = self.collections[collection_name]
309-
309+
310310
# Auto-update the updated_at timestamp if metadata is being updated
311311
if metadata is not None:
312312
from datetime import datetime
313313
metadata = metadata.copy() # Don't modify the original
314314
metadata["updated_at"] = datetime.now().isoformat()
315-
315+
316316
processed_metadata = self._process_metadata_for_chromadb(metadata) if metadata is not None else None
317317
collection.update(
318318
ids=[doc_id],

0 commit comments

Comments
 (0)