#NEWLINE# def __getitem__( self , type_params ) : #NEWLINE# #INDENT# if ( not isinstance ( type_params , ( collections . Sequence , set ) ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Cannot create Union without a sequence of types.' ) #NEWLINE# #UNINDENT# params = set ( ) #NEWLINE# for t in type_params : #NEWLINE# #INDENT# validate_composite_type_param ( t , error_msg_prefix = 'All parameters to a Union hint' ) #NEWLINE# if isinstance ( t , self . UnionConstraint ) : #NEWLINE# #INDENT# params |= t . union_types #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# params . add ( t ) #NEWLINE# #UNINDENT# #UNINDENT# if ( Any in params ) : #NEWLINE# #INDENT# return Any #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( params ) == 1 ) : #NEWLINE# #INDENT# return iter ( params ) . next ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . UnionConstraint ( params )