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 issue where generic models couldn't be parametrized with BaseModel #6933

Merged
merged 1 commit into from Jul 28, 2023

Conversation

dmontagu
Copy link
Contributor

@dmontagu dmontagu commented Jul 28, 2023

Closes #6931

The issue is that the BaseModel class, specifically, is lying about some of its attribute annotations and doesn't have certain attributes that every subclass would have (namely, __pydantic_generic_metadata__). Fortunately, the affected functions are currently only used in ways where they shouldn't do anything interesting for BaseModel, so I just modified them to not return True for BaseModel itself, and it seems everything "just works" with that change.

@dmontagu
Copy link
Contributor Author

please review

@cloudflare-pages
Copy link

cloudflare-pages bot commented Jul 28, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7ea383f
Status: ✅  Deploy successful!
Preview URL: https://1cec1c2e.pydantic-docs2.pages.dev
Branch Preview URL: https://fix-generic-parametrized-wit.pydantic-docs2.pages.dev

View logs

@dmontagu dmontagu enabled auto-merge (squash) July 28, 2023 15:34
@dmontagu dmontagu disabled auto-merge July 28, 2023 15:34
@dmontagu dmontagu enabled auto-merge (squash) July 28, 2023 15:35
@dmontagu dmontagu merged commit bb43605 into main Jul 28, 2023
47 checks passed
@dmontagu dmontagu deleted the fix-generic-parametrized-with-basemodel branch July 28, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic Models cannot be typed with BaseModel subclasses
2 participants