feat: mypy for all type check (#10921)

This commit is contained in:
yihong
2024-12-24 18:38:51 +08:00
committed by GitHub
parent c91e8b1737
commit 56e15d09a9
584 changed files with 3975 additions and 2826 deletions

View File

@@ -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: