From 04bdadc99585b3ae9a220485d8c80d7cc9d07416 Mon Sep 17 00:00:00 2001 From: sudosnok Date: Sun, 1 May 2022 20:14:40 +0100 Subject: [PATCH 1/2] Fixed walrus --- github/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/github/client.py b/github/client.py index c784837..bbd7032 100644 --- a/github/client.py +++ b/github/client.py @@ -102,6 +102,12 @@ class GHClient: return self async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + try: + session = self.http.session + await self.session.close() + except Exception as exc: + raise Exception('HTTP Session doesn\'t exist') from exc + if session := getattr(self.http, 'session', None): await session.close() From efabb44b546b5959a11f727b5cc960b597f57c83 Mon Sep 17 00:00:00 2001 From: sudosnok Date: Sun, 1 May 2022 20:17:16 +0100 Subject: [PATCH 2/2] Fixed walrus, for real --- github/client.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/github/client.py b/github/client.py index bbd7032..d5ca29d 100644 --- a/github/client.py +++ b/github/client.py @@ -104,13 +104,10 @@ class GHClient: async def __aexit__(self, *args: Any, **kwargs: Any) -> None: try: session = self.http.session - await self.session.close() + await session.close() except Exception as exc: raise Exception('HTTP Session doesn\'t exist') from exc - if session := getattr(self.http, 'session', None): - await session.close() - def __repr__(self) -> str: return f'<{self.__class__.__name__} has_auth={bool(self._auth)}>'