Type object '<cls>' has no attribute '__parameters__'

Alright I found the bug.

Old code (simplified):

class Base:
    def __init_subclass__(cls) -> None:
        pass

class Sub[T](Base): pass

class SubSub(Sub[object]): pass

New code:

class Base:
    def __init_subclass__(cls) -> None:
        super().__init_subclass__()

class Sub[T](Base): pass

class SubSub(Sub[object]): pass

In a nutshell, I forgot to call super().__init_subclass__. I didn’t really expect that to be an issue because I thought it was just a simple hook you can use optionally, but apparently not.

1 Like