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:
Ishaan Jaffer 2026-05-07 12:08:12 -07:00
parent 9379f7f206
commit cd5febf03d
No known key found for this signature in database

View file

@ -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,