def convert_type(ty, default=None):
 guessed_type = False
 if ((ty is None) and (default is not None)):
  if isinstance(default, tuple):
   ty = tuple(map(type, default))
  else:
   ty = type(default)
  guessed_type = True
 if isinstance(ty, tuple):
  return Tuple(ty)
 if isinstance(ty, ParamType):
  return ty
 if ((ty is text_type) or (ty is str) or (ty is None)):
  return STRING
 if (ty is int):
  return INT
 if ((ty is bool) and (not guessed_type)):
  return BOOL
 if (ty is float):
  return FLOAT
 if guessed_type:
  return STRING
 if __debug__:
  try:
   if issubclass(ty, ParamType):
    raise AssertionError(('Attempted to use an uninstantiated parameter type (%s).' % ty))
  except TypeError:
   pass
 return FuncParamType(ty)

def convert_type ( ty , default = None ) : guessed_type = False if ( ( ty is None ) and ( default is not None ) ) : if isinstance ( default , tuple ) : ty = tuple ( map ( type , default ) ) else : ty = type ( default ) guessed_type = True if isinstance ( ty , tuple ) : return Tuple ( ty ) if isinstance ( ty , ParamType ) : return ty if ( ( ty is text_type ) or ( ty is str ) or ( ty is None ) ) : return STRING if ( ty is int ) : return INT if ( ( ty is bool ) and ( not guessed_type ) ) : return BOOL if ( ty is float ) : return FLOAT if guessed_type : return STRING if __debug__ : try : if issubclass ( ty , ParamType ) : raise AssertionError ( ( 'Attempted to use an uninstantiated parameter type (%s).' % ty ) ) except TypeError : pass return FuncParamType ( ty )
converts a callable or python ty into the most appropriate param ty .