Skip to content

Commit

Permalink
Add Type Hints as specified in is-charms-contributing-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
javierdelapuente authored Mar 6, 2024
2 parents 0da0d7d + 6f2af57 commit 59b6ac9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
10 changes: 6 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -26,7 +28,7 @@
class IsCharmsTemplateCharm(ops.CharmBase):
"""Charm the service."""

def __init__(self, *args):
def __init__(self, *args: typing.Any):
"""Construct.
Args:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) -> pebble.LayerDict:
"""Return a dictionary representing a Pebble layer."""
return {
"summary": "httpbin layer",
Expand Down

0 comments on commit 59b6ac9

Please sign in to comment.