Issue 17352: Be clear that prepare must be declared as a class method (original) (raw)

Created on 2013-03-04 15:11 by ncoghlan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg183463 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013-03-04 15:11
The docs on __prepare__ don't make it clear that it should be a staticmethod, and the error message if you forget is not obvious at all. (This is particularly so, since the examples in PEP 3115 had it as an ordinary method).
msg183466 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013-03-04 15:28
Class method, not static method (super() breaks if you declare it as a static method)
msg237095 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2015-03-03 00:10
Should __prepare__ be special-cased as a classmethod, like __new__ is? Is there any reason to ever have __prepare__ /not/ be a classmethod?
msg237127 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2015-03-03 12:36
__new__ is a little weird - it's actually special cased as a staticmethod. Your questions is still valid, though. For existing versions, documenting the requirement is the only option. For future versions, we could conceivably implement a "decorate it if it isn't already decorated" fallback, but for backwards compatibility we'd have to avoid double-decorating explicitly decorated implementations.
msg267032 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-03 04:21
This is a duplicate of issue 15243.
History
Date User Action Args
2022-04-11 14:57:42 admin set github: 61554
2016-06-03 04:21:51 berker.peksag set status: open -> closedsuperseder: Misleading documentation for __prepare__nosy: + berker.peksagmessages: + resolution: duplicatestage: resolved
2015-07-21 07:27:01 ethan.furman set nosy: - ethan.furman
2015-03-03 12:36:22 ncoghlan set messages: +
2015-03-03 00:10:20 ethan.furman set messages: +
2014-05-19 01:29:23 ethan.furman set nosy: + ethan.furman
2013-10-13 20:16:56 georg.brandl set assignee: docs@pythoncomponents: + Documentationnosy: + docs@python
2013-03-04 15:28:05 ncoghlan set messages: + title: Be clear that __prepare__ must be declared as a static method -> Be clear that __prepare__ must be declared as a class method
2013-03-04 15:11:32 ncoghlan create