Skip to content
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

Multiple inheritance with Generic leads to [misc] error #18268

Open
Lancetnik opened this issue Dec 8, 2024 · 3 comments · May be fixed by #18270
Open

Multiple inheritance with Generic leads to [misc] error #18268

Lancetnik opened this issue Dec 8, 2024 · 3 comments · May be fixed by #18270
Labels
bug mypy got something wrong

Comments

@Lancetnik
Copy link

Bug Report

If we creates multiple generic parents with the same generic attribute, mypy raises an error about incompatible definition

To Reproduce

from typing import Generic, TypeVar

T = TypeVar("T")

class A(Generic[T]):
    x: T

class B(Generic[T]):
    x: T

class C(A[str], B[str]):
    pass

Raises error: Definition of "x" in base class "A" is incompatible with definition in base class "B" [misc]

Expected Behavior

The example should has no error, like in the final types case

class A:
    x: str

class B:
    x: str

class C(A, B):
    pass

Actual Behavior

Raises an error

Your Environment

mypy==1.14.0

@Lancetnik Lancetnik added the bug mypy got something wrong label Dec 8, 2024
@Lancetnik
Copy link
Author

I would like to solve the problem if smbd can lead me to the right direction

@Lancetnik
Copy link
Author

Well, the problem is in is_equivalent function result
It validates two TypeVarTypes, that contains TypeVarId differs by namespace. They has A and B classes values, but seems like the correct one is C or str

@Lancetnik
Copy link
Author

Seems like it is related to #18189 and #14774 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant