[issue39679] functools: singledispatchmethod doesn't work with classmethod

Dmitry Kulazhenko report at bugs.python.org
Wed Jun 16 03:50:42 EDT 2021


Dmitry Kulazhenko <dmkulazhenko at gmail.com> added the comment:

Based on what I've read, workaround:


from functools import singledispatchmethod


def _register(self, cls, method=None):
    if hasattr(cls, "__func__"):
        setattr(cls, "__annotations__", cls.__func__.__annotations__)
    return self.dispatcher.register(cls, func=method)


singledispatchmethod.register = _register

----------
nosy: +dmkulazhenko -EugenePY, FFY00, Viktor Roytman, glyph, levkivskyi, lukasz.langa, markgrandi, mental, ncoghlan, xtreak

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39679>
_______________________________________


More information about the Python-bugs-list mailing list