Skip to content

Commit

Permalink
fix: recursion exit condition unreachable
Browse files Browse the repository at this point in the history
grokk use grokk code. grokk no use fancy map
  • Loading branch information
bmario committed Aug 2, 2024
1 parent 1a478fa commit 27de1e3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions metricq_sink_websocket/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,19 @@ def _internal_to_primary(self, internal_metric: str) -> str:
def _primary_to_internal(self, primary_metric: str) -> str: ...

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

def _primary_to_internal(
self, primary_metric: str | Iterable[str]
) -> str | Iterable[str]:
) -> str | list[str]:
if self._internal_name_by_primary_name is None:
return primary_metric
if isinstance(primary_metric, Iterable):
return list(map(self._primary_to_internal, primary_metric))
return self._internal_name_by_primary_name[primary_metric]
if isinstance(primary_metric, str):
return self._internal_name_by_primary_name[primary_metric]
elif isinstance(primary_metric, Iterable):
return [self._primary_to_internal(metric) for metric in primary_metric]
else:
raise TypeError("primary_metric is neither a string nor a sequence of strings")

def _suffix_metric(self, metric: str) -> str:
assert self._suffix
Expand Down

0 comments on commit 27de1e3

Please sign in to comment.