mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-09 08:18:12 +00:00
fix(guardrails): mark RestrictedPython's unpack guard as untyped
The guarded_unpack_sequence import is partially unknown to basedpyright, which put reportUnknownVariableType one over its merge-base ceiling. RestrictedPython ships no type information, so suppress it on that line with the reason, the form the type-discipline gate accepts. Also type the async test helper and the parametrized test's arguments, which were the remaining new unknown-type diagnostics.
This commit is contained in:
parent
871948aeb5
commit
32dbbeaefe
2 changed files with 4 additions and 3 deletions
|
|
@ -31,7 +31,7 @@ from RestrictedPython.Eval import default_guarded_getitem
|
|||
from RestrictedPython.Guards import (
|
||||
full_write_guard,
|
||||
guarded_iter_unpack_sequence,
|
||||
guarded_unpack_sequence,
|
||||
guarded_unpack_sequence, # pyright: ignore[reportUnknownVariableType] # RestrictedPython is untyped
|
||||
safer_getattr,
|
||||
)
|
||||
from RestrictedPython.transformer import copy_locations
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import http.server
|
||||
import threading
|
||||
import time
|
||||
from collections.abc import AsyncIterator
|
||||
from http.server import ThreadingHTTPServer
|
||||
|
||||
import pytest
|
||||
|
|
@ -953,7 +954,7 @@ def test_async_for_gets_the_same_guards_as_for():
|
|||
assert async_unpack & {"_agetiter_", "_aiter_unpack_sequence_"}
|
||||
|
||||
|
||||
async def _arange(*values):
|
||||
async def _arange(*values: object) -> AsyncIterator[object]:
|
||||
for v in values:
|
||||
yield v
|
||||
|
||||
|
|
@ -974,7 +975,7 @@ async def _arange(*values):
|
|||
),
|
||||
],
|
||||
)
|
||||
async def test_async_for_still_executes(source, arg, expected):
|
||||
async def test_async_for_still_executes(source: str, arg: tuple[object, ...], expected: int):
|
||||
"""Guarding `async for` must not break it, in either target shape."""
|
||||
from litellm.proxy.guardrails.guardrail_hooks.custom_code.sandbox import (
|
||||
build_sandbox_globals,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue