Two argument form of `type()`

Since Python 3 made explicitly inheriting from object unnecessary, these two lines are equivalent

X = type('X', (object,), dict(a=1))`
X = type('X', (), dict(a=1))`

It’s surprising that you have to pass an empty tuple to type(). It wasn’t obvious what (object,), was before and now on Python 3 it’s less obvious.

One way to solve this would be a 3rd signature for type():

X = type('X', dict(a=1))

This is pretty ugly because it makes the 3 argument form surprising, since the third bases argument comes from the middle:

class type(object)
class type(name, dict)
class type(name, bases, dict)

instead of the more sensible

class type(object)
class type(name, dict[, bases])

but you can’t break backwards compatibility with all the code that uses the class type(name, bases, dict) form.

I disagree with your statements:

“It’s surprising that you have to pass an empty tuple to type(). It
wasn’t obvious what (object,), was before and now on Python 3 it’s
less obvious.”

Firstly, you don’t have to pass an empty tuple.

And secondly, of course it is obvious what (object,) is, if you know
what type does. It’s a tuple of superclasses.

The type class requires a tuple of superclasses (notice plural)
equivalent to what you would enter in a class statement:

class MyClass(Spam, Eggs, Cheese, Aardvark):
    pass

# Equivalent to:
MyClass = type("MyClass", (Spam, Eggs, Cheese, Aardvark), {})

Clearly it doesn’t have to be an empty tuple. And clearly you can leave
out object if you wish.

It would be surprising if you didn’t pass a tuple. How else can we
handle a positional argument in the middle of the parameter list? The
signature of range is very unusual, and we should have a really good
reason for emulating that in other functions.

So if you have no explicit bases, the natural way to pass that is with
an empty tuple. An empty tuple implies (object,), just as leaving out
the superclasses in the class statement does. So what’s the problem here
you are trying to solve?

type already has a complex signature. Let’s not make it even more
complex, and rather confusing, without a strong reason.