This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hongweipeng
Recipients docs@python, hongweipeng
Date 2020-11-11.07:59:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605081595.15.0.657429202369.issue42319@roundup.psfhosted.org>
In-reply-to
Content
https://docs.python.org/zh-cn/3.8/library/functools.html#functools.singledispatchmethod

as the code:
```
from functools import singledispatchmethod

class Negator:
    @singledispatchmethod
    @classmethod
    def neg(cls, arg):
        raise NotImplementedError("Cannot negate a")

    @neg.register
    @classmethod
    def _(cls, arg: int):
        return -arg

    @neg.register
    @classmethod
    def _(cls, arg: bool):
        return not arg

```

  File "/root/.pyenv/versions/3.8.5/lib/python3.8/functools.py", line 907, in register
    return self.dispatcher.register(cls, func=method)
  File "/root/.pyenv/versions/3.8.5/lib/python3.8/functools.py", line 849, in register
    raise TypeError(
TypeError: Invalid first argument to `register()`: <classmethod object at 0x7fa22c0495b0>. Use either `@register(some_class)` or plain `@register` on an annotated function.
History
Date User Action Args
2020-11-11 07:59:55hongweipengsetrecipients: + hongweipeng, docs@python
2020-11-11 07:59:55hongweipengsetmessageid: <1605081595.15.0.657429202369.issue42319@roundup.psfhosted.org>
2020-11-11 07:59:55hongweipenglinkissue42319 messages
2020-11-11 07:59:54hongweipengcreate