You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Managing Resources section of Advanced Patterns, there is a code example where a Repo class is used as a context manager to be passed to Context.with_resource.
The __enter__ method on Repo currently returns None, which means that the code snippet below is broken since repo is None (the result of __enter__()).
withRepo() asrepo:
repo.db.query(...)
In the snippet below that, we are also assigning None to ctx.obj, since ctx.with_resource returns the result of calling the resource’s __enter__() method.
In the Managing Resources section of Advanced Patterns, there is a code example where a
Repo
class is used as a context manager to be passed toContext.with_resource
.The
__enter__
method onRepo
currently returnsNone
, which means that the code snippet below is broken sincerepo
isNone
(the result of__enter__()
).In the snippet below that, we are also assigning
None
toctx.obj
, sincectx.with_resource
returns the result of calling the resource’s__enter__()
method.The fix is to have
Repo.__enter__
returnself
.The text was updated successfully, but these errors were encountered: