classification
Title: abstractmethod can run on classes
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Michael Hooreman, nikvanderhoof
Priority: normal Keywords:

Created on 2018-08-05 16:29 by Michael Hooreman, last changed 2018-08-08 00:32 by nikvanderhoof.

Messages (3)
msg323157 - (view) Author: Michael Hooreman (Michael Hooreman) Date: 2018-08-05 16:29
Hello,

When I decorate a class method with abc.abstractmethod, and I call it from the class (not the instance), the call is successful.

It looks like ID 5867 which was closed years ago.

See https://stackoverflow.com/questions/51669362/python-3-6-abc-abstracmethod-on-classmethod-no-check-on-class-level-call

Thanks!
msg323255 - (view) Author: Nikolas Vanderhoof (nikvanderhoof) Date: 2018-08-08 00:29
This behavior is consistent with the behavior described in the documentation for `@classmethod`.

https://docs.python.org/3.6/library/functions.html?highlight=classmethod#classmethod

"It can be called either on the class (such as C.f()) or on an instance (such as C().f())."

In this case, it can't be called on an instance because it is abstract, but since it's a classmethod, it is still okay to call it on the class directly.
msg323256 - (view) Author: Nikolas Vanderhoof (nikvanderhoof) Date: 2018-08-08 00:32
I've also posted that response on stackoverflow to your question in case others have the same confusion.
History
Date User Action Args
2018-08-08 00:32:28nikvanderhoofsetmessages: + msg323256
2018-08-08 00:29:59nikvanderhoofsetnosy: + nikvanderhoof
messages: + msg323255
2018-08-05 16:29:46Michael Hooremancreate