-
Notifications
You must be signed in to change notification settings - Fork 247
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
Make better union validation decisions based on extra
behavior
#1335
Comments
It seems to me like the solution here would be to have another counter |
Indeed. Honestly a good first issue for someone looking to start in |
@erohmensing you might be interested in this! |
Thanks for the tag @sydney-runkle! This makes sense, would be happy to take a look. @davidhewitt is there any reason why you'd think of a counter over a bool for |
I think a Also, consider: from pydantic import BaseModel, TypeAdapter
class ModelA(BaseModel):
a: int
b: int
class ModelB(ModelA, extra='allow'):
pass
print(repr(TypeAdapter(ModelA | ModelB).validate_python({'a': 1, 'b': 1, 'x': 1})))
#> ModelA(a=1, b=1) This is the current behavior - I think the desired behavior would be |
I agree!
do you mean in the case of like
should be Model A? If so, agreed - that seems to be the case and I think it would make sense for it to stay like that |
@erohmensing, are you still interested in contributing here? |
For example:
Is the current behavior, but that doesn't seem like the best decision.
See #1332 and #1334 for recent context on union validation decision improvements.
The text was updated successfully, but these errors were encountered: