crossbario / crossbario/autobahn-python
TypeError: Subscripted generics cannot be used with class and instance checks
Open
Nobody has claimed this yet.
bug
needs-investigation
wamp
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 768
- PR merge metrics
- No merged PRs in 30d
Description
Code:
@wamp.register('network.xbr.console.find_markets', check_types=True)
def find_markets(self,
created_from: Optional[int] = None,
limit: Optional[int] = None,
include_owners: Optional[List[bytes]] = None,
include_actors: Optional[List[bytes]] = None,
include_titles: Optional[List[str]] = None,
include_descriptions: Optional[List[str]] = None,
include_tags: Optional[List[str]] = None,
include_apis: Optional[List[bytes]] = None,
details: Optional[CallDetails] = None) -> List[bytes]:
pass
Traceback:
2020-02-29T22:27:08+0100 [Router 26746] XbrNetworkApi.onUserError(): "TypeError: Subscripted generics cannot be used with class and instance checks"
Traceback (most recent call last):
File "/home/oberstet/scm/crossbario/autobahn-python/autobahn/wamp/protocol.py", line 1020, in onMessage
on_reply = txaio.as_future(endpoint.fn, *invoke_args, **invoke_kwargs)
File "/home/oberstet/scm/crossbario/txaio/txaio/tx.py", line 365, in as_future
return ensureDeferred(fun(*args, **kwargs))
File "/home/oberstet/cpy381_5/lib/python3.8/site-packages/twisted/internet/defer.py", line 911, in ensureDeferred
return _cancellableInlineCallbacks(coro)
File "/home/oberstet/cpy381_5/lib/python3.8/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
_inlineCallbacks(None, g, status)
--- <exception caught here> ---
File "/home/oberstet/cpy381_5/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
result = g.send(result)
File "/home/oberstet/scm/crossbario/autobahn-python/autobahn/wamp/protocol.py", line 506, in _type_check
if not isinstance(arguments[name], kind.__args__):
File "/home/oberstet/cpy381/lib/python3.8/typing.py", line 766, in __instancecheck__
return self.__subclasscheck__(type(obj))
File "/home/oberstet/cpy381/lib/python3.8/typing.py", line 774, in __subclasscheck__
raise TypeError("Subscripted generics cannot be used with"
builtins.TypeError: Subscripted generics cannot be used with class and instance checks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in autobahn/wamp/protocol.py at the _type_check call shown near line 506, then reproduce it with the check_types=True endpoint and annotations in xbrnetwork/_api.py near line 1095. Trace how Optional and List annotations are checked. Done means the endpoint no longer raises the reported TypeError while type checking its arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100