diff --git a/autobahn/wamp/protocol.py b/autobahn/wamp/protocol.py index 2035d0c1c..ca055c433 100644 --- a/autobahn/wamp/protocol.py +++ b/autobahn/wamp/protocol.py @@ -502,13 +502,17 @@ async def _type_check(*args, **kwargs): response = [] for name, kind in func.__annotations__.items(): if name in arguments: + # if a "type" has __origin__ attribute it is a + # parameterized generic if getattr(kind, "__origin__", None) == Union: + expected_types = [arg.__name__ for arg in kind.__args__] if not isinstance(arguments[name], kind.__args__): response.append( - "'{}' required={} got={}".format(name, kind.__name__, type(arguments[name]).__name__)) + "'{}' expected types={} got={}".format(name, expected_types, + type(arguments[name]).__name__)) elif not isinstance(arguments[name], kind): response.append( - "'{}' required={} got={}".format(name, kind.__name__, type(arguments[name]).__name__)) + "'{}' expected type={} got={}".format(name, kind.__name__, type(arguments[name]).__name__)) if response: raise TypeCheckError(', '.join(response)) return await txaio.as_future(func, *args, **kwargs)