-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Add is_auto utility #1721
Add is_auto utility #1721
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1721 +/- ##
==========================================
- Coverage 98.13% 98.10% -0.04%
==========================================
Files 139 139
Lines 5214 5234 +20
Branches 947 954 +7
==========================================
+ Hits 5117 5135 +18
Misses 53 53
- Partials 44 46 +2 |
Thanks for adding the Here's a preview of the changelog: Add Here's the preview release card for twitter: Here's the tweet text:
|
strawberry/auto.py
Outdated
@@ -21,3 +25,25 @@ def __repr__(self): | |||
|
|||
|
|||
auto: Final = Annotated[Any, StrawberryAuto()] | |||
|
|||
|
|||
def is_auto(type_: Union[StrawberryAnnotation, StrawberryType, type]): |
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.
Can is_auto
be a classmethod
(or staticmethod
) on StrawberryAuto
instead of an unbound function?
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.
In fact, could we just implement StrawberryAuto.__instancecheck__
?
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.
Awesome idea! I went the same road for UNSET
/is_unset
here, but maybe we should change it too in the future?
Btw, its done!
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.
Yep definitely think we should do that in the future 👍. Personally, I don't think unbound functions are good practice in Python in anything other than simple scripts.
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.
Minor requests; otherwise lgtm.
Will approve now so that either you or Patrick can merge
Add `is_auto` utility for checking if a type is `strawberry.auto`, considering the possibility of it being a `StrawberryAnnotation` or even being used inside `Annotated`.
Hey @BryceBeagle and @patrick91 , sorry for the delay here... I have not been able to properly focus on some contributions lately. Just fixed the suggestions made by @BryceBeagle . This PR is already approved, but do you want to take another look at it? |
* Add is_auto utility Add `is_auto` utility for checking if a type is `strawberry.auto`, considering the possibility of it being a `StrawberryAnnotation` or even being used inside `Annotated`.
Add
is_auto
utility for checking if a type isstrawberry.auto
,considering the possibility of it being a
StrawberryAnnotation
oreven being used inside
Annotated
.Description
Types of Changes
Issues Fixed or Closed by This PR
Checklist