-
-
Notifications
You must be signed in to change notification settings - Fork 29.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class My[X](object):
raises TypeError: Cannot create a consistent method resolution order
#107909
Comments
Hi! I am to try to follow along, but I am not able to get the same error from the first example you give:
gives me
the second example works for me though:
Am I doing something wrong? How to fix to reproduce the same error as you? P.S. how to make code formatting look like your examples? I use the "Add code" button but my code looks different from yours in the preview. |
Okay, I run again after great suggestion from JelleZijlstra in other conversation. I can now reproduce: >>> 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
>>> 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): ...
... For anyone also stuck with same problem as me above, try to do #107905 (comment) |
@brandonardenwalli, please use triple backticks to format multiline code blocks in GitHub issues, i.e.:
|
pythonGH-108001) (cherry picked from commit b61f599) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
It looks like a correct error:
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
object
base in PEP695 generic classes #108001object
base in PEP695 generic classes (GH-108001) #108022The text was updated successfully, but these errors were encountered: