"Did you mean" for the metaclass keyword in class definition

For those whose first language is not English (e.g. me), they may easily mistype the word ‘metaclass’ :frowning:

The current error message:

>>> class Foo(mitaclass=type):
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Foo.__init_subclass__() takes no keyword arguments

I think it is better to have a clearer error message, something like:

TypeError: Foo.__init_subclass__() takes no keyword arguments. Did you mean 'metaclass'?

2 Likes

It might be possible, but that message is generic; the C code handling it is just checking what parameters are expected and what were provided and it isn’t specific to metaclasses.

2 Likes