From 6b9bc617cb39e140dbeafa91d2df8f395427caec Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 15 Feb 2026 06:40:40 +0000 Subject: [PATCH] fix: resolve ty unresolved-attribute on RuntimeError.status_code Use custom ExceptionWithStatus class instead of dynamically adding status_code to RuntimeError Co-authored-by: Ali Khokhar --- tests/test_api.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 905c7643..52c5f214 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -135,10 +135,13 @@ def test_generic_exception_returns_500(): def test_generic_exception_with_status_code(): """Generic exception with status_code attribute uses that status (getattr fallback).""" + class ExceptionWithStatus(RuntimeError): + def __init__(self, msg: str, status_code: int = 500): + super().__init__(msg) + self.status_code = status_code + def _raise_with_status(*args, **kwargs): - e = RuntimeError("bad gateway") - e.status_code = 502 - raise e + raise ExceptionWithStatus("bad gateway", 502) mock_provider.stream_response = _raise_with_status response = client.post(