Skip to content

Commit

Permalink
Fix all the lint erorrs
Browse files Browse the repository at this point in the history
  • Loading branch information
dashmage committed Mar 22, 2024
1 parent d1f4527 commit 3f0f931
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import logging
from time import sleep
from typing import Any, Dict, Optional, Tuple
from typing import Any, Dict, Optional

import ops
from charms.grafana_agent.v0.cos_agent import COSAgentProvider
Expand All @@ -32,6 +32,8 @@

logger = logging.getLogger(__name__)

# mypy: disable-error-code="index"


class HardwareObserverCharm(ops.CharmBase):
"""Charm the application."""
Expand Down Expand Up @@ -81,7 +83,7 @@ def __init__(self, *args: Any) -> None:
)
self.num_cos_agent_relations = self.get_num_cos_agent_relations("cos-agent")

def _on_install_or_upgrade(self, event: ops.InstallEvent) -> None:
def _on_install_or_upgrade(self, _: ops.InstallEvent) -> None:
"""Install or upgrade charm."""
# Install resources
self.model.unit.status = MaintenanceStatus("Installing resources...")
Expand All @@ -106,7 +108,7 @@ def _on_install_or_upgrade(self, event: ops.InstallEvent) -> None:
self._stored.exporter_status["msg"] = msg
return

def _on_collect_status(self, event: ops.CollectStatusEvent):
def _on_collect_status(self, event: ops.CollectStatusEvent) -> None:
if not self._stored.resource_status["installed"]:
event.add_status(BlockedStatus(self._stored.resource_status["msg"]))

Expand Down Expand Up @@ -188,8 +190,8 @@ def _on_config_changed(self, event: EventBase) -> None:
self._stored.config[key] = value # type: ignore
change_set.add(key)

if not self._stored.resource_status["installed"]: # type: ignore[truthy-function]
logging.info( # type: ignore[unreachable]
if not self._stored.resource_status["installed"]:
logging.info(
"Config changed called before install complete, deferring event: %s",
event.handle,
)
Expand Down Expand Up @@ -218,10 +220,10 @@ def _on_config_changed(self, event: EventBase) -> None:
def _on_cos_agent_relation_joined(self, event: EventBase) -> None:
"""Start the exporter when relation joined."""
if (
not self._stored.resource_status["installed"] # type: ignore[truthy-function]
or not self._stored.exporter_status["installed"] # type: ignore[truthy-function]
not self._stored.resource_status["installed"]
or not self._stored.exporter_status["installed"]
):
logger.info( # type: ignore[unreachable]
logger.info(
"Defer cos-agent relation join because exporter or resources is not ready yet."
)
event.defer()
Expand All @@ -230,9 +232,9 @@ def _on_cos_agent_relation_joined(self, event: EventBase) -> None:
self.exporter.start()
logger.info("Start and enable exporter service")

def _on_cos_agent_relation_departed(self, event: EventBase) -> None:
def _on_cos_agent_relation_departed(self, _: EventBase) -> None:
"""Remove the exporter when relation departed."""
if self._stored.exporter_status["installed"]: # type: ignore[truthy-function]
if self._stored.exporter_status["installed"]:
self.exporter.stop()
self.exporter.disable()
logger.info("Stop and disable exporter service")
Expand Down

0 comments on commit 3f0f931

Please sign in to comment.