Repository navigation
test(api): bring the list operator node tests under strict pyrefly - #46308
Merged
asukaminato0721 merged 4 commits intoNov 15, 2026
Merged
Conversation
Annotate the fixture chain in `test_list_operator.py`, build a real `InitParams` instead of a bare `MagicMock`, and drop the module's strict-mode exemption.
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-11-13 15:56:36.901753714 +0000
+++ /tmp/pyrefly_pr.txt 2026-11-13 15:56:14.079637710 +0000
@@ -1664,6 +1664,8 @@
--> tests/e2e_tests/contracts/core/workflow/nodes/test_if_else.py:388:19
ERROR Argument `dict[str, list[dict[str, list[dict[str, list[str] | str]] | str]] | str]` is not assignable to parameter `node_data` with type `IfElseNodeData | dict[str, object]` in function `_build_if_else_node` [bad-argument-type]
--> tests/e2e_tests/contracts/core/workflow/nodes/test_if_else.py:453:19
+ERROR Object of class `FunctionType` has no attribute `return_value` [missing-attribute]
+ --> tests/e2e_tests/contracts/core/workflow/nodes/test_list_operator.py:103:5
ERROR `Literal['{invalid-json-schema']` is not assignable to attribute `json_schema` with type `dict[str, Any] | None` [bad-assignment]
--> tests/e2e_tests/contracts/core/workflow/nodes/test_start_node_json_object.py:209:28
ERROR Argument `_StubToolRuntime` is not assignable to parameter `runtime` with type `ToolNodeRuntimeProtocol` in function `graphon.nodes.tool.tool_node.ToolNode.__init__` [bad-argument-type]
|
Contributor
Pyrefly Type Coverage
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #46308 +/- ##
=======================================
Coverage 90.40% 90.41%
=======================================
Files 6334 6334
Lines 396673 396673
Branches 79711 79711
=======================================
+ Hits 358631 358644 +13
+ Misses 31933 31919 -14
- Partials 6109 6110 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Keep the runtime-state mock the tests already rely on and declare its type locally, so pyrefly can see `variable_pool.get` without the mock having to be replaced by a real `RuntimeState` the test data cannot satisfy.
asukaminato0721
requested changes
Nov 15, 2026
asukaminato0721
enabled auto-merge
November 15, 2026 08:44
The list operator fixture handed the node a `MagicMock` runtime state and then stubbed `variable_pool.get` to return the expected segment. Build the real objects instead: a `RuntimeState` over a real `VariablePool` (remembering that `workflow_id` is required), and register the source segment with `VariablePool.add`. The stub disappears and the node is exercised against the pool it actually reads from. The selector stays two segments — `[node_id, variable_name]` — because `VariablePool.get` returns `None` for anything shorter. Verified: pyrefly 29 errors / 0 warnings / 0 non-missing-import for the unit config and 0 for the e2e config, 2 tests pass, ruff clean.
# Conflicts: # api/tests/unit_tests/pyrefly.toml
auto-merge was automatically disabled
November 15, 2026 09:37
Head branch was pushed to by a user without write access
Contributor
Author
|
Replaced the mocks with real objects.
|
asukaminato0721
approved these changes
Nov 15, 2026
This was referenced Nov 16, 2026
This was referenced Nov 16, 2026
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
api/tests/e2e_tests/contracts/core/workflow/nodes/test_list_operator.pystill sits inproject-excludesinapi/tests/unit_tests/pyrefly.toml, so the strict preset has never checked it. Under strict checking it reports six diagnostics along the fixture chain_build_list_operator_node→list_operator_node→ the tests that consume it.What changed
_build_list_operator_node(node_data: ListOperatorNodeData, graph_init_params: InitParams) -> ListOperatorNodelist_operator_node() -> ListOperatorNodetest_filter_files_by_type(list_operator_node: ListOperatorNode) -> Nonetest_get_file_extract_string_func() -> NoneMagicMocklocally so pyrefly can seevariable_pool.get.return_valueon them.project-excludes(208 → 207 entries).No
# pyrefly: ignore, no# type: ignore, notyping.cast.A note on what this does not do
An earlier revision of this branch replaced the
MagicMock()standing in for graph init parameters with a realInitParams, and the runtime state mock with a realRuntimeState. That satisfied pyrefly but broke the test:VariablePool.getreturnsNonewhen the selector is shorter thanSELECTORS_LENGTH(2), and this fixture deliberately uses a single-segment selector["test_variable"]— the mock is what makes the variable resolve at all. Constructing a realRuntimeStatealso requires eitherworkflow_idorgraph_execution, which the fixture does not model.So this branch keeps the mocks and narrows their types instead. That is the honest shape of the change: the module was exempt not because it uses mocks, but because its annotations were missing.
How to verify
Project-wide check from
api/tests/unit_tests/, using the GitHub output format the CI job uses:INFO 29 diagnostics, allmissing-importnotes from packages absent in a local venv. CI installs the full dependency set, so they do not appear there.missing-import, zeroWARN, none in the touched file.Note that
min-severity = "warn"inpyrefly.toml, so a strayWARNfailsmake type-check-corejust like anERROR. The first push of this branch did leave one such warning (Object of class FunctionType has no attribute return_valueat line 103) and CI caught it — that is what the local mock-type declarations fix.Mutation check: reverting only
test_list_operator.pywhile keeping the exemption removed raises the count to 35 and reproduces exactly the six original diagnostics.Tests:
pytest api/tests/e2e_tests/contracts/core/workflow/nodes/test_list_operator.py→ 2 passed, unchanged from before.ruff checkandruff format --checkboth pass.