From 95a950d4fb7ddf18e7b4883cd137630ed3f5b60f Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 20 Sep 2024 09:57:05 +0900 Subject: [PATCH] happy mypy and pyright --- tests/integration/commands/test_analyse.py | 11 +++++++---- .../ops-main-linter-charms/negative/src/charm.py | 2 +- .../ops-main-linter-charms/smoke/src/charm.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/integration/commands/test_analyse.py b/tests/integration/commands/test_analyse.py index 73c935e31..8f337e9aa 100644 --- a/tests/integration/commands/test_analyse.py +++ b/tests/integration/commands/test_analyse.py @@ -389,18 +389,21 @@ def zip_directory(directory_path: Path, zip_path: Path): @pytest.fixture -def ops_main_linter_charms(request): +def linter_charms(request): return request.config.rootpath / "tests/integration/ops-main-linter-charms" @pytest.mark.parametrize(("charm", "rv"), [("smoke", 0), ("negative", 2)]) def test_ops_main_linter( - tmp_path: Path, ops_main_linter_charms: Path, emitter, config, charm: str, rv: int + tmp_path: Path, linter_charms: Path, emitter, config, charm: str, rv: int ): - zip_directory(ops_main_linter_charms / charm, (charm := tmp_path / "this.charm")) + zip_directory(linter_charms / charm, (charm_path := tmp_path / "this.charm")) + retcode = Analyse(config=config).run( - Namespace(filepath=charm, force=None, format=None, ignore=None) + Namespace(filepath=charm_path, force=None, format=None, ignore=None) ) + assert retcode == rv + if rv: assert "ops.main() call missing" in str(emitter.interactions) diff --git a/tests/integration/ops-main-linter-charms/negative/src/charm.py b/tests/integration/ops-main-linter-charms/negative/src/charm.py index 35d895e15..14d38b313 100755 --- a/tests/integration/ops-main-linter-charms/negative/src/charm.py +++ b/tests/integration/ops-main-linter-charms/negative/src/charm.py @@ -1,5 +1,5 @@ # Copyright 2024 Canonical Ltd. -import ops +import ops # type: ignore class SomeCharm(ops.CharmBase): ... diff --git a/tests/integration/ops-main-linter-charms/smoke/src/charm.py b/tests/integration/ops-main-linter-charms/smoke/src/charm.py index 2248e7c4b..25429819f 100755 --- a/tests/integration/ops-main-linter-charms/smoke/src/charm.py +++ b/tests/integration/ops-main-linter-charms/smoke/src/charm.py @@ -1,5 +1,5 @@ # Copyright 2024 Canonical Ltd. -import ops +import ops # type: ignore class SomeCharm(ops.CharmBase): ...