mirror of
https://github.com/langgenius/dify.git
synced 2025-06-27 05:30:04 +00:00
chore: bump mypy to 1.16 (#20608)
This commit is contained in:
parent
60777bc610
commit
0f3d4d0b6e
@ -208,7 +208,7 @@ class AnnotationBatchImportApi(Resource):
|
|||||||
if len(request.files) > 1:
|
if len(request.files) > 1:
|
||||||
raise TooManyFilesError()
|
raise TooManyFilesError()
|
||||||
# check file type
|
# check file type
|
||||||
if not file.filename.endswith(".csv"):
|
if not file.filename or not file.filename.endswith(".csv"):
|
||||||
raise ValueError("Invalid file type. Only CSV files are allowed")
|
raise ValueError("Invalid file type. Only CSV files are allowed")
|
||||||
return AppAnnotationService.batch_import_app_annotations(app_id, file)
|
return AppAnnotationService.batch_import_app_annotations(app_id, file)
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ class DatasetDocumentSegmentBatchImportApi(Resource):
|
|||||||
if len(request.files) > 1:
|
if len(request.files) > 1:
|
||||||
raise TooManyFilesError()
|
raise TooManyFilesError()
|
||||||
# check file type
|
# check file type
|
||||||
if not file.filename.endswith(".csv"):
|
if not file.filename or not file.filename.endswith(".csv"):
|
||||||
raise ValueError("Invalid file type. Only CSV files are allowed")
|
raise ValueError("Invalid file type. Only CSV files are allowed")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -139,4 +139,4 @@ class CacheEmbedding(Embeddings):
|
|||||||
logging.exception(f"Failed to add embedding to redis for the text '{text[:10]}...({len(text)} chars)'")
|
logging.exception(f"Failed to add embedding to redis for the text '{text[:10]}...({len(text)} chars)'")
|
||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
return embedding_results
|
return embedding_results # type: ignore
|
||||||
|
@ -104,7 +104,7 @@ class QAIndexProcessor(BaseIndexProcessor):
|
|||||||
|
|
||||||
def format_by_template(self, file: FileStorage, **kwargs) -> list[Document]:
|
def format_by_template(self, file: FileStorage, **kwargs) -> list[Document]:
|
||||||
# check file type
|
# check file type
|
||||||
if not file.filename.endswith(".csv"):
|
if not file.filename or not file.filename.endswith(".csv"):
|
||||||
raise ValueError("Invalid file type. Only CSV files are allowed")
|
raise ValueError("Invalid file type. Only CSV files are allowed")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -32,14 +32,14 @@ class ToolFileMessageTransformer:
|
|||||||
try:
|
try:
|
||||||
assert isinstance(message.message, ToolInvokeMessage.TextMessage)
|
assert isinstance(message.message, ToolInvokeMessage.TextMessage)
|
||||||
tool_file_manager = ToolFileManager()
|
tool_file_manager = ToolFileManager()
|
||||||
file = tool_file_manager.create_file_by_url(
|
tool_file = tool_file_manager.create_file_by_url(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
file_url=message.message.text,
|
file_url=message.message.text,
|
||||||
conversation_id=conversation_id,
|
conversation_id=conversation_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
url = f"/files/tools/{file.id}{guess_extension(file.mimetype) or '.png'}"
|
url = f"/files/tools/{tool_file.id}{guess_extension(tool_file.mimetype) or '.png'}"
|
||||||
|
|
||||||
yield ToolInvokeMessage(
|
yield ToolInvokeMessage(
|
||||||
type=ToolInvokeMessage.MessageType.IMAGE_LINK,
|
type=ToolInvokeMessage.MessageType.IMAGE_LINK,
|
||||||
@ -68,7 +68,7 @@ class ToolFileMessageTransformer:
|
|||||||
|
|
||||||
assert isinstance(message.message.blob, bytes)
|
assert isinstance(message.message.blob, bytes)
|
||||||
tool_file_manager = ToolFileManager()
|
tool_file_manager = ToolFileManager()
|
||||||
file = tool_file_manager.create_file_by_raw(
|
tool_file = tool_file_manager.create_file_by_raw(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
conversation_id=conversation_id,
|
conversation_id=conversation_id,
|
||||||
@ -77,7 +77,7 @@ class ToolFileMessageTransformer:
|
|||||||
filename=filename,
|
filename=filename,
|
||||||
)
|
)
|
||||||
|
|
||||||
url = cls.get_tool_file_url(tool_file_id=file.id, extension=guess_extension(file.mimetype))
|
url = cls.get_tool_file_url(tool_file_id=tool_file.id, extension=guess_extension(tool_file.mimetype))
|
||||||
|
|
||||||
# check if file is image
|
# check if file is image
|
||||||
if "image" in mimetype:
|
if "image" in mimetype:
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
warn_return_any = True
|
warn_return_any = True
|
||||||
warn_unused_configs = True
|
warn_unused_configs = True
|
||||||
check_untyped_defs = True
|
check_untyped_defs = True
|
||||||
|
cache_fine_grained = True
|
||||||
|
sqlite_cache = True
|
||||||
exclude = (?x)(
|
exclude = (?x)(
|
||||||
core/model_runtime/model_providers/
|
core/model_runtime/model_providers/
|
||||||
| tests/
|
| tests/
|
||||||
|
@ -56,7 +56,6 @@ dependencies = [
|
|||||||
"opentelemetry-sdk==1.27.0",
|
"opentelemetry-sdk==1.27.0",
|
||||||
"opentelemetry-semantic-conventions==0.48b0",
|
"opentelemetry-semantic-conventions==0.48b0",
|
||||||
"opentelemetry-util-http==0.48b0",
|
"opentelemetry-util-http==0.48b0",
|
||||||
"pandas-stubs~=2.2.3.241009",
|
|
||||||
"pandas[excel,output-formatting,performance]~=2.2.2",
|
"pandas[excel,output-formatting,performance]~=2.2.2",
|
||||||
"pandoc~=2.4",
|
"pandoc~=2.4",
|
||||||
"psycogreen~=1.0.2",
|
"psycogreen~=1.0.2",
|
||||||
@ -104,7 +103,7 @@ dev = [
|
|||||||
"dotenv-linter~=0.5.0",
|
"dotenv-linter~=0.5.0",
|
||||||
"faker~=32.1.0",
|
"faker~=32.1.0",
|
||||||
"lxml-stubs~=0.5.1",
|
"lxml-stubs~=0.5.1",
|
||||||
"mypy~=1.15.0",
|
"mypy~=1.16.0",
|
||||||
"ruff~=0.11.5",
|
"ruff~=0.11.5",
|
||||||
"pytest~=8.3.2",
|
"pytest~=8.3.2",
|
||||||
"pytest-benchmark~=4.0.0",
|
"pytest-benchmark~=4.0.0",
|
||||||
@ -152,6 +151,8 @@ dev = [
|
|||||||
"types_pyOpenSSL>=24.1.0",
|
"types_pyOpenSSL>=24.1.0",
|
||||||
"types_cffi>=1.17.0",
|
"types_cffi>=1.17.0",
|
||||||
"types_setuptools>=80.9.0",
|
"types_setuptools>=80.9.0",
|
||||||
|
"pandas-stubs~=2.2.3",
|
||||||
|
"scipy-stubs>=1.15.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
4370
api/uv.lock
generated
4370
api/uv.lock
generated
File diff suppressed because it is too large
Load Diff
@ -7,4 +7,4 @@ cd "$SCRIPT_DIR/.."
|
|||||||
|
|
||||||
# run mypy checks
|
# run mypy checks
|
||||||
uv run --directory api --dev --with pip \
|
uv run --directory api --dev --with pip \
|
||||||
python -m mypy --install-types --non-interactive --cache-fine-grained --sqlite-cache .
|
python -m mypy --install-types --non-interactive ./
|
||||||
|
Loading…
x
Reference in New Issue
Block a user