diff --git a/packages/pyright-internal/src/analyzer/typeUtils.ts b/packages/pyright-internal/src/analyzer/typeUtils.ts index 3a4ef3d6c924..2e1829c6f6dd 100644 --- a/packages/pyright-internal/src/analyzer/typeUtils.ts +++ b/packages/pyright-internal/src/analyzer/typeUtils.ts @@ -3006,9 +3006,9 @@ export function computeMroLinearization(classType: ClassType): boolean { // Generic has some special-case logic (see description of __mro_entries__ // in PEP 560) that we need to account for here. if (ClassType.isBuiltIn(baseClass, 'Generic')) { - // If the class is a Protocol, the generic is ignored for the purposes - // of computing the MRO. - if (ClassType.isProtocolClass(classType)) { + // If the class is a Protocol or TypedDict, the generic is ignored for + // the purposes of computing the MRO. + if (ClassType.isProtocolClass(classType) || ClassType.isTypedDictClass(classType)) { return false; } diff --git a/packages/pyright-internal/src/tests/samples/typedDict18.py b/packages/pyright-internal/src/tests/samples/typedDict18.py index 021170f20902..6cb48852eaa6 100644 --- a/packages/pyright-internal/src/tests/samples/typedDict18.py +++ b/packages/pyright-internal/src/tests/samples/typedDict18.py @@ -126,3 +126,15 @@ def __init__(self, **attrs: Unpack[TD9[_T1]]) -> None: f7 = ClassA(x=1) reveal_type(f7, expected_text="ClassA[int]") + + +class TD10(TypedDict, Generic[_T1]): + x: _T1 + + +class TD11(TypedDict): + y: int + + +class TD12(TD10[str], TD11): + ...