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
Fixes discriminated unions not working on aliased literal fields. Issue #3849. #5736
Merged
dmontagu
merged 2 commits into
pydantic:1.10.X-fixes
from
benwah:fix_discriminated_union_issue_3849
May 12, 2023
Merged
Fixes discriminated unions not working on aliased literal fields. Issue #3849. #5736
dmontagu
merged 2 commits into
pydantic:1.10.X-fixes
from
benwah:fix_discriminated_union_issue_3849
May 12, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benwah
force-pushed
the
fix_discriminated_union_issue_3849
branch
from
May 10, 2023 16:00
ebc5266
to
a797d73
Compare
please review |
benwah
force-pushed
the
fix_discriminated_union_issue_3849
branch
3 times, most recently
from
May 10, 2023 16:14
1d26e81
to
fcf0bdf
Compare
benwah
force-pushed
the
fix_discriminated_union_issue_3849
branch
from
May 10, 2023 16:29
fcf0bdf
to
6173cfa
Compare
dmontagu
reviewed
May 10, 2023
benwah
force-pushed
the
fix_discriminated_union_issue_3849
branch
from
May 10, 2023 23:49
6173cfa
to
1402ac0
Compare
benwah
force-pushed
the
fix_discriminated_union_issue_3849
branch
from
May 10, 2023 23:55
1402ac0
to
4d2a64c
Compare
…efore checking discriminator_key
renovate bot
added a commit
to allenporter/flux-local
that referenced
this pull request
May 25, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [pydantic](https://togithub.com/pydantic/pydantic) | `==1.10.7` -> `==1.10.8` | [![age](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/compatibility-slim/1.10.7)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/confidence-slim/1.10.7)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>pydantic/pydantic</summary> ### [`v1.10.8`](https://togithub.com/pydantic/pydantic/releases/tag/v1.10.8): 2023-05-23 [Compare Source](https://togithub.com/pydantic/pydantic/compare/v1.10.7...v1.10.8) #### What's Changed - Fix a bug in `Literal` usage with `typing-extension==4.6.0`, [#​5826](https://togithub.com/pydantic/pydantic/issues/5826) by [@​hramezani](https://togithub.com/hramezani) - This solves the (closed) issue [#​3849](https://togithub.com/pydantic/pydantic/issues/3849) where aliased fields that use discriminated union fail to validate when the data contains the non-aliased field name, [#​5736](https://togithub.com/pydantic/pydantic/issues/5736) by [@​benwah](https://togithub.com/benwah) - Update email-validator dependency to >=2.0.0post2, [#​5627](https://togithub.com/pydantic/pydantic/issues/5627) by [@​adriangb](https://togithub.com/adriangb) - update `AnyClassMethod` for changes in [python/typeshed#​9771](https://togithub.com/python/typeshed/issues/9771), [#​5505](https://togithub.com/pydantic/pydantic/issues/5505) by [@​ITProKyle](https://togithub.com/ITProKyle) #### New Contributors - [@​DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos) made their first contribution in [pydantic/pydantic#5375 - [@​ITProKyle](https://togithub.com/ITProKyle) made their first contribution in [pydantic/pydantic#5505 - [@​benwah](https://togithub.com/benwah) made their first contribution in [pydantic/pydantic#5736 **Full Changelog**: pydantic/pydantic@v1.10.7...v1.10.8 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS45OC40IiwidXBkYXRlZEluVmVyIjoiMzUuOTguNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot
added a commit
to allenporter/pyrainbird
that referenced
this pull request
May 25, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [pydantic](https://togithub.com/pydantic/pydantic) | `==1.10.7` -> `==1.10.8` | [![age](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/compatibility-slim/1.10.7)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/pydantic/1.10.8/confidence-slim/1.10.7)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>pydantic/pydantic</summary> ### [`v1.10.8`](https://togithub.com/pydantic/pydantic/releases/tag/v1.10.8): 2023-05-23 [Compare Source](https://togithub.com/pydantic/pydantic/compare/v1.10.7...v1.10.8) ##### What's Changed - Fix a bug in `Literal` usage with `typing-extension==4.6.0`, [#​5826](https://togithub.com/pydantic/pydantic/issues/5826) by [@​hramezani](https://togithub.com/hramezani) - This solves the (closed) issue [#​3849](https://togithub.com/pydantic/pydantic/issues/3849) where aliased fields that use discriminated union fail to validate when the data contains the non-aliased field name, [#​5736](https://togithub.com/pydantic/pydantic/issues/5736) by [@​benwah](https://togithub.com/benwah) - Update email-validator dependency to >=2.0.0post2, [#​5627](https://togithub.com/pydantic/pydantic/issues/5627) by [@​adriangb](https://togithub.com/adriangb) - update `AnyClassMethod` for changes in [python/typeshed#​9771](https://togithub.com/python/typeshed/issues/9771), [#​5505](https://togithub.com/pydantic/pydantic/issues/5505) by [@​ITProKyle](https://togithub.com/ITProKyle) ##### New Contributors - [@​DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos) made their first contribution in [pydantic/pydantic#5375 - [@​ITProKyle](https://togithub.com/ITProKyle) made their first contribution in [pydantic/pydantic#5505 - [@​benwah](https://togithub.com/benwah) made their first contribution in [pydantic/pydantic#5736 **Full Changelog**: pydantic/pydantic@v1.10.7...v1.10.8 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/pyrainbird). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS45OC40IiwidXBkYXRlZEluVmVyIjoiMzUuOTguNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change Summary
The issue is described here: #3849
TL;DR:
When you have an aliased field, and it uses a discriminated union; you can no longer use the un-aliased field name to instantiate the model.
According to the discussion, this is not going to be a problem once Pydantic 2.x releases, but it's definitly problematic for 1.10.x which I'm currently using.
Here's the test failure without this change:
Related issue number
Fix #3849
Checklist
changes/<pull request or issue id>-<github username>.md
file added describing change(see changes/README.md for details)
Selected Reviewer: @PrettyWood