fix: use getattr for pyright type checking on dynamic error attributes

Fixes pyright errors:
- Cannot access attribute 'code' for class 'Exception'
- Cannot access attribute 'param' for class 'Exception'

Using getattr() instead of direct attribute access satisfies pyright's
type checker while maintaining the same runtime behavior.
This commit is contained in:
Otto
2026-02-09 07:52:45 +00:00
parent b334f1a843
commit 495d01b09b

View File

@@ -1822,9 +1822,9 @@ def _extract_api_error_details(error: Exception) -> dict[str, Any]:
}
if hasattr(error, "code"):
details["code"] = error.code
details["code"] = getattr(error, "code", None)
if hasattr(error, "param"):
details["param"] = error.param
details["param"] = getattr(error, "param", None)
if isinstance(error, APIStatusError):
details["status_code"] = error.status_code