Skip to content

Conversation

@willowrimlinger
Copy link
Contributor

🛠 Changes being made

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

  • Support dict annotations with type arguments (e.g. dict[str, int])
  • Support new Union operator (e.g. int | str)
  • To accomplish the above two goals, I rewrote the generic parsing method to no longer use string-based checking as it was limited.

🧠 Rationale behind the change

Why did you choose to make these changes?

Before, you were forced to use the dict annotation with no type arguments and your only method of validation was through json schema. This doesn't play nice with strict type checking. Now, you can properly type your dict parameters for use in the view function.

Does this pull request resolve any open issues?

No

Were there any trade-offs you had to consider?

I removed the logic to simplify the type name for primatives in the ValidationError message. It could be adapted to support dictionaries and fixed to properly support lists, but I thought string-comparisons like this seemed hacky and prone to error, especially when adding support for new types.

🧪 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

willowrimlinger and others added 9 commits November 19, 2025 14:03
I thought the previous solution of comparing the string version of the
type was not flexible enough. Instead, I treat every input that we got
multiple values for as a list. If we got a single value input and it
should've been considered a list with one element, handle that case
during generic parsing.
Currently, the startswith() check for list doesn't work because
str(list) == "<class 'list'>". This logic also is currently not set up
for dicts. I think that just returning the stringified version of the
entire type is still clear to the user.
Add tests for typeddicts

Remove typeddict stuff
@willowrimlinger willowrimlinger mentioned this pull request Nov 19, 2025
4 tasks
Copy link
Collaborator

@smt5541 smt5541 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning up the generic parsing and making it use proper typing! This looks great!

@smt5541 smt5541 self-assigned this Nov 19, 2025
@smt5541 smt5541 merged commit c50b46a into Ge0rg3:master Nov 19, 2025
5 checks passed
@smt5541 smt5541 assigned willowrimlinger and unassigned smt5541 Nov 19, 2025
@Ge0rg3
Copy link
Owner

Ge0rg3 commented Nov 21, 2025

Many thanks both! 🏆

@willowrimlinger willowrimlinger deleted the willowrimlinger/switch-off-string-based-generic-parsing 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.

3 participants