dataclasses-json icon indicating copy to clipboard operation
dataclasses-json copied to clipboard

Fixing bug in decoder eval for optional fields

Open rpmcginty opened this issue 2 years ago • 2 comments

Issue: https://github.com/lidatong/dataclasses-json/issues/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.

rpmcginty avatar Apr 19 '22 23:04 rpmcginty

@lidatong is there any concern with this change?

rpmcginty avatar Jul 22 '22 21:07 rpmcginty

@lidatong is there a timeline for merging into the package?

rpmcginty avatar Sep 26 '22 23:09 rpmcginty

@lidatong we have run into this issue as well, can we get this merged and a new release created?

TristanSpeakEasy avatar Nov 09 '22 09:11 TristanSpeakEasy

@lidatong Ran into this issue as well. Would love to know if its getting merged soon :)

simplesagar avatar Nov 10 '22 21:11 simplesagar

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.

patricksnape avatar Jan 13 '23 12:01 patricksnape

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)

TristanSpeakEasy avatar Jan 13 '23 12:01 TristanSpeakEasy

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

lidatong avatar Jan 14 '23 13:01 lidatong

Is there an option for the latter?

rpmcginty avatar Mar 03 '23 12:03 rpmcginty

@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

rpmcginty avatar Mar 18 '23 05:03 rpmcginty

@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

lidatong avatar Mar 18 '23 13:03 lidatong

Also, please sync your branch to latest master commit. Then we can proceed with a merge

matt035343 avatar Jun 10 '23 18:06 matt035343

@matt035343 I have rebased and fixed formatting errors

rpmcginty avatar Jun 12 '23 20:06 rpmcginty

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)

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

george-zubrienko avatar Jun 13 '23 17:06 george-zubrienko