From feaefc7f60cd3be7bf4ecc2b73e77d2bfe048403 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Srinivas=20Reddy=20Thatiparthy=20=28=E0=B0=B6=E0=B1=8D?= =?utf8?q?=E0=B0=B0=E0=B1=80=E0=B0=A8=E0=B0=BF=E0=B0=B5=E0=B0=BE=E0=B0=B8?= =?utf8?q?=E0=B1=8D=20=E0=B0=B0=E0=B1=86=E0=B0=A1=E0=B1=8D=E0=B0=A1?= =?utf8?q?=E0=B0=BF=20=E0=B0=A4=E0=B0=BE=E0=B0=9F=E0=B0=BF=E0=B0=AA?= =?utf8?q?=E0=B0=B0=E0=B1=8D=E0=B0=A4=E0=B0=BF=29?= Date: Fri, 9 Feb 2018 15:29:19 +0530 Subject: [PATCH] Cleanup inspect * use isinstance(..) instead of type(..) * use '.. not in ..' instead of 'not .. in .. ' --- Lib/inspect.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/inspect.py b/Lib/inspect.py index bc97efe179..109efc06b2 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -993,7 +993,7 @@ def getclasstree(classes, unique=False): for c in classes: if c.__bases__: for parent in c.__bases__: - if not parent in children: + if parent not in children: children[parent] = [] if c not in children[parent]: children[parent].append(c) @@ -1538,7 +1538,7 @@ def _shadowed_dict(klass): except KeyError: pass else: - if not (type(class_dict) is types.GetSetDescriptorType and + if not (isinstance(class_dict, types.GetSetDescriptorType) and class_dict.__name__ == "__dict__" and class_dict.__objclass__ is entry): return class_dict @@ -1560,7 +1560,7 @@ def getattr_static(obj, attr, default=_sentinel): klass = type(obj) dict_attr = _shadowed_dict(klass) if (dict_attr is _sentinel or - type(dict_attr) is types.MemberDescriptorType): + isinstance(dict_attr, types.MemberDescriptorType)): instance_result = _check_instance(obj, attr) else: klass = obj @@ -1975,7 +1975,7 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True): def parse_name(node): assert isinstance(node, ast.arg) - if node.annotation != None: + if node.annotation is not None: raise ValueError("Annotations are not currently supported") return node.arg -- 2.40.0