From e36fcea25f6d6522a49ac38b7f35a8fa2f5a3211 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sat, 12 Mar 2022 21:26:22 +0200 Subject: [PATCH] More small fixes. - Update the prospector pre-commit hook, it was failing for some reason. - Address some docstring issues it started complaining about. --- .pre-commit-config.yaml | 2 +- images/docker/compose-health-check | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7dfd9f8..2fe5d51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -90,7 +90,7 @@ repos: --line-length=79 - repo: https://github.com/PyCQA/prospector.git - rev: 1.5.1 + rev: 1.7.1 hooks: - id: prospector args: diff --git a/images/docker/compose-health-check b/images/docker/compose-health-check index 5fb8c43..9fc6461 100755 --- a/images/docker/compose-health-check +++ b/images/docker/compose-health-check @@ -13,9 +13,13 @@ import dotenv # pylint: disable=import-error def get_project_containers_health(client, project): - """Get a Docker connection and the Docker Compose project name and return a + # noqa: D213 + """Get the health of containers of a Compose project. + + Get a Docker connection and the Docker Compose project name and return a dictionary of container objects and their health status (if available, else - their status).""" + their status). + """ return { i: i.attrs["State"]["Health"]["Status"] if "Health" in i.attrs["State"] @@ -27,13 +31,18 @@ def get_project_containers_health(client, project): def get_unhealthy_project_containers(client, project): - """Returns a list (could be empty) of containers that are not healthy or - not running (in case a health check is not set).""" + # noqa: D213 + """Returns a list (could be empty) of containers that are not healthy. + + Or in the case that a health check is not set, containers that are not + running. + """ healths = get_project_containers_health(client, project) return [x for x in healths if healths[x] not in ["healthy", "running"]] def wait_for_project_health(project, timeout): + # noqa: D213 """Wait for a Docker Compose project to be healthy. If all of the containers are healthy or running (because there's no @@ -79,7 +88,6 @@ def get_project_name(args): def main(): """Main entrypoint.""" - epilog = ( "The Docker Compose project name is resolved in the following order:" "\n1. From the command line parameter." -- GitLab