Skip to content
Snippets Groups Projects
Commit 90bd8eb8 authored by John Snow's avatar John Snow
Browse files

scripts/qmp-shell: use isinstance() instead of type()


A bit more idiomatic, and quiets some linter warnings.

Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-17-jsnow@redhat.com
Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
parent 73f699c9
No related branches found
No related tags found
No related merge requests found
......@@ -195,13 +195,13 @@ class QMPShell(qmp.QEMUMonitorProtocol):
for path in optpath[:-1]:
curpath.append(path)
obj = parent.get(path, {})
if type(obj) is not dict:
if not isinstance(obj, dict):
msg = 'Cannot use "{:s}" as both leaf and non-leaf key'
raise QMPShellError(msg.format('.'.join(curpath)))
parent[path] = obj
parent = obj
if optpath[-1] in parent:
if type(parent[optpath[-1]]) is dict:
if isinstance(parent[optpath[-1]], dict):
msg = 'Cannot use "{:s}" as both leaf and non-leaf key'
raise QMPShellError(msg.format('.'.join(curpath)))
raise QMPShellError(f'Cannot set "{key}" multiple times')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment