-
-
Notifications
You must be signed in to change notification settings - Fork 543
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
Clean up StrawberryField and StrawberryArgument interface #916
Conversation
Thanks for adding the Here's a preview of the changelog:
|
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## main #916 +/- ##
=======================================
Coverage 97.41% 97.41%
=======================================
Files 76 76
Lines 2592 2592
Branches 362 362
=======================================
Hits 2525 2525
Misses 41 41
Partials 26 26 |
def __bool__(self): | ||
return False |
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.
Advantage of adding truthiness?
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.
I just moved this class around. Not sure what the point of this is. @patrick91 do you know?
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.
it's to make sure you can use it in if
statements:
def something(a: int = UNSET):
if a:
return
...
(note this check is silly but it's to demonstrate the idea :) )
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.
That seems like it could lead to bugs. What if a
is 0
?
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.
sorry I missed this comment! that's a good point 😊
but then that means you always need to check if it is unset before doing anything with it, right? I guess that's similar to using None, so I think we can remove it :)
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.
BTW UNSET will be changing significantly with this change anyway: #872
c0bcf7c
to
eef3359
Compare
@patrick91 @BryceBeagle I've added some release notes. I think this is good to go now. |
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.
Looks good to me! There's a couple of comments, but we can merge the PR and deal with them later if you prefer @jkimbo 😊
def __bool__(self): | ||
return False |
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.
sorry I missed this comment! that's a good point 😊
but then that means you always need to check if it is unset before doing anything with it, right? I guess that's similar to using None, so I think we can remove it :)
Description
default_value
todefault
in StrawberryFielddefault_value
todefault
in StrawberryArgumentundefined
in favour ofUNSET
(note: I haven't actually removedundefined
but I think we can do that now)These changes are pretty minor but they are the ground work for allowing custom fields. I was just going to do all the changes necessary but #906 changes some of the code I was going to touch so I'll write up my proposal for it first before doing the code changes.
Types of Changes
Issues Fixed or Closed by This PR
Checklist