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

Error more eagerly for proper subclasses of generics that we don't know how to validate #5629

Merged
merged 1 commit into from May 1, 2023

Conversation

dmontagu
Copy link
Contributor

@dmontagu dmontagu commented Apr 28, 2023

Closes #2264. (As it fixes some confusing behavior.)

We should go further and make similar changes for other subclasses of generics which don't have a "standard" way to call __init__.

Users who want to support such classes should implement a __get_pydantic_core_schema__ classmethod on the type in question, or if they don't control the type, on a pydantic-specific annotation used whenever that type occurs as a pydantic field annotation.

An example of how to do this is included in tests.test_edge_cases.test_custom_generic_validators

Selected Reviewer: @samuelcolvin

@dmontagu
Copy link
Contributor Author

dmontagu commented May 1, 2023

please review (also @adriangb for context, I'm not sure if you did something different/more general than this)

@dmontagu dmontagu merged commit 0346ddb into main May 1, 2023
40 checks passed
@dmontagu dmontagu deleted the disallow-sequence-subclasses branch May 1, 2023 23:33
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.

Support for string fields that inherit from Generic
3 participants