mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
python: avoid equality check for None
PEP8 says that: "Comparisons to singletons like None should always be done with is or is not, never the equality operators." glib uses a mix of "== None" and "is None". This patch changes all cases to the latter.
This commit is contained in:
@@ -1068,7 +1068,7 @@ class CodeGenerator:
|
||||
'\n')
|
||||
|
||||
def generate_annotations(self, prefix, annotations):
|
||||
if annotations == None:
|
||||
if annotations is None:
|
||||
return
|
||||
|
||||
n = 0
|
||||
|
@@ -63,38 +63,38 @@ def apply_annotation(iface_list, iface, method, signal, prop, arg, key, value):
|
||||
iface_obj = i
|
||||
break
|
||||
|
||||
if iface_obj == None:
|
||||
if iface_obj is None:
|
||||
print_error('No interface "{}"'.format(iface))
|
||||
|
||||
target_obj = None
|
||||
|
||||
if method:
|
||||
method_obj = find_method(iface_obj, method)
|
||||
if method_obj == None:
|
||||
if method_obj is None:
|
||||
print_error('No method "{}" on interface "{}"'.format(method, iface))
|
||||
if arg:
|
||||
arg_obj = find_arg(method_obj.in_args, arg)
|
||||
if (arg_obj == None):
|
||||
if (arg_obj is None):
|
||||
arg_obj = find_arg(method_obj.out_args, arg)
|
||||
if (arg_obj == None):
|
||||
if (arg_obj is None):
|
||||
print_error('No arg "{}" on method "{}" on interface "{}"'.format(arg, method, iface))
|
||||
target_obj = arg_obj
|
||||
else:
|
||||
target_obj = method_obj
|
||||
elif signal:
|
||||
signal_obj = find_signal(iface_obj, signal)
|
||||
if signal_obj == None:
|
||||
if signal_obj is None:
|
||||
print_error('No signal "{}" on interface "{}"'.format(signal, iface))
|
||||
if arg:
|
||||
arg_obj = find_arg(signal_obj.args, arg)
|
||||
if (arg_obj == None):
|
||||
if (arg_obj is None):
|
||||
print_error('No arg "{}" on signal "{}" on interface "{}"'.format(arg, signal, iface))
|
||||
target_obj = arg_obj
|
||||
else:
|
||||
target_obj = signal_obj
|
||||
elif prop:
|
||||
prop_obj = find_prop(iface_obj, prop)
|
||||
if prop_obj == None:
|
||||
if prop_obj is None:
|
||||
print_error('No property "{}" on interface "{}"'.format(prop, iface))
|
||||
target_obj = prop_obj
|
||||
else:
|
||||
|
@@ -61,7 +61,7 @@ class Arg:
|
||||
if len(self.since) == 0:
|
||||
self.since = utils.lookup_since(self.annotations)
|
||||
|
||||
if self.name == None:
|
||||
if self.name is None:
|
||||
self.name = 'unnamed_arg%d'%arg_number
|
||||
# default to GVariant
|
||||
self.ctype_in_g = 'GVariant *'
|
||||
|
@@ -116,21 +116,21 @@ def lookup_annotation(annotations, key):
|
||||
|
||||
def lookup_docs(annotations):
|
||||
s = lookup_annotation(annotations, 'org.gtk.GDBus.DocString')
|
||||
if s == None:
|
||||
if s is None:
|
||||
return ''
|
||||
else:
|
||||
return s
|
||||
|
||||
def lookup_since(annotations):
|
||||
s = lookup_annotation(annotations, 'org.gtk.GDBus.Since')
|
||||
if s == None:
|
||||
if s is None:
|
||||
return ''
|
||||
else:
|
||||
return s
|
||||
|
||||
def lookup_brief_docs(annotations):
|
||||
s = lookup_annotation(annotations, 'org.gtk.GDBus.DocString.Short')
|
||||
if s == None:
|
||||
if s is None:
|
||||
return ''
|
||||
else:
|
||||
return s
|
||||
|
Reference in New Issue
Block a user