From b05310c40511827ec8eb5bdfec5590574c502c99 Mon Sep 17 00:00:00 2001 From: Pietro Pasotti Date: Mon, 19 Aug 2024 13:14:41 +0200 Subject: [PATCH] ruff is the new black --- src/charm.py | 3 ++- tests/scenario/test_dashboard_transfer.py | 3 ++- tests/scenario/test_setup_statuses.py | 3 ++- tests/scenario/test_start_statuses.py | 3 ++- tests/scenario/test_tracing_integration.py | 5 +++-- tests/unit/test_relation_status.py | 3 ++- tests/unit/test_update_status.py | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/charm.py b/src/charm.py index 1d861715..f90a5134 100755 --- a/src/charm.py +++ b/src/charm.py @@ -14,10 +14,11 @@ from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointConsumer from charms.tempo_k8s.v1.charm_tracing import trace_charm from cosl import GrafanaDashboard -from grafana_agent import CONFIG_PATH, GrafanaAgentCharm from ops.main import main from ops.pebble import Layer +from grafana_agent import CONFIG_PATH, GrafanaAgentCharm + logger = logging.getLogger(__name__) SCRAPE_RELATION_NAME = "metrics-endpoint" diff --git a/tests/scenario/test_dashboard_transfer.py b/tests/scenario/test_dashboard_transfer.py index c299c234..0babdd77 100644 --- a/tests/scenario/test_dashboard_transfer.py +++ b/tests/scenario/test_dashboard_transfer.py @@ -2,10 +2,11 @@ # See LICENSE file for licensing details. import json -from charm import GrafanaAgentK8sCharm from cosl import GrafanaDashboard from scenario import Container, Context, Relation, State +from charm import GrafanaAgentK8sCharm + def encode_as_dashboard(dct: dict): return GrafanaDashboard._serialize(json.dumps(dct).encode("utf-8")) diff --git a/tests/scenario/test_setup_statuses.py b/tests/scenario/test_setup_statuses.py index 781052b8..9de833f3 100644 --- a/tests/scenario/test_setup_statuses.py +++ b/tests/scenario/test_setup_statuses.py @@ -1,10 +1,11 @@ # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. -import charm from ops import BlockedStatus, UnknownStatus, pebble from scenario import Container, Context, ExecOutput, State +import charm + def test_install(vroot): context = Context( diff --git a/tests/scenario/test_start_statuses.py b/tests/scenario/test_start_statuses.py index 407fe037..bb4bfc5a 100644 --- a/tests/scenario/test_start_statuses.py +++ b/tests/scenario/test_start_statuses.py @@ -3,10 +3,11 @@ import dataclasses from pathlib import Path -from charm import GrafanaAgentK8sCharm from ops import pebble from scenario import Container, Context, ExecOutput, State +from charm import GrafanaAgentK8sCharm + CHARM_ROOT = Path(__file__).parent.parent.parent diff --git a/tests/scenario/test_tracing_integration.py b/tests/scenario/test_tracing_integration.py index 1dcd6704..f27a7684 100644 --- a/tests/scenario/test_tracing_integration.py +++ b/tests/scenario/test_tracing_integration.py @@ -3,12 +3,13 @@ import pytest import scenario import yaml -from charm import GrafanaAgentK8sCharm from charms.tempo_k8s.v1.charm_tracing import charm_tracing_disabled from charms.tempo_k8s.v2.tracing import Receiver, TracingProviderAppData, TracingRequirerAppData -from grafana_agent import CONFIG_PATH from ops import pebble +from charm import GrafanaAgentK8sCharm +from grafana_agent import CONFIG_PATH + @pytest.fixture def ctx(vroot): diff --git a/tests/unit/test_relation_status.py b/tests/unit/test_relation_status.py index a37cf8cc..4e94f9a3 100644 --- a/tests/unit/test_relation_status.py +++ b/tests/unit/test_relation_status.py @@ -4,10 +4,11 @@ import unittest from unittest.mock import patch -from charm import GrafanaAgentK8sCharm as GrafanaAgentCharm from ops.model import ActiveStatus, BlockedStatus from ops.testing import Harness +from charm import GrafanaAgentK8sCharm as GrafanaAgentCharm + class TestRelationStatus(unittest.TestCase): def setUp(self, *unused): diff --git a/tests/unit/test_update_status.py b/tests/unit/test_update_status.py index 67563585..ec87f073 100644 --- a/tests/unit/test_update_status.py +++ b/tests/unit/test_update_status.py @@ -4,9 +4,10 @@ import unittest from unittest.mock import patch -from charm import GrafanaAgentK8sCharm as GrafanaAgentCharm from ops.testing import Harness +from charm import GrafanaAgentK8sCharm as GrafanaAgentCharm + class TestUpdateStatus(unittest.TestCase): def setUp(self, *unused):