@@ -190,7 +190,7 @@ def __exit__(self, typ, value, traceback): # pylint: disable=unused-argument
190190        # We strip off keyword args, per the warning from 
191191        # StackExchange: 
192192        # DO NOT send "**kargs" to "type.__new__".  It won't catch them and 
193-         # you'll get a "TypeError: type() takes 1 or 3 arguments" exception.     
193+         # you'll get a "TypeError: type() takes 1 or 3 arguments" exception. 
194194        return  super ().__new__ (cls , name , bases , dct )
195195
196196    # FIXME: is there a more elegant way to automatically add methods to the class that 
@@ -200,7 +200,7 @@ def __init__(cls, name, bases, nmspc, context_class: Optional[Type]=None, **kwar
200200        if  context_class  is  not None :
201201            cls ._context_class  =  context_class 
202202        super ().__init__ (name , bases , nmspc )
203-          
203+ 
204204
205205
206206    def  get_context (cls , error_if_none = True ) ->  Optional [T ]:
@@ -228,7 +228,7 @@ def get_contexts(cls) -> List[T]:
228228        # but since the context class is not guaranteed to exist when 
229229        # the metaclass is being instantiated, I couldn't figure out a 
230230        # better way. [2019/10/11:rpg] 
231-          
231+ 
232232        # no race-condition here, contexts is a thread-local object 
233233        # be sure not to override contexts in a subclass however! 
234234        context_class  =  cls .context_class 
@@ -284,8 +284,11 @@ def modelcontext(model: Optional['Model']) -> 'Model':
284284    """ 
285285    if  model  is  None :
286286        model  =  Model .get_context (error_if_none = False )
287+ 
287288        if  model  is  None :
288-             raise  ValueError ("No model on context stack." )
289+             # TODO: This should be a ValueError, but that breaks 
290+             # ArviZ (and others?), so might need a deprecation. 
291+             raise  TypeError ("No model on context stack." )
289292    return  model 
290293
291294
0 commit comments