edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

Improve the Transaction docs to include patterns for unbound variables

Open scotttrinh opened this issue 1 year ago • 0 comments

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

scotttrinh avatar Nov 27 '24 20:11 scotttrinh