fix(typing): runtime NameError in DictBasedTypingSystem.construct_state, correct ActionSchema abstract signatures#808
Open
adawang1210 wants to merge 1 commit into
Conversation
…ncorrect ActionSchema signatures Signed-off-by: adawang <adawang12101210@gmail.com>
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.
Summary
DictBasedTypingSystem.construct_state()crashed withNameError: name 'State' is not definedwhenever it was actually called --Stateis only imported underTYPE_CHECKINGinburr/core/typing.py. This is reachable from the public API:ApplicationBuilder.with_state(<non-State object>)with a dict-based typing system hits this path (application.pycallsself.typing_system.construct_state(state)). Additionally,ActionSchema's abstract methods were declared withoutself, contradicting every concrete implementation (DefaultSchema, the pydantic integration), and an unusedSelfimport fallback was dead code.Changes made
burr/core/typing.py:construct_statenow importsStatelocally at runtime (module-level would be circular --state.pyimports fromtyping.py), fixing theNameError.ActionSchema.state_input_type/state_output_type/intermediate_result_typeabstract declarations now takeself, matching all implementations.try: from typing import Selffallback (never referenced).tests/core/test_typing.py(new): coversDictBasedTypingSystembehavior including the previously-crashingconstruct_state, a conformingActionSchemasubclass, ABC enforcement for incomplete subclasses, andDEFAULT_SCHEMAsemantics.How to test
Repro of the bug on main:
Checklist
pytest tests/ --ignore=tests/integration_tests: 577 passed, 5 skipped)git commit -s)