Message ID | 20231031171234.77162-1-ihrachys@redhat.com |
---|---|
State | Accepted |
Commit | fdbf0bb2aed53e70b455eb1adcfda8d8278ea690 |
Delegated to: | Ilya Maximets |
Headers | show |
Series | [ovs-dev] flake8: fix E721 check failures. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | warning | apply and check: warning |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
ovsrobot/intel-ovs-compilation | success | test: success |
On 31 Oct 2023, at 18:12, Ihar Hrachyshka wrote: > 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 <ihrachys@redhat.com> Hi Ihar, thanks for taking care of this! The changes look good to me. I guess only the subject might need some cleanup, but can probably be done at commit time. Acked-by: Eelco Chaudron <echaudro@redhat.com> Cheers, Eelco
On 11/1/23 10:38, Eelco Chaudron wrote: > > > On 31 Oct 2023, at 18:12, Ihar Hrachyshka wrote: > >> 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 <ihrachys@redhat.com> > > Hi Ihar, thanks for taking care of this! The changes look good to me. > > I guess only the subject might need some cleanup, but can probably be done at commit time. > > Acked-by: Eelco Chaudron <echaudro@redhat.com> Thanks, Ihar and Eelco! I fixed the checkpatch warning and applied the fix. Backported down to 2.17 to avoid build issues on LTS. Best regards, Ilya Maximets.
diff --git a/python/ovs/jsonrpc.py b/python/ovs/jsonrpc.py index d5127268a..d9fe27aec 100644 --- a/python/ovs/jsonrpc.py +++ b/python/ovs/jsonrpc.py @@ -377,7 +377,7 @@ class Session(object): 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) diff --git a/tests/test-jsonrpc.py b/tests/test-jsonrpc.py index 1df5afa22..8a4a17593 100644 --- a/tests/test-jsonrpc.py +++ b/tests/test-jsonrpc.py @@ -199,13 +199,13 @@ notify REMOTE METHOD PARAMS send notification and exit 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" diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py index a841adba4..71248854f 100644 --- a/tests/test-ovsdb.py +++ b/tests/test-ovsdb.py @@ -37,7 +37,7 @@ vlog.init(None) 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 @@ -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) @@ -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) @@ -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"
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 <ihrachys@redhat.com> --- python/ovs/jsonrpc.py | 2 +- tests/test-jsonrpc.py | 4 ++-- tests/test-ovsdb.py | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-)