mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-09 08:18:12 +00:00
fix(guardrails): keep visit_AsyncFor's result typed
The type-check gate measures in .venv-typecheck, where RestrictedPython is not installed, so `self.visit_For(node)` is Unknown there. Binding it to `transformed` and passing it on added one reportUnknownVariableType and one reportUnknownArgumentType over the merge-base ceiling. `guard_iter` rewrites `node.iter` on the node it is given and returns that same node, so keep working on `node`. In that environment sandbox.py now has 18 reportUnknownVariableType (base 19) and 2 reportUnknownArgumentType (base 2). All 67 tests in test_custom_code_security.py pass.
This commit is contained in:
parent
32dbbeaefe
commit
74c3bb2f06
1 changed files with 4 additions and 3 deletions
|
|
@ -82,9 +82,10 @@ class AsyncAwareTransformer(RestrictingNodeTransformer):
|
|||
return bounded
|
||||
|
||||
def visit_AsyncFor(self, node: ast.AsyncFor) -> ast.AST:
|
||||
transformed: Final = self.visit_For(node)
|
||||
_use_async_iter_guards(transformed)
|
||||
return transformed
|
||||
# `guard_iter` rewrites `node.iter` on the node it is given and returns it.
|
||||
self.visit_For(node)
|
||||
_use_async_iter_guards(node)
|
||||
return node
|
||||
|
||||
def visit_AsyncWith(self, node: ast.AsyncWith) -> ast.AST:
|
||||
return self.visit_With(node)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue