-
Notifications
You must be signed in to change notification settings - Fork 210
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
Use ChoiceKey
in TaggedUnionValidator
for int keys
#405
Conversation
Looking good, please put the issue being fixed in the pr body. |
CodSpeed Performance ReportMerging #405 Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good, please add tests for the new cases.
@samuelcolvin I realize this PR doesn't support Python |
it should support enums (please add a test) if they also inherit form Supporting more general enums is probably a bigger issue. |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #405 +/- ##
==========================================
- Coverage 95.33% 95.31% -0.02%
==========================================
Files 90 90
Lines 10536 10564 +28
Branches 8 8
==========================================
+ Hits 10044 10069 +25
- Misses 492 495 +3
Continue to review full report at Codecov.
|
@philhchen I have been working on integrating this on the I've got many discriminated-union tests now passing in the branch from the PR above (with a local install of this branch for However, I have noticed two weird issues that I'm hoping you (or @samuelcolvin) will see how to resolve faster than me. Here is the test that I have been working against: (I know the test needs modification for the final bit for the string cases, but it's not getting that far yet)
(Also, I needed to change the default value of |
I just realized that you had made that change, then undid it in favor of #398 😅; I just closed that PR, and pushed a commit to this PR updating the relevant file and fixing the test. |
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2bf1060
to
212af1f
Compare
Yeah I noticed this as well - I think it's a result of this line. I'll modify it instead of being lazy 😅 |
Ok I think int tags should now show up as ints in their representations as error messages |
I was able to reproduce this and traced down the error to a nuanced bug in these lines. The logic there is that if a literal can be downcast as a str, then it is treated as a @samuelcolvin do you have some thoughts on how to proceed? |
Would this be solved by using I'll look a bit later when I'm at a computer. |
How do you know if it |
I guess based on the runtime |
@dmontagu I don't have write access to the |
I've made a few tweaks. I think this is ready. @dmontagu @philhchen are you happy to merge this? |
Used for supporting Discriminated Unions for pydantic/pydantic#4675
As per pydantic/pydantic#4675 (comment), supporting int and string keys should use an Enum.