Alex Waygood <alex.wayg...@gmail.com> added the comment:
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 ``` ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46032> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com