From df58dff43db2adf5c9cbc4f9dddec09fcf364e0a Mon Sep 17 00:00:00 2001 From: Javier de la Puente Date: Tue, 5 Mar 2024 08:43:45 +0100 Subject: [PATCH 1/4] Add Type Hints as specified in is-charms-contributing-guide --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0ed8d68..0fce3f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,10 +34,16 @@ line_length = 99 profile = "black" [tool.mypy] -ignore_missing_imports = true +check_untyped_defs = true +disallow_untyped_defs = true explicit_package_bases = true +ignore_missing_imports = true namespace_packages = true +[[tool.mypy.overrides]] +disallow_untyped_defs = false +module = "tests.*" + [tool.pylint] disable = "wrong-import-order" From 5eb2bef574bae5b8c3aab4994beb03888548fe02 Mon Sep 17 00:00:00 2001 From: Javier de la Puente Date: Tue, 5 Mar 2024 08:56:42 +0100 Subject: [PATCH 2/4] Fix linting with the new rules --- src/charm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/charm.py b/src/charm.py index 46227b1..914afed 100755 --- a/src/charm.py +++ b/src/charm.py @@ -14,8 +14,10 @@ """ import logging +import typing import ops +from ops import pebble # Log messages can be retrieved using juju debug-log logger = logging.getLogger(__name__) @@ -26,7 +28,7 @@ class IsCharmsTemplateCharm(ops.CharmBase): """Charm the service.""" - def __init__(self, *args): + def __init__(self, *args: typing.Any): """Construct. Args: @@ -36,7 +38,7 @@ def __init__(self, *args): self.framework.observe(self.on.httpbin_pebble_ready, self._on_httpbin_pebble_ready) self.framework.observe(self.on.config_changed, self._on_config_changed) - def _on_httpbin_pebble_ready(self, event: ops.PebbleReadyEvent): + def _on_httpbin_pebble_ready(self, event: ops.PebbleReadyEvent) -> None: """Define and start a workload using the Pebble API. Change this example to suit your needs. You'll need to specify the right entrypoint and @@ -57,7 +59,7 @@ def _on_httpbin_pebble_ready(self, event: ops.PebbleReadyEvent): # https://juju.is/docs/sdk/constructs#heading--statuses self.unit.status = ops.ActiveStatus() - def _on_config_changed(self, event: ops.ConfigChangedEvent): + def _on_config_changed(self, event: ops.ConfigChangedEvent) -> None: """Handle changed configuration. Change this example to suit your needs. If you don't need to handle config, you can remove @@ -92,7 +94,7 @@ def _on_config_changed(self, event: ops.ConfigChangedEvent): self.unit.status = ops.BlockedStatus("invalid log level: '{log_level}'") @property - def _pebble_layer(self): + def _pebble_layer(self) -> typing.Union[pebble.LayerDict]: """Return a dictionary representing a Pebble layer.""" return { "summary": "httpbin layer", From 25db321bd4b3cb444cdbd202aa97610661d7edc9 Mon Sep 17 00:00:00 2001 From: Javier de la Puente Date: Wed, 6 Mar 2024 07:47:55 +0100 Subject: [PATCH 3/4] Remove not needed typing.Union --- src/charm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/charm.py b/src/charm.py index 914afed..e9b21ed 100755 --- a/src/charm.py +++ b/src/charm.py @@ -94,7 +94,7 @@ def _on_config_changed(self, event: ops.ConfigChangedEvent) -> None: self.unit.status = ops.BlockedStatus("invalid log level: '{log_level}'") @property - def _pebble_layer(self) -> typing.Union[pebble.LayerDict]: + def _pebble_layer(self) -> pebble.LayerDict: """Return a dictionary representing a Pebble layer.""" return { "summary": "httpbin layer", From 6f2af5772d7fa2e1f13ae40517d5927731cf529c Mon Sep 17 00:00:00 2001 From: Javier de la Puente Date: Wed, 6 Mar 2024 14:44:53 +0100 Subject: [PATCH 4/4] Remove chaos variales in integration test --- .github/workflows/integration_test.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index 8e4034b..60c34dd 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -8,9 +8,6 @@ jobs: uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main secrets: inherit with: - chaos-app-label: app.kubernetes.io/name=indico - chaos-enabled: false - chaos-experiments: pod-delete load-test-enabled: false load-test-run-args: "-e LOAD_TEST_HOST=localhost" zap-before-command: "curl -H \"Host: indico.local\" http://localhost/bootstrap --data-raw 'csrf_token=00000000-0000-0000-0000-000000000000&first_name=admin&last_name=admin&email=admin%40admin.com&username=admin&password=lunarlobster&confirm_password=lunarlobster&affiliation=Canonical'"