Open pradeep90 opened 3 years ago
The error message in Python 3.10 with MonkeyType 22.2.0 has slightly changed, but stacktrace remains essentially in the same form
Failed collecting trace
Traceback (most recent call last):
File "/home/jdanek/.cache/pypoetry/virtualenvs/skupper-router-7_an9NB3-py3.10/lib/python3.10/site-packages/monkeytype/tracing.py", line 259, in __call__
self.handle_call(frame)
File "/home/jdanek/.cache/pypoetry/virtualenvs/skupper-router-7_an9NB3-py3.10/lib/python3.10/site-packages/monkeytype/tracing.py", line 225, in handle_call
arg_types[name] = get_type(frame.f_locals[name],
File "/home/jdanek/.cache/pypoetry/virtualenvs/skupper-router-7_an9NB3-py3.10/lib/python3.10/site-packages/monkeytype/typing.py", line 177, in get_type
return Type[obj]
File "/usr/lib64/python3.10/typing.py", line 311, in inner
return func(*args, **kwds)
File "/usr/lib64/python3.10/typing.py", line 1126, in __getitem__
params = tuple(_type_check(p, msg) for p in params)
File "/usr/lib64/python3.10/typing.py", line 1126, in <genexpr>
params = tuple(_type_check(p, msg) for p in params)
File "/usr/lib64/python3.10/typing.py", line 171, in _type_check
raise TypeError(f"Plain {arg} is not valid as type argument")
TypeError: Plain <class 'typing.Protocol'> is not valid as type argument
Type[foo]
raises aTypeError
whenfoo
isGeneric
ortyping._Protocol
. Here's a repro:It arises from the following lines in typing.py:
https://github.com/Instagram/MonkeyType/blob/master/monkeytype/typing.py#L174-L177
Our best bet is probably to catch the
TypeError
there and return a default type (probablyAny
).This isn't a fatal error right now because we just drop the trace.