chore: ci fixups and poetry update

This commit is contained in:
Andrew Herrington
2024-05-05 12:20:49 -05:00
parent cb862fa2c5
commit d0b986025e
24 changed files with 829 additions and 1026 deletions

View File

@@ -1,10 +1,6 @@
"""An async healthchecks.io client."""
from types import TracebackType
from typing import Dict
from typing import List
from typing import Optional
from typing import Tuple
from typing import Type
from httpx import Client as HTTPXClient
@@ -27,7 +23,7 @@ class Client(AbstractClient):
api_url: str = "https://healthchecks.io/api/",
ping_url: str = "https://hc-ping.com/",
api_version: int = 1,
client: Optional[HTTPXClient] = None,
client: HTTPXClient | None = None,
) -> None:
"""An AsyncClient can be used in code using asyncio to work with the Healthchecks.io api.
@@ -62,9 +58,9 @@ class Client(AbstractClient):
def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc: Optional[BaseException],
traceback: Optional[TracebackType],
exc_type: type[BaseException] | None,
exc: BaseException | None,
traceback: TracebackType | None,
) -> None:
"""Context manager exit."""
self._finalizer_method()
@@ -73,7 +69,7 @@ class Client(AbstractClient):
"""Closes the httpx client."""
self._client.close()
def get_checks(self, tags: Optional[List[str]] = None) -> List[checks.Check]:
def get_checks(self, tags: list[str] | None = None) -> list[checks.Check]:
"""Get a list of checks from the healthchecks api.
Args:
@@ -208,7 +204,7 @@ class Client(AbstractClient):
response = self.check_response(self._client.delete(request_url))
return checks.Check.from_api_result(response.json())
def get_check_pings(self, check_id: str) -> List[checks.CheckPings]:
def get_check_pings(self, check_id: str) -> list[checks.CheckPings]:
"""Returns a list of pings this check has received.
This endpoint returns pings in reverse order (most recent first),
@@ -234,10 +230,10 @@ class Client(AbstractClient):
def get_check_flips(
self,
check_id: str,
seconds: Optional[int] = None,
start: Optional[int] = None,
end: Optional[int] = None,
) -> List[checks.CheckStatuses]:
seconds: int | None = None,
start: int | None = None,
end: int | None = None,
) -> list[checks.CheckStatuses]:
"""Returns a list of "flips" this check has experienced.
A flip is a change of status (from "down" to "up," or from "up" to "down").
@@ -272,7 +268,7 @@ class Client(AbstractClient):
response = self.check_response(self._client.get(request_url))
return [checks.CheckStatuses(**status_data) for status_data in response.json()]
def get_integrations(self) -> List[Optional[integrations.Integration]]:
def get_integrations(self) -> list[integrations.Integration | None]:
"""Returns a list of integrations belonging to the project.
Raises:
@@ -290,7 +286,7 @@ class Client(AbstractClient):
for integration_dict in response.json()["channels"]
]
def get_badges(self) -> Dict[str, badges.Badges]:
def get_badges(self) -> dict[str, badges.Badges]:
"""Returns a dict of all tags in the project, with badge URLs for each tag.
Healthchecks.io provides badges in a few different formats:
@@ -317,7 +313,7 @@ class Client(AbstractClient):
response = self.check_response(self._client.get(request_url))
return {key: badges.Badges.from_api_result(item) for key, item in response.json()["badges"].items()}
def success_ping(self, uuid: str = "", slug: str = "", data: str = "") -> Tuple[bool, str]:
def success_ping(self, uuid: str = "", slug: str = "", data: str = "") -> tuple[bool, str]:
"""Signals to Healthchecks.io that a job has completed successfully.
Can also be used to indicate a continuously running process is still running and healthy.
@@ -351,7 +347,7 @@ class Client(AbstractClient):
response = self.check_ping_response(self._client.post(ping_url, content=data))
return (True if response.status_code == 200 else False, response.text)
def start_ping(self, uuid: str = "", slug: str = "", data: str = "") -> Tuple[bool, str]:
def start_ping(self, uuid: str = "", slug: str = "", data: str = "") -> tuple[bool, str]:
"""Sends a "job has started!" message to Healthchecks.io.
Sending a "start" signal is optional, but it enables a few extra features:
@@ -387,7 +383,7 @@ class Client(AbstractClient):
response = self.check_ping_response(self._client.post(ping_url, content=data))
return (True if response.status_code == 200 else False, response.text)
def fail_ping(self, uuid: str = "", slug: str = "", data: str = "") -> Tuple[bool, str]:
def fail_ping(self, uuid: str = "", slug: str = "", data: str = "") -> tuple[bool, str]:
"""Signals to Healthchecks.io that the job has failed.
Actively signaling a failure minimizes the delay from your monitored service failing to you receiving an alert.
@@ -421,7 +417,7 @@ class Client(AbstractClient):
response = self.check_ping_response(self._client.post(ping_url, content=data))
return (True if response.status_code == 200 else False, response.text)
def exit_code_ping(self, exit_code: int, uuid: str = "", slug: str = "", data: str = "") -> Tuple[bool, str]:
def exit_code_ping(self, exit_code: int, uuid: str = "", slug: str = "", data: str = "") -> tuple[bool, str]:
"""Signals to Healthchecks.io that the job has failed.
Actively signaling a failure minimizes the delay from your monitored service failing to you receiving an alert.