Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_shrink_types_mixed_dicts(self, types, expected_type):
assert shrink_types(types) == expected_type
def shrink_traced_types(traces: Iterable[CallTrace]) -> Tuple[Dict[str, type], Optional[type], Optional[type]]:
"""Merges the traced types and returns the minimally equivalent types"""
arg_types: DefaultDict[str, Set[type]] = collections.defaultdict(set)
return_types: Set[type] = set()
yield_types: Set[type] = set()
for t in traces:
for arg, typ in t.arg_types.items():
arg_types[arg].add(typ)
if t.return_type is not None:
return_types.add(t.return_type)
if t.yield_type is not None:
yield_types.add(t.yield_type)
shrunken_arg_types = {name: shrink_types(ts) for name, ts in arg_types.items()}
return_type = shrink_types(return_types) if return_types else None
yield_type = shrink_types(yield_types) if yield_types else None
return (shrunken_arg_types, return_type, yield_type)
def shrink_traced_types(traces: Iterable[CallTrace]) -> Tuple[Dict[str, type], Optional[type], Optional[type]]:
"""Merges the traced types and returns the minimally equivalent types"""
arg_types: DefaultDict[str, Set[type]] = collections.defaultdict(set)
return_types: Set[type] = set()
yield_types: Set[type] = set()
for t in traces:
for arg, typ in t.arg_types.items():
arg_types[arg].add(typ)
if t.return_type is not None:
return_types.add(t.return_type)
if t.yield_type is not None:
yield_types.add(t.yield_type)
shrunken_arg_types = {name: shrink_types(ts) for name, ts in arg_types.items()}
return_type = shrink_types(return_types) if return_types else None
yield_type = shrink_types(yield_types) if yield_types else None
return (shrunken_arg_types, return_type, yield_type)
def shrink_traced_types(traces: Iterable[CallTrace]) -> Tuple[Dict[str, type], Optional[type], Optional[type]]:
"""Merges the traced types and returns the minimally equivalent types"""
arg_types: DefaultDict[str, Set[type]] = collections.defaultdict(set)
return_types: Set[type] = set()
yield_types: Set[type] = set()
for t in traces:
for arg, typ in t.arg_types.items():
arg_types[arg].add(typ)
if t.return_type is not None:
return_types.add(t.return_type)
if t.yield_type is not None:
yield_types.add(t.yield_type)
shrunken_arg_types = {name: shrink_types(ts) for name, ts in arg_types.items()}
return_type = shrink_types(return_types) if return_types else None
yield_type = shrink_types(yield_types) if yield_types else None
return (shrunken_arg_types, return_type, yield_type)