Skip to content

Commit feaefc7

Browse files
srinivasreddymethane
authored andcommitted
Cleanup inspect
* use isinstance(..) instead of type(..) * use '.. not in ..' instead of 'not .. in .. '
1 parent a48e78a commit feaefc7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/inspect.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ def getclasstree(classes, unique=False):
993993
for c in classes:
994994
if c.__bases__:
995995
for parent in c.__bases__:
996-
if not parent in children:
996+
if parent not in children:
997997
children[parent] = []
998998
if c not in children[parent]:
999999
children[parent].append(c)
@@ -1538,7 +1538,7 @@ def _shadowed_dict(klass):
15381538
except KeyError:
15391539
pass
15401540
else:
1541-
if not (type(class_dict) is types.GetSetDescriptorType and
1541+
if not (isinstance(class_dict, types.GetSetDescriptorType) and
15421542
class_dict.__name__ == "__dict__" and
15431543
class_dict.__objclass__ is entry):
15441544
return class_dict
@@ -1560,7 +1560,7 @@ def getattr_static(obj, attr, default=_sentinel):
15601560
klass = type(obj)
15611561
dict_attr = _shadowed_dict(klass)
15621562
if (dict_attr is _sentinel or
1563-
type(dict_attr) is types.MemberDescriptorType):
1563+
isinstance(dict_attr, types.MemberDescriptorType)):
15641564
instance_result = _check_instance(obj, attr)
15651565
else:
15661566
klass = obj
@@ -1975,7 +1975,7 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
19751975

19761976
def parse_name(node):
19771977
assert isinstance(node, ast.arg)
1978-
if node.annotation != None:
1978+
if node.annotation is not None:
19791979
raise ValueError("Annotations are not currently supported")
19801980
return node.arg
19811981

0 commit comments

Comments
 (0)