Fix mypy errors in storage directory (#6809)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Graham Neubig 2025-02-19 05:52:49 -05:00 committed by GitHub
parent 340c2310d1
commit cb72a06ca3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 7 additions and 7 deletions

View File

@ -15,7 +15,7 @@ class ConversationStore(ABC):
"""
@abstractmethod
async def save_metadata(self, metadata: ConversationMetadata):
async def save_metadata(self, metadata: ConversationMetadata) -> None:
"""Store conversation metadata"""
@abstractmethod

View File

@ -29,7 +29,7 @@ conversation_metadata_type_adapter = TypeAdapter(ConversationMetadata)
class FileConversationStore(ConversationStore):
file_store: FileStore
async def save_metadata(self, metadata: ConversationMetadata):
async def save_metadata(self, metadata: ConversationMetadata) -> None:
json_str = conversation_metadata_type_adapter.dump_json(metadata)
path = self.get_conversation_metadata_filename(metadata.conversation_id)
await call_sync_from_async(self.file_store.write, path, json_str)

View File

@ -29,7 +29,7 @@ class GoogleCloudFileStore(FileStore):
blob = self.bucket.blob(path)
try:
with blob.open('r') as f:
return f.read()
return str(f.read())
except NotFound as err:
raise FileNotFoundError(err)

View File

@ -17,7 +17,7 @@ class LocalFileStore(FileStore):
path = path[1:]
return os.path.join(self.root, path)
def write(self, path: str, contents: str | bytes):
def write(self, path: str, contents: str | bytes) -> None:
full_path = self.get_full_path(path)
os.makedirs(os.path.dirname(full_path), exist_ok=True)
mode = 'w' if isinstance(contents, str) else 'wb'

View File

@ -46,7 +46,7 @@ class S3FileStore(FileStore):
try:
response = self.client.get_object(Bucket=self.bucket, Key=path)
with response['Body'] as stream:
return stream.read().decode('utf-8')
return str(stream.read().decode('utf-8'))
except botocore.exceptions.ClientError as e:
# Catch all S3-related errors
if e.response['Error']['Code'] == 'NoSuchBucket':

View File

@ -25,7 +25,7 @@ class FileSettingsStore(SettingsStore):
except FileNotFoundError:
return None
async def store(self, settings: Settings):
async def store(self, settings: Settings) -> None:
json_str = settings.model_dump_json(context={'expose_secrets': True})
await call_sync_from_async(self.file_store.write, self.path, json_str)

View File

@ -16,7 +16,7 @@ class SettingsStore(ABC):
"""Load session init data"""
@abstractmethod
async def store(self, settings: Settings):
async def store(self, settings: Settings) -> None:
"""Store session init data"""
@classmethod