Message408204
It would be well worth it to improve the error message, however:
```
>>> from functools import singledispatch
>>> @singledispatch
... def func(arg):
... raise NotImplementedError
...
>>> @func.register
... def _(arg: list[str]):
... print('Got a list of strings')
...
>>> func(1)
Traceback (most recent call last):
File "/usr/local/lib/python3.9/functools.py", line 830, in dispatch
impl = dispatch_cache[cls]
File "/usr/local/lib/python3.9/weakref.py", line 405, in __getitem__
return self.data[ref(key)]
KeyError: <weakref at 0x7f2a0d9141d0; to 'type' at 0x7f2a0e08b200 (int)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/functools.py", line 833, in dispatch
impl = registry[cls]
KeyError: <class 'int'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/functools.py", line 877, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
return dispatch(args[0].__class__)(*args, **kw)
File "/usr/local/lib/python3.9/functools.py", line 835, in dispatch
impl = _find_impl(cls, registry)
File "/usr/local/lib/python3.9/functools.py", line 782, in _find_impl
mro = _compose_mro(cls, registry.keys())
File "/usr/local/lib/python3.9/functools.py", line 743, in _compose_mro
types = [n for n in types if is_related(n)]
File "/usr/local/lib/python3.9/functools.py", line 743, in <listcomp>
types = [n for n in types if is_related(n)]
File "/usr/local/lib/python3.9/functools.py", line 742, in is_related
and issubclass(cls, typ))
TypeError: issubclass() argument 2 cannot be a parameterized generic
``` |
|
Date |
User |
Action |
Args |
2021-12-10 12:58:17 | AlexWaygood | set | recipients:
+ AlexWaygood, rhettinger, lukasz.langa, kumaraditya |
2021-12-10 12:58:17 | AlexWaygood | set | messageid: <1639141097.7.0.713117836142.issue46032@roundup.psfhosted.org> |
2021-12-10 12:58:17 | AlexWaygood | link | issue46032 messages |
2021-12-10 12:58:17 | AlexWaygood | create | |
|