Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if isinstance(val, Set):
vals = _safe_iter(val)
num_items = samples['set']
if length is None or length > num_items + 2:
vals = islice(vals, num_items)
for i, v in enumerate(vals):
add_child('<%s>' % i, v)
d = getattr(val, '__dict__', None)
if d:
for k in sorted(islice(_safe_iter(d),
samples['attributes']),
key=str):
v = d[k]
if isinstance(v, TracedFile):
continue
add_child(str(k), v)
else:
for s in sorted(getattr(type(val), '__slots__', None) or ()):
try:
attr = getattr(val, s)
except AttributeError:
pass
else:
add_child(str(s), attr)
return result
def compile(self, source, filename, flags=0):
# type: (str, str, int) -> TracedFile
return TracedFile(self, source, filename, flags)
if isinstance(val, Set):
vals = _safe_iter(val)
num_items = samples['set']
if length is None or length > num_items + 2:
vals = islice(vals, num_items)
for i, v in enumerate(vals):
add_child('<%s>' % i, v)
d = getattr(val, '__dict__', None)
if d:
for k in sorted(islice(_safe_iter(d),
samples['attributes']),
key=str):
v = d[k]
if isinstance(v, TracedFile):
continue
add_child(str(k), v)
else:
for s in sorted(getattr(type(val), '__slots__', None) or ()):
try:
attr = getattr(val, s)
except AttributeError:
pass
else:
add_child(str(s), attr)
return result