Skip to content

typing.is_typeddict returns False for generic TypedDict specializations #149574

@semohr

Description

@semohr

Bug report

Bug description:

It appears that typing.is_typeddict returns False when called on a specialized TypedDict that is used as a type parameter in a generic TypedDict. This behavior is not documented and seems unexpected.

from typing import is_typeddict, Generic, TypeVar, TypedDict

A = TypeVar("A", bound=TypedDict)

class Attributes(TypedDict):
    title: str

class Resource(TypedDict, Generic[A]):
    a: A 

print(is_typeddict(Resource[Attributes]))
# False (unexpected)

is_typeddict(Resource[Attributes]) should return True, since Resource[...] is still a TypedDict after specialization.


I reported this initially in python/typing#2280 where it was suggested I open an issues here.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions