def type_callable(func):
 from .typing.templates import CallableTemplate, infer, infer_global
 if ((not callable(func)) and (not isinstance(func, str))):
  raise TypeError('`func` should be a function or string')
 try:
  func_name = func.__name__
 except AttributeError:
  func_name = str(func)
 def decorate(typing_func):
  def generic(self):
   return typing_func(self.context)
  name = ('%s_CallableTemplate' % (func_name,))
  bases = (CallableTemplate,)
  class_dict = dict(key=func, generic=generic)
  template = type(name, bases, class_dict)
  infer(template)
  if hasattr(func, '__module__'):
   infer_global(func, types.Function(template))
 return decorate

def type_callable ( func ) : from . typing . templates import CallableTemplate , infer , infer_global if ( ( not callable ( func ) ) and ( not isinstance ( func , str ) ) ) : raise TypeError ( '`func` should be a function or string' ) try : func_name = func . __name__ except AttributeError : func_name = str ( func ) def decorate ( typing_func ) : def generic ( self ) : return typing_func ( self . context ) name = ( '%s_CallableTemplate' % ( func_name , ) ) bases = ( CallableTemplate , ) class_dict = dict ( key = func , generic = generic ) template = type ( name , bases , class_dict ) infer ( template ) if hasattr ( func , '__module__' ) : infer_global ( func , types . Function ( template ) ) return decorate
decorate a function as implementing typing for the callable *func* .