mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-11 11:56:53 +08:00
feat: mypy for all type check (#10921)
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
||||
from collections.abc import Generator
|
||||
from pathlib import Path
|
||||
|
||||
import opendal
|
||||
import opendal # type: ignore[import]
|
||||
from dotenv import dotenv_values
|
||||
|
||||
from extensions.storage.base_storage import BaseStorage
|
||||
@@ -18,7 +18,7 @@ def _get_opendal_kwargs(*, scheme: str, env_file_path: str = ".env", prefix: str
|
||||
if key.startswith(config_prefix):
|
||||
kwargs[key[len(config_prefix) :].lower()] = value
|
||||
|
||||
file_env_vars = dotenv_values(env_file_path)
|
||||
file_env_vars: dict = dotenv_values(env_file_path) or {}
|
||||
for key, value in file_env_vars.items():
|
||||
if key.startswith(config_prefix) and key[len(config_prefix) :].lower() not in kwargs and value:
|
||||
kwargs[key[len(config_prefix) :].lower()] = value
|
||||
@@ -48,7 +48,7 @@ class OpenDALStorage(BaseStorage):
|
||||
if not self.exists(filename):
|
||||
raise FileNotFoundError("File not found")
|
||||
|
||||
content = self.op.read(path=filename)
|
||||
content: bytes = self.op.read(path=filename)
|
||||
logger.debug(f"file {filename} loaded")
|
||||
return content
|
||||
|
||||
@@ -75,7 +75,7 @@ class OpenDALStorage(BaseStorage):
|
||||
# error handler here when opendal python-binding has a exists method, we should use it
|
||||
# more https://github.com/apache/opendal/blob/main/bindings/python/src/operator.rs
|
||||
try:
|
||||
res = self.op.stat(path=filename).mode.is_file()
|
||||
res: bool = self.op.stat(path=filename).mode.is_file()
|
||||
logger.debug(f"file {filename} checked")
|
||||
return res
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user