-
Notifications
You must be signed in to change notification settings - Fork 158
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
Fixing bug in decoder eval for optional fields #354
Conversation
@lidatong is there any concern with this change? |
@lidatong is there a timeline for merging into the package? |
@lidatong we have run into this issue as well, can we get this merged and a new release created? |
@lidatong Ran into this issue as well. Would love to know if its getting merged soon :) |
Whilst we are piling on - I would also love to see this merged, this causes very surprising results when a field is constructed incorrectly by passing None where None is not valid (you essentially just get a warning and then are provided with an invalid class back. |
Unfortunately it seems that this project is likely abandoned, we have been maintaining a separate fork for our own use-case but would love to see this repo get some love @lidatong or a new maintainer take up the reigns (which might need to be via a fork of this if the original author doesn't respond) |
hi, i'm really sorry for the long delay. it's been a combination of work stress and burnout, but that is no excuse for my procrastination. i do really appreciate PRs from the community and will try to review and merge the high-demand ones this weekend! i'm also open to granting write permissions to repeat contributors, to make this project more sustainable |
Is there an option for the latter? |
@lidatong Let us know if granting wire permissions are an option. It would be good to get a community to help you out with making updates to this really useful package |
sorry, i just fixed CI issues. definitely can grant write, though publishing is a final step i'll aim to not bottleneck -- it would be good to for to review all changes anyways before signing anything |
Also, please sync your branch to latest master commit. Then we can proceed with a merge |
Co-authored-by: Matthias Als <matt035343@gmail.com>
@matt035343 I have rebased and fixed formatting errors |
No stress, there are extra hands on deck now :) please let me or @s-vitaliy or @matt035343 know if there are other PRs you want reviewed asap |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [dataclasses-json](https://togithub.com/lidatong/dataclasses-json) | `0.5.8` -> `0.5.12` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>lidatong/dataclasses-json (dataclasses-json)</summary> ### [`v0.5.12`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.5.12) [Compare Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.5.9...v0.5.12) ##### What's Changed - Fix multiline scripts in CI by [@​george-zubrienko](https://togithub.com/george-zubrienko) in [https://github.com/lidatong/dataclasses-json/pull/439](https://togithub.com/lidatong/dataclasses-json/pull/439) **Full Changelog**: lidatong/dataclasses-json@v0.5.11...v0.5.12 ### [`v0.5.9`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.5.9) [Compare Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.5.8...v0.5.9) #### What's Changed - feat: add formalized issue template by [@​s-vitaliy](https://togithub.com/s-vitaliy) in [https://github.com/lidatong/dataclasses-json/pull/417](https://togithub.com/lidatong/dataclasses-json/pull/417) - Fixing bug in decoder eval for optional fields by [@​rpmcginty](https://togithub.com/rpmcginty) in [https://github.com/lidatong/dataclasses-json/pull/354](https://togithub.com/lidatong/dataclasses-json/pull/354) - Fix type order relevance for union wrapping 2 types by [@​george-zubrienko](https://togithub.com/george-zubrienko) in [https://github.com/lidatong/dataclasses-json/pull/419](https://togithub.com/lidatong/dataclasses-json/pull/419) - Fix autocomplete when using annotation by [@​george-zubrienko](https://togithub.com/george-zubrienko) in [https://github.com/lidatong/dataclasses-json/pull/411](https://togithub.com/lidatong/dataclasses-json/pull/411) - Add support for enhanced builtin instantiation by [@​rpmcginty](https://togithub.com/rpmcginty) in [https://github.com/lidatong/dataclasses-json/pull/375](https://togithub.com/lidatong/dataclasses-json/pull/375) - Restore `schema()` type safety by fixing generic type alias misuse by [@​andersk](https://togithub.com/andersk) in [https://github.com/lidatong/dataclasses-json/pull/371](https://togithub.com/lidatong/dataclasses-json/pull/371) #### New Contributors - [@​s-vitaliy](https://togithub.com/s-vitaliy) made their first contribution in [https://github.com/lidatong/dataclasses-json/pull/417](https://togithub.com/lidatong/dataclasses-json/pull/417) - [@​george-zubrienko](https://togithub.com/george-zubrienko) made their first contribution in [https://github.com/lidatong/dataclasses-json/pull/419](https://togithub.com/lidatong/dataclasses-json/pull/419) - [@​andersk](https://togithub.com/andersk) made their first contribution in [https://github.com/lidatong/dataclasses-json/pull/371](https://togithub.com/lidatong/dataclasses-json/pull/371) **Full Changelog**: lidatong/dataclasses-json@v0.5.8...v0.5.9 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, 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://developer.mend.io/github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNDQuMiIsInVwZGF0ZWRJblZlciI6IjM2LjguMTEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=--> Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Issue: #353
Problem
There is inconsistent behavior in how a custom decoder is used depending on whether the field of the custom decoder has
Optional
type.For optional fields which can be None, you are supposed to use the
Optional[...]
type. However, when doing so, it seems that custom decoders are always evaluated.It should be noted that fields where the default value is None but no
Optional[...]
typing is present, a custom decoder will only be used if a non-None value is provided.Solution
Modified decoder function s.t. when field value is None, both cases where field type is not optional (existing logic) as well as where field type is optional are handled.