Linter for action reads in state, function-based-actions
Is your feature request related to a problem? Please describe. I want to be able to quickly fail should I attempt to read the wrong state item.
@action(reads=["foo"], ...)
def my_action(state: State) -> State:
bar = state["bar"] # not in reads...
...
We know for sure that this should fail.
Describe the solution you'd like A checker to warn this. We won't be able to catch all cases (for whatever reason), but given the following assumptions (that we can check for), we should be able to get it working to be correct.
- The
stateparameter is not overwritten with another state parameter - Only strings in
reads - State access is done with brackets
Then we can walk through the AST to (a) ensure this and (b) check that all state parameters if that's the case.
Describe alternatives you've considered Having a better error message, adding that as well.
Additional context Just developing and liked this idea
This is not an easy bit of coding (I'm sure chatGPT can help), but it's self-contained and very testable, so should be doable for most engineers.
See this claude chat to get started! https://claude.site/artifacts/502ab996-3352-4809-bd35-4a3493e1583d