apache / apache/burr

typing: `Application.step()`

Open
#353 2 comments 0 reactions 0 assignees View on GitHub
area/core area/typing kind/improvement priority/low
Dominant language
Python
Stars
2.5k
Forks
195
Avg merge
6d 10h
Merged PRs (30d)
17

Description

Currently, `Application.step()` gives a bunch of squiggly red lines when trying to unpack the return value.

![image](https://github.com/user-attachments/assets/27384a41-87b2-46c7-ba9c-d76891090837)

This is because `.step()` is annotated as follow, potentially returning `None`, which can't be unpacked

```python
def step(self, inputs: Optional[Dict[str, Any]] = None) -> Optional[Tuple[Action, dict, State]]:
# ...
return self._step(...)

def _step(
self, inputs: Optional[Dict[str, Any]], _run_hooks: bool = True
) -> Optional[Tuple[Action, dict, State]]:
# ...
return next_action, result, new_state
```
(the return line of `._step()` also has red squiggly lines)

Does `._step()` actually ever return `None` ? If yes, would it make sense to have it return
`(None, None, None)` instead?

Having two potentially return values (the `tuple` or `None`) can be annoying to deal with if they have different "shapes". I'm guessing that directly unpacking the return value is common.

Contributor guide

Open the contributing guide

Research direction

Start with the Application.step() and _step() entry points described in the issue, and inspect every return path to determine whether either method can produce None. Align the return annotation and runtime contract with that behavior, then verify that unpacking the result no longer produces the reported type-checking warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.