From e6b358ddf6682f9c1d37ecf3a07c1bdfc933bbe3 Mon Sep 17 00:00:00 2001
From: Karel van Klink <karel.vanklink@geant.org>
Date: Tue, 2 Jan 2024 14:36:30 +0100
Subject: [PATCH] remove redundant trailing commas, and reformat

---
 docs/dump-openapi-spec.py    |  4 +--
 docs/source/conf.py          | 12 +++-----
 lso/__init__.py              |  6 +---
 lso/config.py                |  4 +--
 lso/environment.py           | 10 ++-----
 lso/playbook.py              | 12 ++------
 test/routes/test_playbook.py | 56 ++++++------------------------------
 test/test_config.py          |  7 +----
 8 files changed, 20 insertions(+), 91 deletions(-)

diff --git a/docs/dump-openapi-spec.py b/docs/dump-openapi-spec.py
index 8e35e71..964489e 100644
--- a/docs/dump-openapi-spec.py
+++ b/docs/dump-openapi-spec.py
@@ -6,9 +6,7 @@ import lso
 
 config_filename = os.path.join(os.path.dirname(__file__), "..", "config.json.example")
 
-output_filename = os.path.join(
-    os.path.dirname(__file__), "source", "_static", "openapi.json"
-)
+output_filename = os.path.join(os.path.dirname(__file__), "source", "_static", "openapi.json")
 
 os.environ["SETTINGS_FILENAME"] = config_filename
 app = lso.create_app()
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 1be1927..c937dec 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -16,9 +16,7 @@ import json
 import os
 import sys
 
-sys.path.insert(
-    0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "lso"))
-)
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "lso")))
 
 
 class RenderAsJSON(Directive):
@@ -37,7 +35,7 @@ class RenderAsJSON(Directive):
 
         return [
             addnodes.desc_name(text=member_name),
-            addnodes.desc_content("", literal),
+            addnodes.desc_content("", literal)
         ]
 
 
@@ -57,7 +55,7 @@ extensions = [
     "sphinx_rtd_theme",
     "sphinx.ext.autodoc",
     "sphinx.ext.coverage",
-    "sphinx.ext.todo",
+    "sphinx.ext.todo"
 ]
 
 templates_path = ["templates"]
@@ -67,9 +65,7 @@ exclude_patterns = []
 
 html_theme = "sphinx_rtd_theme"
 html_static_path = ["_static"]
-html_theme_options = {
-    "style_nav_header_background": "rgb(0 63 95)",
-}
+html_theme_options = {"style_nav_header_background": "rgb(0 63 95)"}
 html_css_files = ["custom.css"]
 html_logo = "_static/geant_logo_white.svg"
 
diff --git a/lso/__init__.py b/lso/__init__.py
index 4a0a358..2d752ef 100644
--- a/lso/__init__.py
+++ b/lso/__init__.py
@@ -18,11 +18,7 @@ def create_app() -> FastAPI:
     app = FastAPI()
 
     app.add_middleware(
-        CORSMiddleware,
-        allow_origins=["*"],
-        allow_credentials=True,
-        allow_methods=["*"],
-        allow_headers=["*"],
+        CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]
     )
 
     app.include_router(default_router, prefix="/api")
diff --git a/lso/config.py b/lso/config.py
index a2eec06..ddc1781 100644
--- a/lso/config.py
+++ b/lso/config.py
@@ -15,9 +15,7 @@ from pydantic import BaseModel
 CONFIG_SCHEMA = {
     "$schema": "http://json-schema.org/draft-07/schema#",
     "type": "object",
-    "properties": {
-        "ansible_playbooks_root_dir": {"type": "string"},
-    },
+    "properties": {"ansible_playbooks_root_dir": {"type": "string"}},
     "required": ["ansible_playbooks_root_dir"],
     "additionalProperties": False,
 }
diff --git a/lso/environment.py b/lso/environment.py
index f8baddf..f50d645 100644
--- a/lso/environment.py
+++ b/lso/environment.py
@@ -15,15 +15,9 @@ LOGGING_DEFAULT_CONFIG = {
             "level": "DEBUG",
             "formatter": "simple",
             "stream": "ext://sys.stdout",
-        },
-    },
-    "loggers": {
-        "resource_management": {
-            "level": "DEBUG",
-            "handlers": ["console"],
-            "propagate": False,
-        },
+        }
     },
+    "loggers": {"resource_management": {"level": "DEBUG", "handlers": ["console"], "propagate": False}},
     "root": {"level": "INFO", "handlers": ["console"]},
 }
 
diff --git a/lso/playbook.py b/lso/playbook.py
index 0ada50b..32155c5 100644
--- a/lso/playbook.py
+++ b/lso/playbook.py
@@ -44,11 +44,7 @@ def playbook_launch_error(reason: str, status_code: int = status.HTTP_400_BAD_RE
 
 
 def _run_playbook_proc(
-    job_id: str,
-    playbook_path: str,
-    extra_vars: dict,
-    inventory: dict[str, Any] | str,
-    callback: str,
+    job_id: str, playbook_path: str, extra_vars: dict, inventory: dict[str, Any] | str, callback: str
 ) -> None:
     """Run a playbook, internal function.
 
@@ -58,11 +54,7 @@ def _run_playbook_proc(
     :param str callback: Callback URL to return output to when execution is completed.
     :param dict[str, Any] | str inventory: Ansible inventory to run the playbook against.
     """
-    ansible_playbook_run = ansible_runner.run(
-        playbook=playbook_path,
-        inventory=inventory,
-        extravars=extra_vars,
-    )
+    ansible_playbook_run = ansible_runner.run(playbook=playbook_path, inventory=inventory, extravars=extra_vars)
 
     payload = {
         "status": ansible_playbook_run.status,
diff --git a/test/routes/test_playbook.py b/test/routes/test_playbook.py
index 658b0e0..8439182 100644
--- a/test/routes/test_playbook.py
+++ b/test/routes/test_playbook.py
@@ -18,27 +18,10 @@ def test_playbook_endpoint_dict_inventory_success(client: TestClient, mocked_ans
         "playbook_name": "placeholder.yaml",
         "callback": TEST_CALLBACK_URL,
         "inventory": {
-            "_meta": {
-                "vars": {
-                    "host1.local": {
-                        "foo": "bar",
-                    },
-                    "host2.local": {
-                        "hello": "world",
-                    },
-                },
-            },
-            "all": {
-                "hosts": {
-                    "host1.local": None,
-                    "host2.local": None,
-                },
-            },
-        },
-        "extra_vars": {
-            "dry_run": True,
-            "commit_comment": "I am a robot!",
+            "_meta": {"vars": {"host1.local": {"foo": "bar"}, "host2.local": {"hello": "world"}}},
+            "all": {"hosts": {"host1.local": None, "host2.local": None}},
         },
+        "extra_vars": {"dry_run": True, "commit_comment": "I am a robot!"},
     }
 
     with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _:
@@ -60,11 +43,7 @@ def test_playbook_endpoint_str_inventory_success(client: TestClient, mocked_ansi
     params = {
         "playbook_name": "placeholder.yaml",
         "callback": TEST_CALLBACK_URL,
-        "inventory": {
-            "all": {
-                "hosts": "host1.local\nhost2.local\nhost3.local",
-            },
-        },
+        "inventory": {"all": {"hosts": "host1.local\nhost2.local\nhost3.local"}},
     }
 
     with patch("lso.playbook.ansible_runner.run", new=mocked_ansible_runner_run) as _:
@@ -85,19 +64,8 @@ def test_playbook_endpoint_invalid_host_vars(client: TestClient, mocked_ansible_
         "playbook_name": "placeholder.yaml",
         "callback": TEST_CALLBACK_URL,
         "inventory": {
-            "_meta": {
-                "host_vars": {
-                    "host1.local": {
-                        "foo": "bar",
-                    },
-                    "host2.local": {
-                        "hello": "world",
-                    },
-                },
-            },
-            "all": {
-                "hosts": "host1.local\nhost2.local\nhost3.local",
-            },
+            "_meta": {"host_vars": {"host1.local": {"foo": "bar"}, "host2.local": {"hello": "world"}}},
+            "all": {"hosts": "host1.local\nhost2.local\nhost3.local"},
         },
     }
 
@@ -122,16 +90,8 @@ def test_playbook_endpoint_invalid_hosts(client: TestClient, mocked_ansible_runn
         "playbook_name": "placeholder.yaml",
         "callback": TEST_CALLBACK_URL,
         "inventory": {
-            "_meta": {
-                "vars": {
-                    "host1.local": {
-                        "foo": "bar",
-                    },
-                },
-            },
-            "all": {
-                "hosts": ["host1.local", "host2.local", "host3.local"],
-            },
+            "_meta": {"vars": {"host1.local": {"foo": "bar"}}},
+            "all": {"hosts": ["host1.local", "host2.local", "host3.local"]},
         },
     }
 
diff --git a/test/test_config.py b/test/test_config.py
index 00875ea..25a41fa 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -22,12 +22,7 @@ def test_validate_testenv_config(data_config_filename: str) -> None:
 
 
 @pytest.mark.parametrize(
-    "bad_config",
-    [
-        {"name": "bad version", "version": 123},
-        {"name": "missing version"},
-        {"version": "missing name"},
-    ],
+    "bad_config", [{"name": "bad version", "version": 123}, {"name": "missing version"}, {"version": "missing name"}]
 )
 def test_bad_config(bad_config: dict) -> None:
     with tempfile.NamedTemporaryFile(mode="w") as file:
-- 
GitLab