Skip to content
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

Isra/optional default #269

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

isra17
Copy link
Collaborator

@isra17 isra17 commented Apr 27, 2023

I was investigating why Optional default was broken (ie. x: Optional[int] = 1 would default to None) and ended up refactoring a good bunch of the code, finding out that defaults seemed to be overall quite broken.

field.load_default = None
field.allow_none = True
metadata[_DESERT_SENTINEL]["allow_none"] = True
if default is marshmallow.missing:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that this behavior is quite counter intuitive, but if we want to keep backward compatibility this is needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want an optional value, then do the same as all python code and do x: Optional[int] = None

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #269 (3e9b593) into main (0c43ff5) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #269   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          472       476    +4     
  Branches        90        93    +3     
=========================================
+ Hits           472       476    +4     
Impacted Files Coverage Δ
src/desert/_make.py 100.00% <100.00%> (ø)
tests/test_make.py 100.00% <100.00%> (ø)

@desert-bot
Copy link
Collaborator

FYI I don't personally have time to work on this repo these days. Other collaborators should be able to review if they're interested, so you might ping someone to see if there's interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants