Skip to content

Commit

Permalink
scripts/qmp-shell: use isinstance() instead of type()
Browse files Browse the repository at this point in the history
A bit more idiomatic, and quiets some linter warnings.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-17-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
  • Loading branch information
jnsnow committed Jun 18, 2021
1 parent 73f699c commit 90bd8eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/qmp/qmp-shell
Expand Up @@ -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')
Expand Down

0 comments on commit 90bd8eb

Please sign in to comment.