-
Notifications
You must be signed in to change notification settings - Fork 119
Open
Labels
Description
For class-based actions, mypy is not happy with parameters to be defined in the method signature of the run method.
Current behavior
I have copied the class-based action example from doc:
from burr.core import Action, State, ApplicationContext
class Counter(Action):
@property
def reads(self) -> list[str]:
return ["counter"]
def run(self,
state: State,
increment_by: int,
# add __context here
__context: ApplicationContext) -> dict:
# can access the app_id from the __context
print(__context.app_id, __context.partition_key, __context.sequence_id)
return {"counter": state["counter"] + increment_by}
@property
def writes(self) -> list[str]:
return ["counter"]
def update(self, result: dict, state: State) -> State:
return state.update(**result)
@property
def inputs(self) -> list[str]:
# add __context here
return ["increment_by", "__context"]Then mypy is not happy with it with errors:
mypy src/demo_application.py
src/demo_application.py:8: error: Signature of "run" incompatible with supertype "Function" [override]
src/demo_application.py:8: note: Superclass:
src/demo_application.py:8: note: def run(self, state: State[Any], **run_kwargs: Any) -> dict[Any, Any]
src/demo_application.py:8: note: Subclass:
src/demo_application.py:8: note: def run(self, state: State[Any], increment_by: int, ApplicationContext, /) -> dict[Any, Any]
Found 1 error in 1 file (checked 1 source file)Library & System Information
uv pip list | grep mypy
mypy 1.13.0
mypy-extensions 1.0.0
uv pip list | grep burr
burr 0.34.1
python --version
Python 3.12.5Reactions are currently unavailable