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

Add generics support for v2 (another attempt) #5125

Merged
merged 52 commits into from
Mar 9, 2023
Merged

Add generics support for v2 (another attempt) #5125

merged 52 commits into from
Mar 9, 2023

Conversation

dmontagu
Copy link
Contributor

@dmontagu dmontagu commented Mar 1, 2023

Note: this requires an updated version of pydantic_core, but is currently passing all tests against pydantic_core's main branch.

There is still one major failing test I haven't resolved yet, which is getting it to work properly with "deep" recursive generic models. Figuring that out is my goal for tomorrow, but I wanted to open this now for the purposes of review.

@samuelcolvin you mentioned that the dataclasses stuff might blow this up, I'll be happy to merge it all together when that's ready.

fix #5146

@dmontagu dmontagu marked this pull request as ready for review March 2, 2023 15:45
tests/test_generics.py Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

A few comments but on the whole I think we should merge this asap.

I still believe that generic_recursion_self_type and friends could be simplified if we adopt something like #5149. However:

  1. I don't pretend to know enough to be sure
  2. If those simplifications aren't possible, it's fine
  3. this shouldn't block merging

@dmontagu
Copy link
Contributor Author

dmontagu commented Mar 9, 2023

I still believe that generic_recursion_self_type and friends could be simplified if we adopt something like #5149. However:

I agree it's hard to reason about, so I also don't pretend to be confident, but I think the main thing that has the potential to simplify the complex recursion stuff would be if the BaseModel's validator was a ModelValidator rather than TypedDictValidator, as we discussed. I think most of the weird have-to-go-deeper stuff comes from the fact that at the top level of the schema, you don't have a model_schema you can refer to. when building the inner typed_dict_schema.

At any rate, agree with all the above feedback, I'll make the changes and merge once they are complete.

@dmontagu dmontagu merged commit 53fcbec into main Mar 9, 2023
@dmontagu dmontagu deleted the v2-generics-v4 branch March 9, 2023 17:06
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.

add memray tests
3 participants