Skip to content

Commit

Permalink
flake8: Fix E721 check failures.
Browse files Browse the repository at this point in the history
E721: "do not compare types, for exact checks use `is` / `is not`, for
instance checks use `isinstance()`"

This fixes `make flake8-check` target when running with
pycodestyle>=1.2.

Signed-off-by: Ihar Hrachyshka <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
booxter authored and igsilya committed Nov 1, 2023
1 parent c0275d6 commit c187d06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion python/ovs/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def __init__(self, reconnect, rpc, remotes):
self.stream = None
self.pstream = None
self.seqno = 0
if type(remotes) != list:
if type(remotes) is not list:
remotes = [remotes]
self.remotes = remotes
random.shuffle(self.remotes)
Expand Down
4 changes: 2 additions & 2 deletions tests/test-jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ def main(argv):
sys.exit(1)

func, n_args = commands[command_name]
if type(n_args) == tuple:
if type(n_args) is tuple:
if len(args) < n_args[0]:
sys.stderr.write("%s: \"%s\" requires at least %d arguments but "
"only %d provided\n"
% (argv[0], command_name, n_args, len(args)))
sys.exit(1)
elif type(n_args) == int:
elif type(n_args) is int:
if len(args) != n_args:
sys.stderr.write("%s: \"%s\" requires %d arguments but %d "
"provided\n"
Expand Down
14 changes: 7 additions & 7 deletions tests/test-ovsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


def unbox_json(json):
if type(json) == list and len(json) == 1:
if type(json) is list and len(json) == 1:
return json[0]
else:
return json
Expand Down Expand Up @@ -325,9 +325,9 @@ def substitute_uuids(json, symtab):
symbol = symtab.get(json)
if symbol:
return str(symbol)
elif type(json) == list:
elif type(json) is list:
return [substitute_uuids(element, symtab) for element in json]
elif type(json) == dict:
elif type(json) is dict:
d = {}
for key, value in json.items():
d[key] = substitute_uuids(value, symtab)
Expand All @@ -341,10 +341,10 @@ def parse_uuids(json, symtab):
name = "#%d#" % len(symtab)
sys.stderr.write("%s = %s\n" % (name, json))
symtab[name] = json
elif type(json) == list:
elif type(json) is list:
for element in json:
parse_uuids(element, symtab)
elif type(json) == dict:
elif type(json) is dict:
for value in json.values():
parse_uuids(value, symtab)

Expand Down Expand Up @@ -1049,14 +1049,14 @@ def main(argv):
sys.exit(1)

func, n_args = commands[command_name]
if type(n_args) == tuple:
if type(n_args) is tuple:
if len(args) < n_args[0]:
sys.stderr.write("%s: \"%s\" requires at least %d arguments but "
"only %d provided\n"
% (ovs.util.PROGRAM_NAME, command_name,
n_args[0], len(args)))
sys.exit(1)
elif type(n_args) == int:
elif type(n_args) is int:
if len(args) != n_args:
sys.stderr.write("%s: \"%s\" requires %d arguments but %d "
"provided\n"
Expand Down

0 comments on commit c187d06

Please sign in to comment.