From f7478e0ea2b9ed723d79e52074d3e4422a7b3d3a Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 13:38:09 +0000 Subject: [PATCH] [autofix.ci] apply automated fixes --- .../src/dify_agent/agent_stub/cli/_files.py | 8 +--- .../src/dify_agent/layers/drive/layer.py | 1 + .../dify_agent/agent_stub/cli/test_drive.py | 8 +--- .../dify_agent/agent_stub/cli/test_main.py | 38 +++++++++++++++---- .../dify_agent/layers/drive/test_layer.py | 4 +- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/dify-agent/src/dify_agent/agent_stub/cli/_files.py b/dify-agent/src/dify_agent/agent_stub/cli/_files.py index 38388cf097e..9c3c017c51f 100644 --- a/dify-agent/src/dify_agent/agent_stub/cli/_files.py +++ b/dify-agent/src/dify_agent/agent_stub/cli/_files.py @@ -140,18 +140,14 @@ def _build_download_mapping( ) -> AgentStubFileMapping: if mapping is not None: if transfer_method is not None or reference_or_url is not None: - raise AgentStubValidationError( - "--mapping cannot be combined with TRANSFER_METHOD or REFERENCE_OR_URL" - ) + raise AgentStubValidationError("--mapping cannot be combined with TRANSFER_METHOD or REFERENCE_OR_URL") try: return AgentStubFileMapping.model_validate_json(mapping) except ValidationError as exc: raise AgentStubValidationError("invalid file download mapping") from exc if transfer_method is None or reference_or_url is None: - raise AgentStubValidationError( - "file download requires either --mapping or TRANSFER_METHOD REFERENCE_OR_URL" - ) + raise AgentStubValidationError("file download requires either --mapping or TRANSFER_METHOD REFERENCE_OR_URL") normalized_transfer_method = cast( Literal["local_file", "tool_file", "datasource_file", "remote_url"], diff --git a/dify-agent/src/dify_agent/layers/drive/layer.py b/dify-agent/src/dify_agent/layers/drive/layer.py index 6812bf4900b..bc043e48193 100644 --- a/dify-agent/src/dify_agent/layers/drive/layer.py +++ b/dify-agent/src/dify_agent/layers/drive/layer.py @@ -62,6 +62,7 @@ class DifyDriveLayerError(RuntimeError): class DifyDriveDeps(LayerDeps): execution_context: Layer[Any, Any, Any, Any, Any, Any] # pyright: ignore[reportUninitializedInstanceVariable] + @dataclass(slots=True) class DifyDriveLayer(PlainLayer[DifyDriveDeps, DifyDriveLayerConfig, EmptyRuntimeState]): """Drive runtime layer that eagerly materializes prompt-mentioned drive targets.""" diff --git a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.py b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.py index c1773165bc1..613580eae2d 100644 --- a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.py +++ b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_drive.py @@ -90,9 +90,7 @@ def test_format_drive_manifest_returns_human_readable_listing(monkeypatch: pytes fake_manifest, ) - result = format_drive_manifest( - list_drive_manifest_from_environment(prefix="skills/") - ) + result = format_drive_manifest(list_drive_manifest_from_environment(prefix="skills/")) assert result == ("12\ttext/markdown\t-\tskills/example/SKILL.md\n-\t-\tsha256:abc\tskills/example/helper.py") assert captured["prefix"] == "skills/" @@ -529,9 +527,7 @@ def test_pull_drive_from_environment_returns_json_result( result = pull_drive_from_environment(targets=["files/a.txt"], local_base=str(tmp_path)) assert isinstance(result, DrivePullResult) - assert result.model_dump() == { - "items": [{"key": "files/a.txt", "local_path": str(tmp_path / "files" / "a.txt")}] - } + assert result.model_dump() == {"items": [{"key": "files/a.txt", "local_path": str(tmp_path / "files" / "a.txt")}]} assert (tmp_path / "files" / "a.txt").read_bytes() == b"a" diff --git a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.py b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.py index 9044ba336a6..8bdb8b2106d 100644 --- a/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.py +++ b/dify-agent/tests/local/dify_agent/agent_stub/cli/test_main.py @@ -212,7 +212,9 @@ def test_cli_file_download_supports_mapping_json( captured_kwargs.update(kwargs) return type("Response", (), {"path": Path("/tmp/inputs/report.pdf")})() - monkeypatch.setattr("dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment) + monkeypatch.setattr( + "dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment + ) with pytest.raises(SystemExit) as exc_info: main( @@ -248,7 +250,9 @@ def test_cli_file_download_rejects_legacy_positional_directory( called = True return type("Response", (), {"path": Path("/tmp/report.pdf")})() - monkeypatch.setattr("dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment) + monkeypatch.setattr( + "dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment + ) with pytest.raises(SystemExit) as exc_info: main(["file", "download", "tool_file", _reference("tool-file-1"), "/tmp"]) @@ -323,8 +327,12 @@ def test_cli_drive_pull_prints_downloaded_paths( "dify_agent.agent_stub.cli.main.pull_drive_from_environment", lambda *, targets, local_base: DrivePullResult( items=[ - DrivePullResult.Item(key=f"{targets[0]}/SKILL.md", local_path=str(Path(local_base) / targets[0] / "SKILL.md")), - DrivePullResult.Item(key=f"{targets[0]}/helper.py", local_path=str(Path(local_base) / targets[0] / "helper.py")), + DrivePullResult.Item( + key=f"{targets[0]}/SKILL.md", local_path=str(Path(local_base) / targets[0] / "SKILL.md") + ), + DrivePullResult.Item( + key=f"{targets[0]}/helper.py", local_path=str(Path(local_base) / targets[0] / "helper.py") + ), ] ), ) @@ -377,7 +385,11 @@ def test_cli_drive_pull_forwards_multiple_targets( captured_kwargs["targets"] = targets captured_kwargs["local_base"] = local_base return DrivePullResult( - items=[DrivePullResult.Item(key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md"))] + items=[ + DrivePullResult.Item( + key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md") + ) + ] ) monkeypatch.setattr( @@ -405,7 +417,11 @@ def test_cli_drive_pull_uses_environment_drive_base_default( captured_kwargs["targets"] = targets captured_kwargs["local_base"] = local_base return DrivePullResult( - items=[DrivePullResult.Item(key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md"))] + items=[ + DrivePullResult.Item( + key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md") + ) + ] ) monkeypatch.setattr( @@ -433,7 +449,11 @@ def test_cli_drive_pull_keeps_historical_drive_base_when_env_is_missing( captured_kwargs["targets"] = targets captured_kwargs["local_base"] = local_base return DrivePullResult( - items=[DrivePullResult.Item(key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md"))] + items=[ + DrivePullResult.Item( + key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md") + ) + ] ) monkeypatch.setattr( @@ -459,7 +479,9 @@ def test_cli_drive_pull_without_targets_pulls_whole_visible_drive( def fake_pull_drive_from_environment(*, targets, local_base): captured_kwargs["targets"] = targets captured_kwargs["local_base"] = local_base - return DrivePullResult(items=[DrivePullResult.Item(key="files/a.txt", local_path=str(Path(local_base) / "files" / "a.txt"))]) + return DrivePullResult( + items=[DrivePullResult.Item(key="files/a.txt", local_path=str(Path(local_base) / "files" / "a.txt"))] + ) monkeypatch.setattr( "dify_agent.agent_stub.cli.main.pull_drive_from_environment", diff --git a/dify-agent/tests/local/dify_agent/layers/drive/test_layer.py b/dify-agent/tests/local/dify_agent/layers/drive/test_layer.py index 8825c466399..eabff845160 100644 --- a/dify-agent/tests/local/dify_agent/layers/drive/test_layer.py +++ b/dify-agent/tests/local/dify_agent/layers/drive/test_layer.py @@ -309,7 +309,9 @@ async def test_download_items_hands_validated_downloads_to_materialization( ) captured: dict[str, object] = {} - def fake_materialize_drive_downloads(*, base_path: Path, downloads: list[DriveDownloadPayload], archive_skip_entry_names_by_dir): + def fake_materialize_drive_downloads( + *, base_path: Path, downloads: list[DriveDownloadPayload], archive_skip_entry_names_by_dir + ): captured["base_path"] = base_path captured["downloads"] = downloads captured["archive_skip_entry_names_by_dir"] = archive_skip_entry_names_by_dir