]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr/dashboard: fix typing issues
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 20 Jan 2024 15:45:46 +0000 (10:45 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 23 Jan 2024 14:45:40 +0000 (09:45 -0500)
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 <jmulligan@redhat.com>
src/pybind/mgr/dashboard/rest_client.py

index 69240bace86678ebd58607b0566960cad1ba22ea..9e27cb57802da677b12701c9e3f731f4643df584 100644 (file)
@@ -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)