Skip to content

Commit

Permalink
Fix mypy errors in storage directory (#6809)
Browse files Browse the repository at this point in the history
Co-authored-by: openhands <[email protected]>
  • Loading branch information
neubig and openhands-agent authored Feb 19, 2025
1 parent 340c231 commit cb72a06
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion openhands/storage/conversation/conversation_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openhands/storage/conversation/file_conversation_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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)
Expand Down
2 changes: 1 addition & 1 deletion openhands/storage/google_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def read(self, path: str) -> str:
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)

Expand Down
2 changes: 1 addition & 1 deletion openhands/storage/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_full_path(self, path: str) -> str:
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'
Expand Down
2 changes: 1 addition & 1 deletion openhands/storage/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def read(self, path: str) -> str:
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':
Expand Down
2 changes: 1 addition & 1 deletion openhands/storage/settings/file_settings_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def load(self) -> Settings | None:
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)

Expand Down
2 changes: 1 addition & 1 deletion openhands/storage/settings/settings_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def load(self) -> Settings | None:
"""Load session init data"""

@abstractmethod
async def store(self, settings: Settings):
async def store(self, settings: Settings) -> None:
"""Store session init data"""

@classmethod
Expand Down

0 comments on commit cb72a06

Please sign in to comment.