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

Improve the Transaction docs to include patterns for unbound variables #553

Open
scotttrinh opened this issue Nov 27, 2024 · 0 comments
Open

Comments

@scotttrinh
Copy link

Our current Transaction API makes it slightly more difficult to use variables bound within the transaction block, since linters and other static analysis tools cannot know that the iterator is every invoked on our transaction iterable. Given that, we should give better examples of how to deal with those tools, and explain more of the philosophy here.

Suggested pattern is:

my_var = None

async for tx in client.transaction():
   async with tx:
       my_var =assert my_var is not None

# use my_var without linter warnings or errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant