Fix: repair the 54 undefined names under tests/ and contributing/, and lint for them - #233
Open
AmaadMartin wants to merge 5 commits into
Open
Fix: repair the 54 undefined names under tests/ and contributing/, and lint for them#233AmaadMartin wants to merge 5 commits into
AmaadMartin wants to merge 5 commits into
Conversation
added 5 commits
August 11, 2026 17:47
Three workflow test modules use Any, AsyncGenerator, Context and RequestInput without importing them. The RequestInput uses sit in runtime yield position, so they raise NameError whenever the node runs.
MockTool and ToolReturningGenAiPartsPlugin do not exist anywhere in the repository. The fixtures produce Mock and MultimodalToolResultsPlugin.
An unconditional module-level skip has disabled this file since the initial import. It calls UnitFlow and _context_formatter, which have never existed, so removing the skip raises NameError. The behaviour it targeted is covered by tests/unittests/flows/llm_flows/test_instructions.py.
…tive mode The module imports root_agent directly and has no name agent, so interactive mode raised NameError before it could start a runner.
The existing ruff hook is scoped to src/ and mypy excludes tests/ and contributing/samples/, so nothing looked for undefined names there.
This was referenced Aug 12, 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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
N/A
Problem:
ruff check tests/ contributing/ --select F821reports 54 undefined names. No tool in the repo looks for them: the ruff pre-commit hook is scopedfiles: ^src/,lint.selectis["F401"], and mypy excludestests/andcontributing/samples/. Three of the 54 are realNameErrors that a marker or a skip currently hides. The rest are missing imports and two names that never existed.Solution: I repaired all 54 findings and added a second ruff pre-commit hook that runs
--select F821overtests/andcontributing/, so the class of defect cannot come back. I used a separate hook rather than widening the existingfiles: ^src/pattern, because an explicit--selecton the command line replaces the configured select for that run. Widening the existing hook would instead applyF401totests/, which is a much larger and unrelated change. No# noqasuppressions.What changed, by finding:
test_workflow_schema.py(40),test_workflow_node.py(1),test_workflow_parallel_worker.py(2) — added the missingAny,AsyncGenerator,ContextandRequestInputimports.test_multimodal_tool_results_plugin.py(6) —MockToolandToolReturningGenAiPartsPluginare phantom names that exist nowhere in the repository. Themock_toolfixture returnsMock(spec=BaseTool)and thepluginfixture returnsMultimodalToolResultsPlugin, so I annotated them with those types.contributing/samples/models/interactions_api/main.py(1) —test_agent = agent.root_agentbecomestest_agent = root_agent. The module importsroot_agentdirectly and has no nameagent, so interactive mode crashed on entry. The sibling function 50 lines above already uses the correct form.tests/integration/test_system_instruction.py(4) — deleted. Please object if you want it kept. An unconditionalpytest.skip(allow_module_level=True)under the comment# Skip until fixed.has disabled it since the initial import commit. It callsUnitFlow()and_context_formatter, which appear nowhere else in this repository and have nofrom __future__ import annotationsto make them inert, so removing the skip raisesNameErroron the first test. CI does not runtests/integration, and instruction and context-variable population is covered by the 36 tests intests/unittests/flows/llm_flows/test_instructions.py.Two genuine
NameErrors are repaired:RequestInputandagent.root_agent.Collision check. I ran
gh pr listand checked every open PR for these files. No open PR makes this change. Three overlap without conflicting: #168 widens thesrc/ruff hook forF401and removes unused imports from two of these files, #141 and #180 change a fixture decorator in the multimodal test. My hunks do not touch the same lines, so I branched frommainrather than stacking. #200 selectsF821forsrc/only and touches a disjoint file set.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
This change adds no executable product code, so it adds no test cases. The regression guard is the new hook. I proved it fails by reintroducing the defects it must catch.
Mutation runs, to prove each guard fails on the defect it pins:
from typing import Anyfromtest_workflow_schema.pyand restoredagent.root_agentin the sample, then ran the hook. It failed:ruff undefined-name check (tests, contributing)......Failed,Found 22 errors(20Any, 2agent). Restoring both lines returns it toPassed.RequestInputimport and rantest_parallel_worker_pauses_for_human_inputwith--runxfail. It failed at line 446 withNameError: name 'RequestInput' is not defined, before reaching a single assertion. With the import, the same run reaches its assertions and fails on the node path:('...Worker@1/Worker@1', ...) != ('...Worker@1', ...).That second run answers the xfail question.
test_parallel_worker_pauses_for_human_inputstill XFAILs after the fix, so theNameErrorwas not why it failed and the markerctx.run_node needs barrier for parallel HITLis still accurate. I left both thexfailand theskipmarkers untouched.Unit Tests:
Manual End-to-End (E2E) Tests:
The
interactions_apisample needs live model credentials, so I did not run it. The line-375 fix is verified by inspection against the identical working line 324, and by ruff reporting zeroF821.Checklist
CI
Unit Tests (3.10-3.14), A2A v0.3 Tests (3.10-3.14) and Mypy Check (3.10-3.13) all pass. The new hook passes:
ruff undefined-name check (tests, contributing)......Passed.Pre-commit Linter fails on one unrelated hook,
update-constraints. It regenerates the constraints files with today's--exclude-newerdate and then reports the tree as dirty. This is not my change: the same job fails on the same hook at my base commit352d11d3, and PRs #163, #213, #214 and #225 already address it.