mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
Cleanup inspect
* use isinstance(..) instead of type(..) * use '.. not in ..' instead of 'not .. in .. '
This commit is contained in:
parent
a48e78a0b7
commit
feaefc7f60
1 changed files with 4 additions and 4 deletions
|
@ -993,7 +993,7 @@ def getclasstree(classes, unique=False):
|
||||||
for c in classes:
|
for c in classes:
|
||||||
if c.__bases__:
|
if c.__bases__:
|
||||||
for parent in c.__bases__:
|
for parent in c.__bases__:
|
||||||
if not parent in children:
|
if parent not in children:
|
||||||
children[parent] = []
|
children[parent] = []
|
||||||
if c not in children[parent]:
|
if c not in children[parent]:
|
||||||
children[parent].append(c)
|
children[parent].append(c)
|
||||||
|
@ -1538,7 +1538,7 @@ def _shadowed_dict(klass):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
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.__name__ == "__dict__" and
|
||||||
class_dict.__objclass__ is entry):
|
class_dict.__objclass__ is entry):
|
||||||
return class_dict
|
return class_dict
|
||||||
|
@ -1560,7 +1560,7 @@ def getattr_static(obj, attr, default=_sentinel):
|
||||||
klass = type(obj)
|
klass = type(obj)
|
||||||
dict_attr = _shadowed_dict(klass)
|
dict_attr = _shadowed_dict(klass)
|
||||||
if (dict_attr is _sentinel or
|
if (dict_attr is _sentinel or
|
||||||
type(dict_attr) is types.MemberDescriptorType):
|
isinstance(dict_attr, types.MemberDescriptorType)):
|
||||||
instance_result = _check_instance(obj, attr)
|
instance_result = _check_instance(obj, attr)
|
||||||
else:
|
else:
|
||||||
klass = obj
|
klass = obj
|
||||||
|
@ -1975,7 +1975,7 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
|
||||||
|
|
||||||
def parse_name(node):
|
def parse_name(node):
|
||||||
assert isinstance(node, ast.arg)
|
assert isinstance(node, ast.arg)
|
||||||
if node.annotation != None:
|
if node.annotation is not None:
|
||||||
raise ValueError("Annotations are not currently supported")
|
raise ValueError("Annotations are not currently supported")
|
||||||
return node.arg
|
return node.arg
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue