Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
elijahbenizzy opened this issue Oct 24, 2024 · 1 comment
Open

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

elijahbenizzy opened this issue Oct 24, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Contributors wanted!

Comments

@elijahbenizzy
Copy link
Contributor

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 elijahbenizzy added enhancement New feature or request help wanted Contributors wanted! labels Oct 24, 2024
@elijahbenizzy
Copy link
Contributor Author

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

@elijahbenizzy elijahbenizzy added the good first issue Good for newcomers label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Contributors wanted!
Projects
None yet
Development

No branches or pull requests

1 participant