-
-
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
fix(mypy): Fix issue with input and interface pydantic decorators #1832
fix(mypy): Fix issue with input and interface pydantic decorators #1832
Conversation
@@ -922,6 +922,7 @@ def _is_strawberry_pydantic_decorator(self, fullname: str) -> bool: | |||
for strawberry_decorator in { | |||
"strawberry.experimental.pydantic.object_type.type", | |||
"strawberry.experimental.pydantic.object_type.input", | |||
"strawberry.experimental.pydantic.object_type.interface", |
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 think we forgot to support the interface decorator, so i just added it
Codecov Report
@@ Coverage Diff @@
## main #1832 +/- ##
=======================================
Coverage 98.15% 98.15%
=======================================
Files 143 143
Lines 5466 5467 +1
Branches 1001 1001
=======================================
+ Hits 5365 5366 +1
Misses 50 50
Partials 51 51 |
Thanks for adding the Here's a preview of the changelog: Fixes mypy type inference when using @strawberry.experimental.pydantic.input Here's the preview release card for twitter: Here's the tweet text:
|
directives=directives, | ||
all_fields=all_fields, | ||
use_pydantic_alias=use_pydantic_alias, | ||
) |
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.
technically you could just leave in partial(type, is_input=True)
and put this in the IF TYPE_CHECKING block. Anyways i made it like this so that its less confusing when users introspect. they may not be familar to what IF TYPE_CHECKING
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.
Makes sense, do you think we can also add this? https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/object_type.py#L152-L153
this should make it work slightly better with pyright
does that work out of the box for the pydantic conversion? not familar with how that works but i think the init for the dataclass wouldn't work well because not all the fields are in the class getting decorated. e.g.
if it doesn't and gives false positives i'll settle it in another issue |
it only works with fields that are defined, so yeah, let's do it in another issue :) |
Resolves #1830
Description
Types of Changes
Issues Fixed or Closed by This PR
Checklist