mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(cost): build unique model names without mutable accumulators
The type-discipline gate counts list/set annotations as LIT001 and un-Final assignments as LIT010. Dedup via tuple(dict.fromkeys(...)). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
2a08259f2a
commit
e2063c04b2
1 changed files with 9 additions and 13 deletions
|
|
@ -328,19 +328,15 @@ def _published_token_rate(
|
|||
|
||||
|
||||
def _unique_model_names(*names: str | None) -> tuple[str, ...]:
|
||||
unique: list[str] = []
|
||||
seen: set[str] = set()
|
||||
for name in names:
|
||||
if not isinstance(name, str) or not name or name in seen:
|
||||
continue
|
||||
seen.add(name)
|
||||
unique.append(name)
|
||||
if "/" in name:
|
||||
tail: Final = name.split("/", 1)[1]
|
||||
if tail and tail not in seen:
|
||||
seen.add(tail)
|
||||
unique.append(tail)
|
||||
return tuple(unique)
|
||||
return tuple(
|
||||
dict.fromkeys(
|
||||
part
|
||||
for name in names
|
||||
if isinstance(name, str) and name
|
||||
for part in ((name,) if "/" not in name else (name, name.split("/", 1)[1]))
|
||||
if part
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _cost_map_rate(key: str | None, field: str) -> float | None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue