Skip to content

class My[X](object): raises TypeError: Cannot create a consistent method resolution order #107909

@sobolevn

Description

@sobolevn
>>> class My[X](object): ...
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <generic parameters of My>
TypeError: Cannot create a consistent method resolution
order (MRO) for bases object, Generic

It looks like a correct error:

>>> from typing import Generic
>>> from typing import TypeVar
>>> T = TypeVar('T')
>>> class A(object, Generic[T]): ...
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Cannot create a consistent method resolution
order (MRO) for bases object, Generic

>>> class A(Generic[T], object): ...
... 
>>> 

But it is not tested. I think that object is quite an important corner-case to test it explicitly.

class My[X](): is tested.

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions