Skip to content

Conversation

@willowrimlinger
Copy link
Contributor

NOTE: Depends on #64

🛠 Changes being made

Give examples of the changes you've made in this pull request. Include an itemized list if you can.

Validate against type annotations with TypedDicts

🧠 Rationale behind the change

Why did you choose to make these changes?

Currently, if you want to validate the specific keys in a dictionary, you'd have to use a json schema. In many cases, that's overkill. It'd be nice to use TypedDicts because they are concise and allow for even stricter type checking within the view method.

Does this pull request resolve any open issues?

No

Were there any trade-offs you had to consider?

  • This doesn't support recursive TypedDicts as they have to be defined with forward reference strings which would be hard to interpret
  • The error message given when the user fails validation is opaque with TypedDicts. It just shows the name of the TypedDict and does not let the user know what keys or subtypes are needed. I thought about displaying this information in the format of jsonschema, but I felt jsonschema-esque error messages were too verbose for simple cases where TypedDicts are not involved. In the long run, I think the ideal solution is to have the auto-generated API documentation give users an easy reference for things like TypedDicts so I've decided to kick the can down the road.

🧪 Testing

  • Have tests been added or updated for the changes introduced in this pull request?

  • Are the changes backwards compatible?

If the changes aren't backwards compatible, what other options were explored?

✨ Quality check

  • Are your changes free of any erroneous print statements, debuggers or other leftover code?

  • Has the README been updated to reflect the changes introduced (if applicable)?

💬 Additional comments

Depends on #64.

@willowrimlinger willowrimlinger changed the title Willowrimlinger/typeddict support Add TypedDict Support Nov 20, 2025
@willowrimlinger willowrimlinger force-pushed the willowrimlinger/typeddict-support branch from 74e4615 to f3f6cc7 Compare November 20, 2025 15:45
@smt5541 smt5541 self-requested a review November 20, 2025 16:01
@smt5541 smt5541 merged commit 4080bdd into Ge0rg3:master Nov 20, 2025
5 checks passed
@willowrimlinger willowrimlinger deleted the willowrimlinger/typeddict-support branch November 21, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants