Skip to content

fix(typing): runtime NameError in DictBasedTypingSystem.construct_state, correct ActionSchema abstract signatures#808

Open
adawang1210 wants to merge 1 commit into
apache:mainfrom
adawang1210:fix/action-schema-abstract-signatures
Open

fix(typing): runtime NameError in DictBasedTypingSystem.construct_state, correct ActionSchema abstract signatures#808
adawang1210 wants to merge 1 commit into
apache:mainfrom
adawang1210:fix/action-schema-abstract-signatures

Conversation

@adawang1210

Copy link
Copy Markdown
Contributor

Summary

DictBasedTypingSystem.construct_state() crashed with NameError: name 'State' is not defined whenever it was actually called -- State is only imported under TYPE_CHECKING in burr/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.py calls self.typing_system.construct_state(state)). Additionally, ActionSchema's abstract methods were declared without self, contradicting every concrete implementation (DefaultSchema, the pydantic integration), and an unused Self import fallback was dead code.

Changes made

  • burr/core/typing.py:
    • construct_state now imports State locally at runtime (module-level would be circular -- state.py imports from typing.py), fixing the NameError.
    • ActionSchema.state_input_type / state_output_type / intermediate_result_type abstract declarations now take self, matching all implementations.
    • Removed the unused try: from typing import Self fallback (never referenced).
  • tests/core/test_typing.py (new): covers DictBasedTypingSystem behavior including the previously-crashing construct_state, a conforming ActionSchema subclass, ABC enforcement for incomplete subclasses, and DEFAULT_SCHEMA semantics.

How to test

pytest tests/core/test_typing.py

Repro of the bug on main:

from burr.core.typing import DictBasedTypingSystem
DictBasedTypingSystem().construct_state({"a": 1})  # NameError before this fix

Checklist

  • Tests added or updated
  • All tests pass locally (pytest tests/ --ignore=tests/integration_tests: 577 passed, 5 skipped)
  • Commits signed off (git commit -s)
  • Pre-commit hooks pass (black, isort, flake8)
  • CONTRIBUTING.md guidelines followed

…ncorrect ActionSchema signatures

Signed-off-by: adawang <adawang12101210@gmail.com>
@github-actions github-actions Bot added area/core Application, State, Graph, Actions area/typing Mypy, type hints, pydantic labels Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Application, State, Graph, Actions area/typing Mypy, type hints, pydantic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant