adawang1210 opened a new pull request, #808:
URL: https://github.com/apache/burr/pull/808

   ## 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
   ```bash
   pytest tests/core/test_typing.py
   ```
   Repro of the bug on main:
   ```python
   from burr.core.typing import DictBasedTypingSystem
   DictBasedTypingSystem().construct_state({"a": 1})  # NameError before this 
fix
   ```
   
   ## Checklist
   - [x] Tests added or updated
   - [x] All tests pass locally (`pytest tests/ 
--ignore=tests/integration_tests`: 577 passed, 5 skipped)
   - [x] Commits signed off (`git commit -s`)
   - [x] Pre-commit hooks pass (black, isort, flake8)
   - [x] CONTRIBUTING.md guidelines followed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to