@@ -273,7 +273,7 @@ def register_api(cls, modifier=identity, attribute_name=None):
273273 >>> Stream().foo(...) # this works now
274274
275275 It attaches the callable as a normal attribute to the class object. In
276- doing so it respsects inheritance (all subclasses of Stream will also
276+ doing so it respects inheritance (all subclasses of Stream will also
277277 get the foo attribute).
278278
279279 By default callables are assumed to be instance methods. If you like
@@ -285,6 +285,15 @@ def register_api(cls, modifier=identity, attribute_name=None):
285285 ... ...
286286
287287 >>> Stream.foo(...) # Foo operates as a static method
288+
289+ You can also provide an optional ``attribute_name`` argument to control
290+ the name of the attribute your callable will be attached as.
291+
292+ >>> @Stream.register_api(attribute_name="bar")
293+ ... class foo(Stream):
294+ ... ...
295+
296+ >> Stream().bar(...) # foo was actually attached as bar
288297 """
289298 def _ (func ):
290299 @functools .wraps (func )
@@ -298,11 +307,17 @@ def wrapped(*args, **kwargs):
298307 @classmethod
299308 def register_plugin_entry_point (cls , entry_point , modifier = identity ):
300309 def stub (* args , ** kwargs ):
301- attribute = entry_point .load ()
310+ node = entry_point .load ()
311+ if not issubclass (node , Stream ):
312+ raise TypeError (
313+ f"Error loading { entry_point .name } "
314+ f"from module { entry_point .module_name } : "
315+ f"{ entry_point .cls .__name__ } must be a subclass of Stream"
316+ )
302317 cls .register_api (
303318 modifier = modifier , attribute_name = entry_point .name
304- )(attribute )
305- return attribute (* args , ** kwargs )
319+ )(node )
320+ return node (* args , ** kwargs )
306321 cls .register_api (modifier = modifier , attribute_name = entry_point .name )(stub )
307322
308323 def start (self ):
0 commit comments