mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 22:35:15 +00:00
python: Resolve pep8 comparison errors.
Resolve pep8 errors: E711 comparison to None should be 'if cond is None:' The reason comparing against None with "is None" is preferred over "== None" is because a class can define its own equality operator and produce bizarre unexpected behavior. Using "is None" has a very explicit meaning that can not be overridden. E721 do not compare types, use 'isinstance()' This one is actually a mistake by the tool in most cases. 'from ovs.db import types' looks just like types from the Python stdlib. In those cases, use the full ovs.db.types name. Fix one case where it actually was types from the stdlib. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -179,7 +179,7 @@ class Idl(object):
|
||||
if (msg.type == ovs.jsonrpc.Message.T_NOTIFY
|
||||
and msg.method == "update"
|
||||
and len(msg.params) == 2
|
||||
and msg.params[0] == None):
|
||||
and msg.params[0] is None):
|
||||
# Database contents changed.
|
||||
self.__parse_update(msg.params[1])
|
||||
elif (msg.type == ovs.jsonrpc.Message.T_REPLY
|
||||
|
@@ -80,7 +80,7 @@ def is_identifier(s):
|
||||
|
||||
|
||||
def json_type_to_string(type_):
|
||||
if type_ == None:
|
||||
if type_ is None:
|
||||
return "null"
|
||||
elif type_ == bool:
|
||||
return "boolean"
|
||||
|
@@ -17,7 +17,7 @@ import sys
|
||||
|
||||
from ovs.db import error
|
||||
import ovs.db.parser
|
||||
from ovs.db import types
|
||||
import ovs.db.types
|
||||
|
||||
|
||||
def _check_id(name, json):
|
||||
@@ -101,7 +101,8 @@ class DbSchema(object):
|
||||
return DbSchema.from_json(self.to_json())
|
||||
|
||||
def __follow_ref_table(self, column, base, base_name):
|
||||
if not base or base.type != types.UuidType or not base.ref_table_name:
|
||||
if (not base or base.type != ovs.db.types.UuidType
|
||||
or not base.ref_table_name):
|
||||
return
|
||||
|
||||
base.ref_table = self.tables.get(base.ref_table_name)
|
||||
@@ -181,7 +182,7 @@ class TableSchema(object):
|
||||
indexes_json = parser.get_optional("indexes", [list], [])
|
||||
parser.finish()
|
||||
|
||||
if max_rows == None:
|
||||
if max_rows is None:
|
||||
max_rows = sys.maxint
|
||||
elif max_rows <= 0:
|
||||
raise error.Error("maxRows must be at least 1", json)
|
||||
@@ -257,7 +258,8 @@ class ColumnSchema(object):
|
||||
parser = ovs.db.parser.Parser(json, "schema for column %s" % name)
|
||||
mutable = parser.get_optional("mutable", [bool], True)
|
||||
ephemeral = parser.get_optional("ephemeral", [bool], False)
|
||||
type_ = types.Type.from_json(parser.get("type", [dict, str, unicode]))
|
||||
type_ = ovs.db.types.Type.from_json(parser.get("type",
|
||||
[dict, str, unicode]))
|
||||
parser.finish()
|
||||
|
||||
return ColumnSchema(name, mutable, not ephemeral, type_)
|
||||
|
@@ -579,7 +579,7 @@ class Parser(object):
|
||||
elif self.parse_state != Parser.__parse_end:
|
||||
self.__error("unexpected end of input")
|
||||
|
||||
if self.error == None:
|
||||
if self.error is None:
|
||||
assert len(self.stack) == 1
|
||||
return self.stack.pop()
|
||||
else:
|
||||
|
@@ -490,7 +490,7 @@ class Session(object):
|
||||
request.id = "echo"
|
||||
self.rpc.send(request)
|
||||
else:
|
||||
assert action == None
|
||||
assert action is None
|
||||
|
||||
def wait(self, poller):
|
||||
if self.rpc is not None:
|
||||
|
Reference in New Issue
Block a user