Skip to content

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

Closed
@Lancetnik

Description

@Lancetnik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions