Skip to content

Commit 27de1e3

Browse files
committed
fix: recursion exit condition unreachable
grokk use grokk code. grokk no use fancy map
1 parent 1a478fa commit 27de1e3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

metricq_sink_websocket/sink.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,19 @@ def _internal_to_primary(self, internal_metric: str) -> str:
6060
def _primary_to_internal(self, primary_metric: str) -> str: ...
6161

6262
@overload
63-
def _primary_to_internal(self, primary_metric: Iterable[str]) -> Iterable[str]: ...
63+
def _primary_to_internal(self, primary_metric: Iterable[str]) -> list[str]: ...
6464

6565
def _primary_to_internal(
6666
self, primary_metric: str | Iterable[str]
67-
) -> str | Iterable[str]:
67+
) -> str | list[str]:
6868
if self._internal_name_by_primary_name is None:
6969
return primary_metric
70-
if isinstance(primary_metric, Iterable):
71-
return list(map(self._primary_to_internal, primary_metric))
72-
return self._internal_name_by_primary_name[primary_metric]
70+
if isinstance(primary_metric, str):
71+
return self._internal_name_by_primary_name[primary_metric]
72+
elif isinstance(primary_metric, Iterable):
73+
return [self._primary_to_internal(metric) for metric in primary_metric]
74+
else:
75+
raise TypeError("primary_metric is neither a string nor a sequence of strings")
7376

7477
def _suffix_metric(self, metric: str) -> str:
7578
assert self._suffix

0 commit comments

Comments
 (0)