From a354f626fe8a1a4468ed7ff4f253091bfb9f743d Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Sat, 20 Jan 2024 10:45:46 -0500 Subject: [PATCH] pybind/mgr/dashboard: fix typing issues Found using mypy 0.990. Fix mypy error by excluding both imports in the try-except block. Type-narrow the `ex.request` variable with an assert. Signed-off-by: John Mulligan --- src/pybind/mgr/dashboard/rest_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/dashboard/rest_client.py b/src/pybind/mgr/dashboard/rest_client.py index 69240bace86..9e27cb57802 100644 --- a/src/pybind/mgr/dashboard/rest_client.py +++ b/src/pybind/mgr/dashboard/rest_client.py @@ -23,7 +23,7 @@ from requests.exceptions import ConnectionError, InvalidURL, Timeout from .settings import Settings try: - from requests.packages.urllib3.exceptions import SSLError + from requests.packages.urllib3.exceptions import SSLError # type: ignore except ImportError: from urllib3.exceptions import SSLError # type: ignore @@ -433,6 +433,7 @@ class RestClient(object): method.upper(), str(ex)) raise RequestException(str(ex)) except Timeout as ex: + assert ex.request msg = "{} REST API {} timed out after {} seconds (url={}).".format( self.client_name, ex.request.method, Settings.REST_REQUESTS_TIMEOUT, ex.request.url) -- 2.39.5