[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 34/72] scripts/qmp-shell: use @classmethod where appropriate
From: |
John Snow |
Subject: |
[PATCH v2 34/72] scripts/qmp-shell: use @classmethod where appropriate |
Date: |
Tue, 3 Nov 2020 19:35:24 -0500 |
Methods with no self-use should belong to the class.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qmp-shell | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index 6767a01eaaed..69359ec8ad7f 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -101,7 +101,8 @@ class FuzzyJSON(ast.NodeTransformer):
'''This extension of ast.NodeTransformer filters literal "true/false/null"
values in an AST and replaces them by proper "True/False/None" values that
Python can properly evaluate.'''
- def visit_Name(self, node):
+ @classmethod
+ def visit_Name(cls, node):
if node.id == 'true':
node.id = 'True'
if node.id == 'false':
@@ -124,7 +125,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
self._histfile = os.path.join(os.path.expanduser('~'),
'.qmp-shell_history')
- def __get_address(self, arg):
+ @classmethod
+ def __get_address(cls, arg):
"""
Figure out if the argument is in the port:host form, if it's not it's
probably a file path.
@@ -171,7 +173,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
except Exception as e:
print("Failed to save history file '%s'; %s" % (self._histfile, e))
- def __parse_value(self, val):
+ @classmethod
+ def __parse_value(cls, val):
try:
return int(val)
except ValueError:
--
2.26.2
- [PATCH v2 21/72] scripts/qemu-ga-client: add module docstring, (continued)
- [PATCH v2 21/72] scripts/qemu-ga-client: add module docstring, John Snow, 2020/11/03
- [PATCH v2 27/72] scripts/qemu-ga-client: Add forwarder stub, John Snow, 2020/11/03
- [PATCH v2 25/72] scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.py, John Snow, 2020/11/03
- [PATCH v2 17/72] scripts/qemu-ga-client: apply isort rules, John Snow, 2020/11/03
- [PATCH v2 14/72] scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.py, John Snow, 2020/11/03
- [PATCH v2 22/72] scripts/qemu-ga-client: apply (most) pylint rules, John Snow, 2020/11/03
- [PATCH v2 31/72] scripts/qmp-shell: fix exception handling, John Snow, 2020/11/03
- [PATCH v2 32/72] scripts/qmp-shell: fix connect method signature, John Snow, 2020/11/03
- [PATCH v2 30/72] scripts/qmp-shell: fix show_banner signature, John Snow, 2020/11/03
- [PATCH v2 35/72] scripts/qmp-shell: Use python3-style super(), John Snow, 2020/11/03
- [PATCH v2 34/72] scripts/qmp-shell: use @classmethod where appropriate,
John Snow <=
- [PATCH v2 40/72] scripts/qmp-shell: rename one and two-letter variables, John Snow, 2020/11/03
- [PATCH v2 24/72] scripts/qmp/qemu-ga-client: add mypy type hints, John Snow, 2020/11/03
- [PATCH v2 33/72] scripts/qmp-shell: remove shadowed variable from _print(), John Snow, 2020/11/03
- [PATCH v2 36/72] scripts/qmp-shell: declare verbose in __init__, John Snow, 2020/11/03
- [PATCH v2 39/72] scripts/qmp-shell: make QMPCompleter returns explicit, John Snow, 2020/11/03
- [PATCH v2 42/72] scripts/qmp-shell: explicitly chain exception context, John Snow, 2020/11/03
- [PATCH v2 37/72] scripts/qmp-shell: use triple-double-quote docstring style, John Snow, 2020/11/03
- [PATCH v2 43/72] scripts/qmp-shell: remove if-raise-else patterns, John Snow, 2020/11/03
- [PATCH v2 41/72] scripts/qmp-shell: fix shell history exception handling, John Snow, 2020/11/03
- [PATCH v2 44/72] scripts/qmp-shell: use isinstance() instead of type(), John Snow, 2020/11/03