@@ -7,13 +7,28 @@ def __init__(
77 self , attr_prefix : str ,
88 arg_names : _typing .Tuple [str , ...],
99 options : _typing .Iterable [_typing .Tuple [type , ...]],
10- function_module , api_module_name ):
10+ function_module , api_module_name ,
11+ default_callable : _typing .Callable = None ):
1112 self .options = set (options )
1213 self .attr_prefix = attr_prefix
1314 self .arg_names = arg_names
1415 self .function_module = function_module
1516 self .api_module_name = api_module_name
1617
18+ if default_callable is None :
19+ dynamic = type (
20+ f"{ self .__class__ .__name__ } _default_{ id (self )} " ,
21+ (self .__class__ ,),
22+ {"__call__" : generic_attribute .default_call },
23+ )
24+ else :
25+ dynamic = type (
26+ f"{ self .__class__ .__name__ } _func_{ id (self )} " ,
27+ (self .__class__ ,),
28+ {"__call__" : default_callable },
29+ )
30+ self .__class__ = dynamic
31+
1732 def __getitem__ (self , keys ):
1833 if not isinstance (keys , tuple ):
1934 keys = (keys ,)
@@ -45,7 +60,7 @@ def options_list(self):
4560
4661 return "\n " .join (opts )
4762
48- def __call__ (self , * args , ** kwargs ):
63+ def default_call (self , * args , ** kwargs ):
4964 raise TypeError (
5065 "No type information was paased to a generic function or type.\n "
5166 "This usually means that you forgot to add square brackets\n "
0 commit comments