From 42843b4885bd3b3d1e264c2b5f398934ecb37560 Mon Sep 17 00:00:00 2001 From: Maurizio Porrato Date: Fri, 18 Aug 2023 17:33:07 +0100 Subject: [PATCH] tox: enfore 100% coverage and add pylint --- src/operator_repo/checks/bundle.py | 2 +- src/operator_repo/checks/operator.py | 2 +- src/operator_repo/cli.py | 6 +++--- tox.ini | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/operator_repo/checks/bundle.py b/src/operator_repo/checks/bundle.py index a231a1e..c5b0434 100644 --- a/src/operator_repo/checks/bundle.py +++ b/src/operator_repo/checks/bundle.py @@ -43,7 +43,7 @@ def check_image(bundle: Bundle) -> Iterator[CheckResult]: if any(container_image == x.get("image") for x in containers): return yield Fail(f"container image {container_image} not used by any deployment") - except Exception as exc: + except Exception as exc: # pylint: disable=broad-exception-caught yield Fail(str(exc)) diff --git a/src/operator_repo/checks/operator.py b/src/operator_repo/checks/operator.py index f8ce1c7..b3ef1e0 100644 --- a/src/operator_repo/checks/operator.py +++ b/src/operator_repo/checks/operator.py @@ -21,5 +21,5 @@ def check_upgrade(operator: Operator) -> Iterator[CheckResult]: yield Fail( f"Channel {channel} has dangling bundles: {dangling_bundles}" ) - except Exception as exc: + except Exception as exc: # pylint: disable=broad-exception-caught yield Fail(str(exc)) diff --git a/src/operator_repo/cli.py b/src/operator_repo/cli.py index c544259..dd49297 100644 --- a/src/operator_repo/cli.py +++ b/src/operator_repo/cli.py @@ -40,12 +40,12 @@ def show_operator(operator: Operator, recursive: bool = False, depth: int = 0) - print(indent(depth) + str(operator)) for bundle in operator: if recursive: - show_bundle(bundle, recursive, depth + 1) + show_bundle(bundle, depth + 1) else: print(indent(depth + 1) + str(bundle)) -def show_bundle(bundle: Bundle, recursive: bool = False, depth: int = 0) -> None: +def show_bundle(bundle: Bundle, depth: int = 0) -> None: print(indent(depth) + str(bundle)) csv_annotations = bundle.csv.get("metadata", {}).get("annotations", {}) info = [ @@ -69,7 +69,7 @@ def show(target: Union[Repo, Operator, Bundle], recursive: bool = False) -> None elif isinstance(target, Operator): show_operator(target, recursive, 1 * recursive) elif isinstance(target, Bundle): - show_bundle(target, recursive, 2 * recursive) + show_bundle(target, 2 * recursive) def action_list(repo: Repo, *what: str, recursive: bool = False) -> None: diff --git a/tox.ini b/tox.ini index 6d1f218..8dd395f 100644 --- a/tox.ini +++ b/tox.ini @@ -6,5 +6,6 @@ isolated_build = True ; This is required for a pyproject.toml based project. groups = ; Dependency groups in pyproject.toml dev commands = - pytest --cov-report term-missing --cov=operator_repo -v tests/ + pytest --cov-report term-missing --cov-fail-under=100 --cov=operator_repo -v tests/ + pylint --disable=R,C src mypy --strict src tests