2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

flake8: Fix E721 check failures.

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.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Ihar Hrachyshka 2023-10-31 17:12:34 +00:00 committed by Ilya Maximets
parent 28f6e7602c
commit fdbf0bb2ae
3 changed files with 10 additions and 10 deletions

View File

@ -377,7 +377,7 @@ class Session(object):
self.stream = None self.stream = None
self.pstream = None self.pstream = None
self.seqno = 0 self.seqno = 0
if type(remotes) != list: if type(remotes) is not list:
remotes = [remotes] remotes = [remotes]
self.remotes = remotes self.remotes = remotes
random.shuffle(self.remotes) random.shuffle(self.remotes)

View File

@ -199,13 +199,13 @@ notify REMOTE METHOD PARAMS send notification and exit
sys.exit(1) sys.exit(1)
func, n_args = commands[command_name] func, n_args = commands[command_name]
if type(n_args) == tuple: if type(n_args) is tuple:
if len(args) < n_args[0]: if len(args) < n_args[0]:
sys.stderr.write("%s: \"%s\" requires at least %d arguments but " sys.stderr.write("%s: \"%s\" requires at least %d arguments but "
"only %d provided\n" "only %d provided\n"
% (argv[0], command_name, n_args, len(args))) % (argv[0], command_name, n_args, len(args)))
sys.exit(1) sys.exit(1)
elif type(n_args) == int: elif type(n_args) is int:
if len(args) != n_args: if len(args) != n_args:
sys.stderr.write("%s: \"%s\" requires %d arguments but %d " sys.stderr.write("%s: \"%s\" requires %d arguments but %d "
"provided\n" "provided\n"

View File

@ -37,7 +37,7 @@ vlog.init(None)
def unbox_json(json): def unbox_json(json):
if type(json) == list and len(json) == 1: if type(json) is list and len(json) == 1:
return json[0] return json[0]
else: else:
return json return json
@ -325,9 +325,9 @@ def substitute_uuids(json, symtab):
symbol = symtab.get(json) symbol = symtab.get(json)
if symbol: if symbol:
return str(symbol) return str(symbol)
elif type(json) == list: elif type(json) is list:
return [substitute_uuids(element, symtab) for element in json] return [substitute_uuids(element, symtab) for element in json]
elif type(json) == dict: elif type(json) is dict:
d = {} d = {}
for key, value in json.items(): for key, value in json.items():
d[key] = substitute_uuids(value, symtab) d[key] = substitute_uuids(value, symtab)
@ -341,10 +341,10 @@ def parse_uuids(json, symtab):
name = "#%d#" % len(symtab) name = "#%d#" % len(symtab)
sys.stderr.write("%s = %s\n" % (name, json)) sys.stderr.write("%s = %s\n" % (name, json))
symtab[name] = json symtab[name] = json
elif type(json) == list: elif type(json) is list:
for element in json: for element in json:
parse_uuids(element, symtab) parse_uuids(element, symtab)
elif type(json) == dict: elif type(json) is dict:
for value in json.values(): for value in json.values():
parse_uuids(value, symtab) parse_uuids(value, symtab)
@ -1049,14 +1049,14 @@ def main(argv):
sys.exit(1) sys.exit(1)
func, n_args = commands[command_name] func, n_args = commands[command_name]
if type(n_args) == tuple: if type(n_args) is tuple:
if len(args) < n_args[0]: if len(args) < n_args[0]:
sys.stderr.write("%s: \"%s\" requires at least %d arguments but " sys.stderr.write("%s: \"%s\" requires at least %d arguments but "
"only %d provided\n" "only %d provided\n"
% (ovs.util.PROGRAM_NAME, command_name, % (ovs.util.PROGRAM_NAME, command_name,
n_args[0], len(args))) n_args[0], len(args)))
sys.exit(1) sys.exit(1)
elif type(n_args) == int: elif type(n_args) is int:
if len(args) != n_args: if len(args) != n_args:
sys.stderr.write("%s: \"%s\" requires %d arguments but %d " sys.stderr.write("%s: \"%s\" requires %d arguments but %d "
"provided\n" "provided\n"