From 4f91bcde6646da258ea5ccd4517d94e9d54de840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Barbero?= Date: Tue, 29 Oct 2024 14:04:04 +0100 Subject: [PATCH] fix: fix pre-commit issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mikaƫl Barbero --- otterdog/cli.py | 1 + otterdog/operations/list_advisories.py | 26 +++++++++++++------------- otterdog/utils.py | 3 ++- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/otterdog/cli.py b/otterdog/cli.py index 8f2b9e9..db90de4 100644 --- a/otterdog/cli.py +++ b/otterdog/cli.py @@ -729,6 +729,7 @@ def list_advisories(state: list[str], details: bool, organizations: list[str]): """ _execute_operation(organizations, ListAdvisoriesOperation(state, details)) + @cli.command(short_help="Installs required dependencies.") def install_deps(): """ diff --git a/otterdog/operations/list_advisories.py b/otterdog/operations/list_advisories.py index 562290e..4d7ee20 100644 --- a/otterdog/operations/list_advisories.py +++ b/otterdog/operations/list_advisories.py @@ -11,13 +11,11 @@ from typing import TYPE_CHECKING from otterdog.providers.github import GitHubProvider -from otterdog.utils import is_info_enabled, style, format_date_for_csv +from otterdog.utils import format_date_for_csv, is_info_enabled, style from . import Operation if TYPE_CHECKING: - from typing import Any - from otterdog.config import OrganizationConfig @@ -46,7 +44,9 @@ def pre_execute(self) -> None: if is_info_enabled(): self.printer.println(f"Listing {self.states} repository security advisories:") if not self.details: - self.printer.println("organization,created_at,updated_at,published_at,state,ghsa_id,cve_id,html_url,summary") + self.printer.println( + "organization,created_at,updated_at,published_at,state,ghsa_id,cve_id,html_url,summary" + ) def post_execute(self) -> None: pass @@ -86,19 +86,19 @@ async def execute( for advisory in advisories: if not self.details: - cve_id = advisory['cve_id'] if advisory['cve_id'] is not None else 'NO_CVE' - summary = advisory['summary'].replace('"', '""') + cve_id = advisory["cve_id"] if advisory["cve_id"] is not None else "NO_CVE" + summary = advisory["summary"].replace('"', '""') formatted_values = { "org_name": org_config.name, - "created_at": format_date_for_csv(advisory['created_at']), - "updated_at": format_date_for_csv(advisory['updated_at']), - "published_at": format_date_for_csv(advisory['published_at']), - "state": advisory['state'], - "ghsa_id": advisory['ghsa_id'], + "created_at": format_date_for_csv(advisory["created_at"]), + "updated_at": format_date_for_csv(advisory["updated_at"]), + "published_at": format_date_for_csv(advisory["published_at"]), + "state": advisory["state"], + "ghsa_id": advisory["ghsa_id"], "cve_id": cve_id, - "html_url": advisory['html_url'], - "summary": summary + "html_url": advisory["html_url"], + "summary": summary, } self.printer.println( diff --git a/otterdog/utils.py b/otterdog/utils.py index e0bd8ef..9db7ff7 100644 --- a/otterdog/utils.py +++ b/otterdog/utils.py @@ -607,7 +607,8 @@ def deep_merge_dict(source: dict[str, Any], destination: dict[str, Any]): return destination -def format_date_for_csv(iso_date_str : str) -> str: + +def format_date_for_csv(iso_date_str: str) -> str: if iso_date_str is None: return "" date_obj = datetime.fromisoformat(iso_date_str)