fix context managers
This commit is contained in:
parent
ddf22f3694
commit
9b3ef85e76
2 changed files with 4 additions and 6 deletions
|
@ -16,7 +16,7 @@ from matrix_alertbot.errors import (
|
|||
)
|
||||
|
||||
|
||||
class AlertmanagerClient(AsyncContextManager):
|
||||
class AlertmanagerClient:
|
||||
def __init__(self, url: str, cache: Cache) -> None:
|
||||
self.api_url = f"{url}/api/v2"
|
||||
self.cache = cache
|
||||
|
@ -25,8 +25,7 @@ class AlertmanagerClient(AsyncContextManager):
|
|||
async def __aenter__(self) -> AlertmanagerClient:
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
await super().__aexit__(*args, **kwargs)
|
||||
async def __aexit__(self, exc_type: Any, exc: Any, tb: Any) -> None:
|
||||
await self.close()
|
||||
|
||||
async def close(self) -> None:
|
||||
|
|
|
@ -51,7 +51,7 @@ async def create_alert(request: web_request.Request) -> web.Response:
|
|||
return web.Response(status=200)
|
||||
|
||||
|
||||
class Webhook(AsyncContextManager):
|
||||
class Webhook:
|
||||
def __init__(self, client: AsyncClient, cache: Cache, config: Config) -> None:
|
||||
self.app = web.Application(logger=logger)
|
||||
self.app["client"] = client
|
||||
|
@ -68,8 +68,7 @@ class Webhook(AsyncContextManager):
|
|||
async def __aenter__(self) -> Webhook:
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
||||
await super().__aexit__(*args, **kwargs)
|
||||
async def __aexit__(self, exc_type: Any, exc: Any, tb: Any) -> None:
|
||||
await self.close()
|
||||
|
||||
async def start(self) -> None:
|
||||
|
|
Loading…
Reference in a new issue