Skip to content

Commit 95c9e48

Browse files
committed
Clean up no-untyped-def #766
Change-Id: If0a7615b33ff8e75e27401a0cbeea4ce9aade891
1 parent df3f7f8 commit 95c9e48

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

cmk/base/legacy_checks/graylog_cluster_stats.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
44
# conditions defined in the file COPYING, which is part of this source code package.
55

6-
# mypy: disable-error-code="no-untyped-def"
76
# mypy: disable-error-code="type-arg"
8-
9-
107
# mypy: disable-error-code="arg-type"
118

12-
from collections.abc import Iterable
9+
from collections.abc import Mapping, Sequence
10+
from typing import Any
1311

14-
from cmk.agent_based.legacy.v0_unstable import check_levels, LegacyCheckDefinition
12+
from cmk.agent_based.legacy.v0_unstable import (
13+
check_levels,
14+
LegacyCheckDefinition,
15+
LegacyCheckResult,
16+
LegacyDiscoveryResult,
17+
LegacyService,
18+
)
1519
from cmk.agent_based.v2 import render
1620
from cmk.plugins.graylog.lib import deserialize_and_merge_json, GraylogSection
1721

@@ -57,12 +61,14 @@
5761
# "alarmcallback_count_by_type": {}}}']]
5862

5963

60-
def discover_graylog_cluster_stats(section: GraylogSection) -> Iterable[tuple[None, dict]]:
64+
def discover_graylog_cluster_stats(section: GraylogSection) -> LegacyDiscoveryResult:
6165
if section:
6266
yield None, {}
6367

6468

65-
def check_graylog_cluster_stats(_no_item, params, parsed):
69+
def check_graylog_cluster_stats(
70+
_no_item: None, params: Mapping[str, Any], parsed: GraylogSection
71+
) -> LegacyCheckResult:
6672
if not parsed:
6773
return
6874

@@ -93,18 +99,18 @@ def check_graylog_cluster_stats(_no_item, params, parsed):
9399
)
94100

95101

96-
def discover_graylog_cluster_stats_elastic(parsed):
102+
def discover_graylog_cluster_stats_elastic(parsed: GraylogSection) -> Sequence[LegacyService]:
97103
elastic_data = parsed.get("elasticsearch")
98104
if elastic_data is not None:
99105
return [(None, {})]
100106
return []
101107

102108

103109
def check_graylog_cluster_stats_elastic(
104-
_no_item,
105-
params,
106-
parsed,
107-
):
110+
_no_item: None,
111+
params: Mapping[str, Any],
112+
parsed: GraylogSection,
113+
) -> LegacyCheckResult:
108114
elastic_data = parsed.get("elasticsearch")
109115
if elastic_data is None:
110116
return
@@ -121,7 +127,7 @@ def check_graylog_cluster_stats_elastic(
121127

122128
status_data = elastic_data.get("status")
123129
if status_data:
124-
yield params.get(status_data.lower()), "Status: %s" % status_data.title()
130+
yield params.get(status_data.lower(), 3), "Status: %s" % status_data.title()
125131

126132
health_data = elastic_data.get("cluster_health")
127133
if health_data:
@@ -202,14 +208,16 @@ def check_graylog_cluster_stats_elastic(
202208
)
203209

204210

205-
def discover_graylog_cluster_stats_mongodb(parsed):
211+
def discover_graylog_cluster_stats_mongodb(parsed: GraylogSection) -> Sequence[LegacyService]:
206212
mongo_data = parsed.get("mongo")
207213
if mongo_data is not None:
208214
return [(None, {})]
209215
return []
210216

211217

212-
def check_graylog_cluster_stats_mongodb(_no_item, params, parsed):
218+
def check_graylog_cluster_stats_mongodb(
219+
_no_item: None, params: Mapping[str, Any], parsed: GraylogSection
220+
) -> LegacyCheckResult:
213221
mongo_data = parsed.get("mongo")
214222
if mongo_data is None:
215223
return

tests/unit/cmk/base/legacy_checks/test_graylog_cluster_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_discover_graylog_cluster_stats(
6464
],
6565
)
6666
def test_check_graylog_cluster_stats(
67-
item: str, params: Mapping[str, Any], info: StringTable, expected_results: Sequence[Any]
67+
item: None, params: Mapping[str, Any], info: StringTable, expected_results: Sequence[Any]
6868
) -> None:
6969
"""Test check function for graylog_cluster_stats check."""
7070
parsed = deserialize_and_merge_json(info)

0 commit comments

Comments
 (0)