Skip to content

Nested Type should work with TypedDict #583

@datvo06

Description

@datvo06

Currently, we would expect nested_type to return a typeddict type annotation on a TypedDict instance.

from typing import TypedDict
from effectful.internals.unification import nested_type

class UserTD(TypedDict):
    name: str
    age: int

print("nested_type(UserTD(name='a', age=1)).value ->", nested_type(UserTD(name='a', age=1)).value)

Result:

nested_type(UserTD(name='a', age=1)).value -> <class 'dict'>

One difficulty is that the TypedDict instance at runtime is just a dict. Inferring types is possible, but we might not be able to recover the schema fully.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions