mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
fix(v2 managed agents): satisfy pyright on _row_to_agent_response config access
Use getattr with a None default and isinstance narrowing instead of hasattr to unwrap prisma.Json-style configs. Pyright was flagging .data access on the dict branch of the union; this rewrites the path so the type narrows cleanly without an Any cast.
This commit is contained in:
parent
9379f7f206
commit
cd5febf03d
1 changed files with 10 additions and 5 deletions
|
|
@ -118,12 +118,17 @@ def _row_to_agent_response(row: Dict[str, Any]) -> AgentRow:
|
|||
Handles both raw-dict configs (Prisma JSON column) and `prisma.Json`-wrapped
|
||||
configs (mock-style with a ``.data`` attribute).
|
||||
"""
|
||||
raw_config = row.get("config") or {}
|
||||
if hasattr(raw_config, "data"):
|
||||
# prisma.Json wrapper used by some test fakes
|
||||
config_dict: Dict[str, Any] = dict(raw_config.data)
|
||||
else:
|
||||
raw_config: Any = row.get("config") or {}
|
||||
# prisma.Json wrapper used by some test fakes exposes the dict via ``.data``;
|
||||
# use ``getattr`` so static type checkers don't flag attribute access on the
|
||||
# ``dict`` branch of the union.
|
||||
wrapped = getattr(raw_config, "data", None)
|
||||
if isinstance(wrapped, dict):
|
||||
config_dict: Dict[str, Any] = dict(wrapped)
|
||||
elif isinstance(raw_config, dict):
|
||||
config_dict = dict(raw_config)
|
||||
else:
|
||||
config_dict = {}
|
||||
|
||||
masked_config = {
|
||||
**config_dict,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue