Menu

#916 Metaclass not recognized if deriving indirectly from type

open
nobody
None
5
2009-05-12
2009-05-12
No

In this:

class DirectMeta(type):
def __init__(cls, classname, bases, dict_):
pass

class IndirectMeta(DirectMeta):
def __init__(cls, classname, bases, dict_):
pass

the first class is correctly recognized as a metaclass, pydev does not complain about the cls parameter instead of self.

But the second class gets an error flagged on __init__, saying it "should have self as first parameter". This is wrong, the first parameter should be cls because the class derives from type, albeit indirectly.

(I thought I reported this earlier, but I can't find it — if this is a dupe, then sorry!)

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.