burr icon indicating copy to clipboard operation
burr copied to clipboard

Linter for action reads in state, function-based-actions

Open elijahbenizzy opened this issue 1 year ago • 1 comments

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.

  1. The state parameter is not overwritten with another state parameter
  2. Only strings in reads
  3. 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.

elijahbenizzy avatar Oct 24 '24 21:10 elijahbenizzy

See this claude chat to get started! https://claude.site/artifacts/502ab996-3352-4809-bd35-4a3493e1583d

elijahbenizzy avatar Oct 24 '24 22:10 elijahbenizzy