Fixes mypy type error where router_model_names (a set) was incompatible
with List[str] parameter type.
Changed check_file_size_under_limit to accept Collection[str] instead of
List[str] since the parameter is only used for membership checks, making
it more flexible and avoiding unnecessary type conversions.
Resolves: proxy/proxy_server.py:5107 arg-type error
Update test_generate_model_id_with_deployment_model_name to accept the new
error message format that results from the list+join optimization.
The function still correctly rejects None values with a TypeError, but the
error message changed from 'unsupported operand type(s) for +=' to
'expected str instance, NoneType found' due to the implementation change
from string concatenation to list joining.
Replace string concatenation in loop with list append + join pattern.
This improves time complexity from O(n²) to O(n) and avoids creating
many temporary string objects during hash ID generation.
Replace copy.deepcopy() with dict.copy() in _get_all_deployments when
creating model aliases.
Safe because:
1. Only modifies top-level 'model_name' field (isolated by shallow copy)
2. Nested dicts (litellm_params, model_info) are never modified after return
3. When model_alias=None, returns original dict with NO copy, proving
callers expect nested structures to be read-only
4. Key insight: Code that needs to modify nested structures does deepcopy FIRST.
This proves the contract is: \"treat returned deployments as read-only for
nested fields.\" (see line 6894: copy.deepcopy before modifying litellm_params)
Performance: ~10-100x faster than deepcopy on nested dict structures.
Tests: All 114 router unit tests pass.
Add AST-based test to detect 'for ... in self.model_list' anti-pattern.
Enforces use of index maps (model_id_to_deployment_index_map and
model_name_to_deployment_indices) for O(1) lookups instead of O(n) iteration.
- Use model_id_to_deployment_index_map and model_name_to_deployment_indices for O(1) lookups in get_model_info, get_deployment_by_model_group_name, and get_model_ids