chore: refurbish Python code by applying refurb linter rules (#8296)

This commit is contained in:
Bowen Liang 2024-09-12 15:50:49 +08:00 • committed by GitHub
commit 40fb4d16ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
105 changed files with 220 additions and 276 deletions

View file

@ -1,6 +1,7 @@
import logging
import mimetypes
import os
from pathlib import Path
from typing import Optional, cast
import requests
@ -453,9 +454,8 @@ class ModelProviderService:
mimetype = mimetype or "application/octet-stream"
# read binary from file
with open(file_path, "rb") as f:
byte_data = f.read()
return byte_data, mimetype
byte_data = Path(file_path).read_bytes()
return byte_data, mimetype
def switch_preferred_provider(self, tenant_id: str, provider: str, preferred_provider_type: str) -> None:
"""