Skip to content

test(api): stop excluding five core test modules from strict pyrefly - #45336

Merged
asukaminato0721 merged 4 commits into
langgenius:mainfrom
shi-felix:test/api-core-strict-batch2
Nov 3, 2026
Merged

asukaminato0721 merged 4 commits into
langgenius:mainfrom
shi-felix:test/api-core-strict-batch2

Conversation

@shi-felix

Copy link
Copy Markdown
Contributor

Summary

Part of the strict Pyrefly rollout for api/tests/unit_tests. Bring five more core-side test modules back under strict Pyrefly checking by removing them from project-excludes and fixing the diagnostics that the exclusion previously hid.

No production code changes.

Modifies

  • api/tests/unit_tests/pyrefly.toml: drop five core/ exclusions.
  • api/tests/unit_tests/core/app/apps/workflow/test_command_channels.py: annotate the _CommandChannelStub helpers with graphon.engine.command.Command.
  • api/tests/unit_tests/core/agent/test_base_agent_runner.py: annotate the json.dumps side-effect helper.
  • api/tests/unit_tests/core/app/app_config/easy_ui_based_app/model_config/test_manager.py: add return annotations and two targeted # pyrefly: ignore[...] comments.
  • api/tests/unit_tests/core/app/layers/test_conversation_variable_persist_layer.py: add -> None return annotations.
  • api/tests/unit_tests/core/workflow/nodes/agent_v2/test_session_store.py: annotate the SQLAlchemy event listener and one local dict.

The edits are type annotations and # pyrefly: ignore[...] comments; test behavior is unchanged.

Tests

  • pyrefly check --config tests/unit_tests/pyrefly.toml --use-ignore-files=false --disable-project-excludes-heuristics=true over the five files: 0 diagnostics.
  • Full-tree pyrefly check --config tests/unit_tests/pyrefly.toml reports the same 11 pre-existing missing-optional-dependency diagnostics as the unmodified tree; no new diagnostics.
  • ruff check and ruff format --check pass on all five touched files.
  • pytest for the five modules could not run in this environment because the local Python environment is missing optional alibabacloud transitive dependencies pulled in by the unit-test conftest import chain; the changes are annotations only, so no runtime behavior is affected.

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

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-03 02:40:22.576454240 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-03 02:40:11.024291447 +0000
@@ -3166,8 +3166,6 @@
    --> tests/unit_tests/core/agent/test_fc_agent_runner.py:717:29
 ERROR Missing argument `description` in function `core.agent.plugin_entities.AgentStrategyEntity.__init__` [missing-argument]
    --> tests/unit_tests/core/agent/test_plugin_entities.py:292:32
-ERROR Argument `dict[str, dict[str, str | dict[str, float | list[str]]]]` is not assignable to parameter `config` with type `AppModelConfigDict` in function `core.app.app_config.easy_ui_based_app.model_config.manager.ModelConfigManager.convert` [bad-argument-type]
-   --> tests/unit_tests/core/app/app_config/easy_ui_based_app/model_config/test_manager.py:368:45
 ERROR Argument `dict[Unknown, Unknown]` is not assignable to parameter `config` with type `AppModelConfigDict` in function `core.app.app_config.easy_ui_based_app.variables.manager.BasicVariablesConfigManager.convert` [bad-argument-type]
   --> tests/unit_tests/core/app/app_config/easy_ui_based_app/variables/test_manager.py:14:67
 ERROR Argument `dict[str, list[dict[str, bool | str | dict[str, str]] | dict[str, bool]]]` is not assignable to parameter `config` with type `AppModelConfigDict` in function `core.app.app_config.easy_ui_based_app.variables.manager.BasicVariablesConfigManager.convert` [bad-argument-type]
@@ -5286,12 +5284,6 @@
     --> tests/unit_tests/core/workflow/nodes/agent_v2/test_runtime_request_builder.py:1811:68
 ERROR Cannot index into `object` [bad-index]
     --> tests/unit_tests/core/workflow/nodes/agent_v2/test_runtime_request_builder.py:1812:14
-ERROR `not in` is not supported between `Literal['agent_workspace_binding_id']` and `None` [not-iterable]
-   --> tests/unit_tests/core/workflow/nodes/agent_v2/test_session_store.py:475:12
-ERROR Argument `dict[str, str]` is not assignable to parameter `process_data` with type `dict[str, object] | None` in function `_execution_row` [bad-argument-type]
-   --> tests/unit_tests/core/workflow/nodes/agent_v2/test_session_store.py:558:69
-ERROR `not in` is not supported between `Literal['agent_workspace_binding_id']` and `None` [not-iterable]
-   --> tests/unit_tests/core/workflow/nodes/agent_v2/test_session_store.py:567:12
 ERROR Argument `_GraphParams` is not assignable to parameter `init_params` with type `InitParams` in function `core.workflow.nodes.datasource.datasource_node.DatasourceNode.__init__` [bad-argument-type]
    --> tests/unit_tests/core/workflow/nodes/datasource/test_datasource_node.py:105:21
 ERROR Argument `_GraphState` is not assignable to parameter `runtime_state` with type `RuntimeState` in function `core.workflow.nodes.datasource.datasource_node.DatasourceNode.__init__` [bad-argument-type]

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 83.00% 83.01% +0.00%
Strict coverage 82.66% 82.66% +0.00%
Typed symbols 85,596 85,601 +5
Untyped symbols 17,603 17,598 -5
Modules 4373 4373 0

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.77%. Comparing base (96b1b20) to head (1c69d22).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #45336   +/-   ##
=======================================
  Coverage   89.77%   89.77%           
=======================================
  Files        6239     6239           
  Lines      390902   390924   +22     
  Branches    79285    79291    +6     
=======================================
+ Hits       350932   350957   +25     
+ Misses      33872    33868    -4     
- Partials     6098     6099    +1     
Flag Coverage Δ
api 89.63% <ø> (-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.

Use `ParamSpec` for the `*args`/`**kwargs` of the `json.dumps` stand-in so the forwarded call no longer needs a `pyrefly: ignore[bad-argument-type]` comment.
pyrefly only accepts `P.args`/`P.kwargs` when the ParamSpec is declared on the function itself, so use the PEP 695 inline form instead of a module-level `ParamSpec` instance.
pyrefly rejects `P.args`/`P.kwargs` from an unbound ParamSpec ("Expected a type form, got instance of ParamSpecArgs") and still complains about unpacking `dict[str, object]` into the named `json.dumps` parameters.

The module under test only ever calls `json.dumps(value)` or `json.dumps(value, ensure_ascii=False)`, so declare exactly that: an explicit `ensure_ascii` keyword. This removes the escape hatch without changing what the test exercises.
@shi-felix

Copy link
Copy Markdown
Contributor Author

P.args/P.kwargs don't survive pyrefly here — an unbound ParamSpec is rejected (Expected a type form, got instance of ParamSpecArgs), and the PEP 695 inline form def f[**P](...) gets past the parser but then fails on the forward with nine Unpacked keyword argument object is not assignable to parameter ... errors.

Since base_agent_runner only ever calls json.dumps(value) or json.dumps(value, ensure_ascii=False), the stand-in now mirrors exactly that:

def dumps_side_effect(value: object, *, ensure_ascii: bool = True) -> str:
    if value in (tool_input, observation, tool_meta) and ensure_ascii is False:
        raise TypeError("fail")
    return real_dumps(value, ensure_ascii=ensure_ascii)

The pyrefly: ignore[bad-argument-type] is gone. Pushed as 1c69d22; Style Check is green.

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Nov 3, 2026
@asukaminato0721 asukaminato0721 self-assigned this Nov 3, 2026
Merged via the queue into langgenius:main with commit dc36c3e Nov 3, 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.

2 participants