MCPcopy
hub / github.com/AstrBotDevs/AstrBot / normalize_and_dedupe_strings

Function normalize_and_dedupe_strings

astrbot/core/utils/string_utils.py:7–21  ·  view source on GitHub ↗
(items: Iterable[Any] | None)

Source from the content-addressed store, hash-verified

5
6
7def normalize_and_dedupe_strings(items: Iterable[Any] | None) -> list[str]:
8 if items is None:
9 return []
10
11 normalized: list[str] = []
12 seen: set[str] = set()
13 for item in items:
14 if not isinstance(item, str):
15 continue
16 cleaned = item.strip()
17 if not cleaned or cleaned in seen:
18 continue
19 seen.add(cleaned)
20 normalized.append(cleaned)
21 return normalized

Calls 3

setFunction · 0.85
addMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected