Skip to content

test(api): strictly type agent prompt and skill package tests - #45221

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
ShousenZHANG:refactor/agent-service-test-types
Nov 1, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
ShousenZHANG:refactor/agent-service-test-types

Conversation

@ShousenZHANG

Copy link
Copy Markdown
Contributor

Summary

Refs #24645, following #45180.

Enable strict Pyrefly checking for the Agent prompt-mention and skill-package tests. Annotate the existing tests and resolver, match the ZIP read error-injection helper to ZipFile.read's password parameter, and remove the unused-lambda-parameter Ruff exception.

 tests/unit_tests/pyrefly.toml — project-excludes
- services/agent/test_prompt_mentions.py
- services/agent/test_skill_package_service.py

The tests continue to exercise real Agent configuration objects and ZIP archives. Existing cases and assertions are preserved.

Evidence

  • Pyrefly 1.4.0: 36 strict errors before, zero after. Full unit-test, container-test and production type checks pass.
  • Both target files reach 100% type coverage: prompt mentions 11/34 → 34/34 typed symbols; skill packages 26/36 → 36/36.
  • All 67 tests pass on main and this branch, with identical ordered test IDs. The 80 assertions retain their logic; only an unused lambda argument is renamed.
  • Full Ruff format/check, 78 import contracts, response-contract lint, generated billing-client verification and all eight CI guards pass. Guards compare against the merge base.

Production type checking uses the Tencent provider source path for the Windows worktree. Tests run through the local Windows wrapper for readline/libmagic.

Merge Danger

Reversible; scope is two test modules and their check exclusions. Given valid pytest fixtures, tests preserve the existing parsing, normalization and error assertions. Production behavior is unchanged.

Screenshots

Before After
N/A: test typing and check configuration N/A

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

Backend commands were run individually on Windows; there are no frontend or documentation changes.

From Codex

Copilot AI balanced review requested due to automatic review settings November 1, 2026 03:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-01 03:17:12.560136869 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-01 03:16:45.768094167 +0000
@@ -5848,8 +5848,6 @@
     --> tests/unit_tests/services/agent/test_roster_service.py:5544:35
 ERROR Object of class `object` has no attribute `agent_role` [missing-attribute]
     --> tests/unit_tests/services/agent/test_roster_service.py:5614:16
-ERROR Argument `object` is not assignable to parameter `pwd` with type `bytes | None` in function `zipfile.ZipFile.read` [bad-argument-type]
-   --> tests/unit_tests/services/agent/test_skill_package_service.py:327:44
 ERROR Object of class `NoneType` has no attribute `node_job_config_dict` [missing-attribute]
    --> tests/unit_tests/services/agent/test_workflow_publish_service.py:601:49
 ERROR Object of class `NoneType` has no attribute `node_job_config_dict` [missing-attribute]

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 81.57% 81.60% +0.03%
Strict coverage 81.22% 81.25% +0.03%
Typed symbols 85,604 85,637 +33
Untyped symbols 19,423 19,390 -33
Modules 4396 4396 0

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.85%. Comparing base (5336037) to head (6ccafea).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #45221      +/-   ##
==========================================
- Coverage   89.85%   89.85%   -0.01%     
==========================================
  Files        6249     6249              
  Lines      398125   398125              
  Branches    80223    80223              
==========================================
- Hits       357737   357735       -2     
- Misses      34076    34079       +3     
+ Partials     6312     6311       -1     
Flag Coverage Δ
api 89.71% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Nov 1, 2026
@asukaminato0721 asukaminato0721 self-assigned this Nov 1, 2026
Merged via the queue into langgenius:main with commit 170dbae Nov 1, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants