@@ -190,7 +190,7 @@ def __exit__(self, typ, value, traceback): # pylint: disable=unused-argument
190
190
# We strip off keyword args, per the warning from
191
191
# StackExchange:
192
192
# 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.
194
194
return super ().__new__ (cls , name , bases , dct )
195
195
196
196
# 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
200
200
if context_class is not None :
201
201
cls ._context_class = context_class
202
202
super ().__init__ (name , bases , nmspc )
203
-
203
+
204
204
205
205
206
206
def get_context (cls , error_if_none = True ) -> Optional [T ]:
@@ -228,7 +228,7 @@ def get_contexts(cls) -> List[T]:
228
228
# but since the context class is not guaranteed to exist when
229
229
# the metaclass is being instantiated, I couldn't figure out a
230
230
# better way. [2019/10/11:rpg]
231
-
231
+
232
232
# no race-condition here, contexts is a thread-local object
233
233
# be sure not to override contexts in a subclass however!
234
234
context_class = cls .context_class
@@ -284,8 +284,11 @@ def modelcontext(model: Optional['Model']) -> 'Model':
284
284
"""
285
285
if model is None :
286
286
model = Model .get_context (error_if_none = False )
287
+
287
288
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." )
289
292
return model
290
293
291
294
0 commit comments