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

fix: state schema should accept generic dict types as typing.Dict and TypedDict - WF-115 #649

Conversation

FabienArcellier
Copy link
Collaborator

@FabienArcellier FabienArcellier commented Nov 24, 2024

A dictionary can be specified with different types, including generics. WF must support these generics and treat them like dictionaries.

fix #620


typing.Dict

class MyState(wf.WriterState):
    counter: int
    record: Dict[str, Any]

initial_state = wf.init_state({
    "counter": 0,
    "record": {}
}, schema=MyState)

typing.TypedDict

class SpecificDictTyped(typing.TypedDict):
    a: str
    b: str

class MyState(wf.WriterState):
    counter: int
    record: SpecificDictTyped

initial_state = wf.init_state({
    "counter": 0,
    "record": {}
}, schema=MyState)

image

@FabienArcellier FabienArcellier added the bug Something isn't working label Nov 24, 2024
@FabienArcellier FabienArcellier self-assigned this Nov 24, 2024
@FabienArcellier FabienArcellier changed the title feat: state schema should accept generic dict types as typing.Dict and TypedDict fix: state schema should accept generic dict types as typing.Dict and TypedDict Nov 24, 2024
@FabienArcellier FabienArcellier changed the title fix: state schema should accept generic dict types as typing.Dict and TypedDict fix: state schema should accept generic dict types as typing.Dict and TypedDict - WF-115 Nov 24, 2024
@FabienArcellier FabienArcellier marked this pull request as ready for review November 24, 2024 16:26
@ramedina86 ramedina86 merged commit 985e6cf into writer:dev Nov 29, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

state schema should accept generic dict types as typing.Dict and TypedDict
2 participants