class Works(type):
def __new__(cls, *args, **kwargs):
print([cls,args]) # outputs [, ()]
return super().__new__(c
The zero-argument form of super
requires that the method containing it have an explicit (i.e., non-varargs) first argument. This is suggested by an older version of the docs (emphasis added):
The zero argument form automatically searches the stack frame for the class (
__class__
) and the first argument.
For some reason this note was removed in later versions of the docs. (It might be worth raising a doc bug, because the docs are quite vague about how zero-argument super
works and what is required for it to work.)
See also this Python bug report (which is unresolved, and not clearly accepted as even a bug). The upshot is that zero-argument super
is magic, and that magic fails in some cases. As suggested in the bug report, if you want to accept only varargs, you'll need to use the explicit two-argument form of super
.