Skip to content

test(api): bring the advanced prompt transform tests under strict pyrefly - #45968

Merged
asukaminato0721 merged 8 commits into
langgenius:mainfrom
yetuge:test/pyrefly-r8
Nov 16, 2026
Merged

asukaminato0721 merged 8 commits into
langgenius:mainfrom
yetuge:test/pyrefly-r8

Conversation

@yetuge

@yetuge yetuge commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Summary

core/prompt/test_advanced_prompt_transform.py was excluded from strict pyrefly. Annotating it lets the module leave the exclusion list.

  • added -> None to the test functions
  • typed the get_chat_model_args fixture with a shared ChatModelArgs alias carrying the real entity types
  • narrowed the deliberate invalid cast(list, ...) to list[ChatModelMessage]

Tests

  • pyrefly check (strict preset): 0 diagnostics.
  • ruff check / ruff format --check: clean.
  • pytest: 14 passed.

@yetuge
yetuge requested a review from QuantumGhost as a code owner November 10, 2026 06:23
@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 86.55% 86.57% +0.02%
Strict coverage 86.21% 86.23% +0.02%
Typed symbols 93,715 93,737 +22
Untyped symbols 14,617 14,599 -18
Modules 4599 4599 0

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.35%. Comparing base (ab7bbed) to head (6683d76).
⚠️ Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #45968      +/-   ##
==========================================
- Coverage   90.41%   90.35%   -0.06%     
==========================================
  Files        6334     6370      +36     
  Lines      396673   402877    +6204     
  Branches    79711    80658     +947     
==========================================
+ Hits       358637   364014    +5377     
- Misses      31928    32451     +523     
- Partials     6108     6412     +304     
Flag Coverage Δ
api 90.01% <ø> (-0.10%) ⬇️

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 self-assigned this Nov 12, 2026
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Nov 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 12, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-16 13:05:47.962405141 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-16 13:05:32.806259049 +0000
@@ -3940,8 +3940,6 @@
     --> tests/unit_tests/core/plugin/impl/test_plugin.py:1900:24
 ERROR `in` is not supported between `Literal['Service temporarily unavailable']` and `None` [not-iterable]
     --> tests/unit_tests/core/plugin/impl/test_plugin.py:1917:24
-ERROR Argument `Literal['x']` is not assignable to parameter `edition_type` with type `Literal['basic', 'jinja2'] | None` in function `graphon.prompt_entities.ChatModelMessage.model_construct` [bad-argument-type]
-   --> tests/unit_tests/core/prompt/test_advanced_prompt_transform.py:333:115
 ERROR Argument `dict[str, str]` is not assignable to parameter `reranking_model` with type `RerankingModelDict | None` in function `core.rag.data_post_processor.data_post_processor.DataPostProcessor.__init__` [bad-argument-type]
   --> tests/unit_tests/core/rag/data_post_processor/test_data_post_processor.py:28:37
 ERROR Argument `dict[str, str]` is not assignable to parameter `weights` with type `WeightsDict | None` in function `core.rag.data_post_processor.data_post_processor.DataPostProcessor.__init__` [bad-argument-type]

@asukaminato0721 asukaminato0721 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.

ci

@yetuge

yetuge commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

CI is fixed: merged current main (resolving the pyrefly.toml conflict) and added one documented # pyrefly: ignore[bad-argument-type] for the deliberately invalid edition_type="x", since pyrefly 1.5 now type-checks model_construct. Style Check, pyrefly-diff, codecov and both API unit shards are green — could you take another look?

@asukaminato0721 asukaminato0721 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.

4 inline suggestions at e8dde5c205, each from a rule learned from earlier reviews in this repository. Reply on a comment if it is wrong.

dify-codereview

@asukaminato0721 asukaminato0721 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.

1 inline suggestion at 52eca9f826, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong. 4 review threads are still unresolved.

dify-codereview

@asukaminato0721 asukaminato0721 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.

Checked 6683d76b2a. 4 review threads are still unresolved.

dify-codereview

@yetuge

yetuge commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

All four threads are addressed and resolved: the invalid-input cases were removed, the no-memory test uses the real token-budget calculation, and the remaining stubs are explained in-line. CI is green on 6683d76b; could you re-review?

@asukaminato0721 asukaminato0721 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.

Nothing to flag at 6683d76b2a.

dify-codereview

@asukaminato0721
asukaminato0721 dismissed stale reviews from themself November 16, 2026 13:25

Nothing left to flag at 6683d76.

@asukaminato0721 asukaminato0721 added the waiting-for-reviewer dify-codereview: checked, nothing left for the author; a reviewer's turn label Nov 16, 2026
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Nov 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 16, 2026
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into langgenius:main with commit 0ba3c9d Nov 16, 2026
51 checks passed
MindOfqc added a commit to MindOfqc/dify that referenced this pull request Nov 17, 2026
Upstream graduated test_advanced_prompt_transform.py under langgenius#45968 at the same
time as this branch, so take the upstream rewrite of that test file (it already
carries strict types) and keep this branch's other graduates; pyrefly.toml is
rebuilt by set arithmetic from the merge base, this branch and upstream.
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. waiting-for-reviewer dify-codereview: checked, nothing left for the author; a reviewer's turn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants