def interface_field(interfaces, **field_kwargs):
 if (not isinstance(interfaces, tuple)):
  raise TypeError('The ``interfaces`` argument must be a tuple. Got: {!r}'.format(interfaces))
 original_invariant = field_kwargs.pop('invariant', None)
 def invariant(value):
  error_messages = []
  if (original_invariant is not None):
   (original_invariant_result, _original_invariant_message) = original_invariant(value)
   if original_invariant_result:
    error_messages.append(original_invariant_result)
  missing_interfaces = []
  for interface in interfaces:
   if (not interface.providedBy(value)):
    missing_interfaces.append(interface.getName())
  if missing_interfaces:
   error_messages.append('The value {!r} did not provide these required interfaces: {}'.format(value, ', '.join(missing_interfaces)))
  if error_messages:
   return (False, '\n'.join(error_messages))
  else:
   return (True, '')
 field_kwargs['invariant'] = invariant
 return field(**field_kwargs)

def interface_field ( interfaces , ** field_kwargs ) : if ( not isinstance ( interfaces , tuple ) ) : raise TypeError ( 'The ``interfaces`` argument must be a tuple. Got: {!r}' . format ( interfaces ) ) original_invariant = field_kwargs . pop ( 'invariant' , None ) def invariant ( value ) : error_messages = [ ] if ( original_invariant is not None ) : ( original_invariant_result , _original_invariant_message ) = original_invariant ( value ) if original_invariant_result : error_messages . append ( original_invariant_result ) missing_interfaces = [ ] for interface in interfaces : if ( not interface . providedBy ( value ) ) : missing_interfaces . append ( interface . getName ( ) ) if missing_interfaces : error_messages . append ( 'The value {!r} did not provide these required interfaces: {}' . format ( value , ', ' . join ( missing_interfaces ) ) ) if error_messages : return ( False , '\n' . join ( error_messages ) ) else : return ( True , '' ) field_kwargs [ 'invariant' ] = invariant return field ( ** field_kwargs )
a pclass field which checks that the assigned value provides all the interfaces .