mirror of
https://github.com/langgenius/dify.git
synced 2026-03-16 12:27:42 +08:00
Align workflow file runtime protocols with actual httpx response behavior so strict type checks pass consistently in CI. Changes - Update HttpResponseProtocol.content to a read-only property, matching httpx.Response semantics. - Relax HttpResponseProtocol.raise_for_status return type to object, compatible with httpx returning self. - Mark _UnconfiguredWorkflowFileRuntime._raise as NoReturn to remove false positive "must return value on all code paths" errors for protocol methods. Context - Fixes type-check failures from basedpyright on: - core/app/workflow/file_runtime.py - core/workflow/file/runtime.py Verification - basedpyright on touched workflow-file modules reports 0 errors.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Generator
|
|
from typing import Protocol
|
|
|
|
|
|
class HttpResponseProtocol(Protocol):
|
|
"""Subset of response behavior needed by workflow file helpers."""
|
|
|
|
@property
|
|
def content(self) -> bytes: ...
|
|
|
|
def raise_for_status(self) -> object: ...
|
|
|
|
|
|
class WorkflowFileRuntimeProtocol(Protocol):
|
|
"""Runtime dependencies required by ``core.workflow.file``.
|
|
|
|
Implementations are expected to be provided by integration layers (for example,
|
|
``core.app.workflow.file_runtime``) so the workflow package avoids importing
|
|
application infrastructure modules directly.
|
|
"""
|
|
|
|
@property
|
|
def files_url(self) -> str: ...
|
|
|
|
@property
|
|
def internal_files_url(self) -> str | None: ...
|
|
|
|
@property
|
|
def secret_key(self) -> str: ...
|
|
|
|
@property
|
|
def files_access_timeout(self) -> int: ...
|
|
|
|
@property
|
|
def multimodal_send_format(self) -> str: ...
|
|
|
|
def http_get(self, url: str, *, follow_redirects: bool = True) -> HttpResponseProtocol: ...
|
|
|
|
def storage_load(self, path: str, *, stream: bool = False) -> bytes | Generator: ...
|
|
|
|
def sign_tool_file(self, *, tool_file_id: str, extension: str, for_external: bool = True) -> str: ...
|