]> git.proxmox.com Git - mirror_qemu.git/commitdiff
sphinx/qapidoc: Tidy up pylint warning raise-missing-from
authorMarkus Armbruster <armbru@redhat.com>
Wed, 25 Oct 2023 09:21:59 +0000 (11:21 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 13 Nov 2023 09:36:51 +0000 (10:36 +0100)
Pylint advises:

    docs/sphinx/qapidoc.py:518:12: W0707: Consider explicitly re-raising using 'raise ExtensionError(str(err)) from err' (raise-missing-from)

>From its manual:

    Python's exception chaining shows the traceback of the current
    exception, but also of the original exception.  When you raise a
    new exception after another exception was caught it's likely that
    the second exception is a friendly re-wrapping of the first
    exception.  In such cases `raise from` provides a better link
    between the two tracebacks in the final error.

Makes sense, so do it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20231025092159.1782638-2-armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
docs/sphinx/qapidoc.py

index 8f3b9997a1532b4dc3adc90ab373d67fe8861659..658c288f8fe9b674e8c7230053658f44934145e5 100644 (file)
@@ -515,7 +515,7 @@ class QAPIDocDirective(Directive):
         except QAPIError as err:
             # Launder QAPI parse errors into Sphinx extension errors
             # so they are displayed nicely to the user
-            raise ExtensionError(str(err))
+            raise ExtensionError(str(err)) from err
 
     def do_parse(self, rstlist, node):
         """Parse rST source lines and add them to the specified node