@composite
def tagged_union_strategy(draw, type_, attr_strategies):
 invariant = type_.__invariant__
 tag = draw(sampled_from(invariant._allowed_tags))
 attributes = {invariant.tag_attribute: tag}
 for (name, strategy) in attr_strategies.items():
  if ((name in invariant.attributes_for_tag[tag]) or (name not in invariant._all_attributes)):
   attributes[name] = draw(strategy)
 return type_(**attributes)

@ composite def tagged_union_strategy ( draw , type_ , attr_strategies ) : invariant = type_ . __invariant__ tag = draw ( sampled_from ( invariant . _allowed_tags ) ) attributes = { invariant . tag_attribute : tag } for ( name , strategy ) in attr_strategies . items ( ) : if ( ( name in invariant . attributes_for_tag [ tag ] ) or ( name not in invariant . _all_attributes ) ) : attributes [ name ] = draw ( strategy ) return type_ ( ** attributes )
create a strategy for building a type with a taggedunioninvariant .