From: Martin Kletzander Date: Wed, 16 Apr 2025 07:59:44 +0000 (+0200) Subject: python: Do not explicitly state variables are global when only read X-Git-Tag: v11.3.0-rc1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=750eaf2243941b73a70d1c7a6dd14d5230c18a3a;p=thirdparty%2Flibvirt.git python: Do not explicitly state variables are global when only read If a variable is not modified in a scope there is no need for the use of global in such scope. Without this patch build fails with: F824 `global ...` is unused: name is never assigned in scope It is a bit difficult to find more information on that message and error code, I found it here: https://docs.astral.sh/ruff/rules/global-variable-not-assigned/ Signed-off-by: Martin Kletzander Reviewed-by: Jiri Denemark --- diff --git a/scripts/apibuild.py b/scripts/apibuild.py index 3ecc3eadf7..a30e87969a 100755 --- a/scripts/apibuild.py +++ b/scripts/apibuild.py @@ -818,8 +818,6 @@ class CParser: # Parse a comment block associate to a macro # def parseMacroComment(self, name, quiet=0): - global ignored_macros - if name[0:2] == '__': quiet = 1 if name in ignored_macros: @@ -895,8 +893,6 @@ class CParser: # as possible # def mergeFunctionComment(self, name, description, quiet=0): - global ignored_functions - if name == 'main': quiet = 1 if name[0:2] == '__': @@ -1135,8 +1131,6 @@ class CParser: self.lexer.push(tok) def token(self): - global ignored_words - token = self.lexer.token() while token is not None: if token[0] == 'comment': diff --git a/tools/virt-qemu-qmp-proxy b/tools/virt-qemu-qmp-proxy index dcdb24b9a9..39e98e9d51 100755 --- a/tools/virt-qemu-qmp-proxy +++ b/tools/virt-qemu-qmp-proxy @@ -278,7 +278,6 @@ class QMPProxy(object): else: error = True except Exception as e: - global debug if debug: print("%s: %s" % (sys.argv[0], str(e))) print(traceback.format_exc())