mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(proxy): satisfy the type-discipline gate for the route-reordering fix
- routes/new_route: Final, closing the LIT010 rebind-openness gap - # mutable-ok / # rebind-ok on the app.router.routes reassignment: it necessarily constructs a list literal and mutates state reachable from the app parameter, since Starlette's own Router.routes must stay a real, appendable list for the framework's own route registration to keep working -- an immutable rewrite is not possible here, per CLAUDE.md's own last-resort carve-out for this case CI failure: LIT002 total exceeded budget by the 1 new violation this PR added (https://github.com/BerriAI/litellm/pull/38017/checks).
This commit is contained in:
parent
6f2b7bd887
commit
726a343bc4
1 changed files with 7 additions and 3 deletions
|
|
@ -2586,12 +2586,16 @@ class SafeRouteAdder:
|
|||
Builds the reordered list in one expression and reassigns app.router.routes
|
||||
wholesale, rather than mutating the existing list in place with pop()/insert().
|
||||
"""
|
||||
routes = app.routes
|
||||
new_route = routes[-1]
|
||||
routes: Final = app.routes
|
||||
new_route: Final = routes[-1]
|
||||
for index, route in enumerate(routes[:-1]):
|
||||
route_path = getattr(route, "path", None)
|
||||
if route_path and SafeRouteAdder._GENERIC_PROVIDER_PATH_MARKER in route_path:
|
||||
app.router.routes = [*routes[:index], new_route, *routes[index:-1]]
|
||||
app.router.routes = [ # mutable-ok: framework's list # rebind-ok: reordering is the fix
|
||||
*routes[:index],
|
||||
new_route,
|
||||
*routes[index:-1],
|
||||
]
|
||||
return
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue