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

Remove `fga_client.close()` from the README

Open davidroeca opened this issue 8 months ago • 2 comments

It looks like .close() is called in the async __aexit__() method as well as the sync __exit__() method.

Given that context managers in python call the exit block in a similar way to a finally block, what's the motivation for recommending the calling of fga_client.close() at the end of context managers?

davidroeca avatar May 05 '25 17:05 davidroeca

👋🏽 I seem to have added that in this commit: https://github.com/openfga/sdk-generator/pull/116/commits/7ce6b65a0a263f045246375a3701dc963bcee15d, as part of the PR introducing the Python SDK: https://github.com/openfga/sdk-generator/pull/116.

TBH I do not remember why - I'll ping @evansims and @ryanpq if they believe this can be removed, and if so, we'll remove it (or accept a PR to do so).

rhamzeh avatar May 08 '25 14:05 rhamzeh

I think we'd be good to remove this. The close() looks to be redundant with the context manager. Might just be something carried over from other sdks as best practices but isn't needed in python at least from what I can see. We'd be happy to review and merge a PR that removes that in the SDK Generator and the Python SDK if you'd like to submit one @davidroeca

ryanpq avatar May 08 '25 14:05 ryanpq