-
-
Notifications
You must be signed in to change notification settings - Fork 531
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 custom dataclass init function #1187
Conversation
Thanks for adding the Here's a preview of the changelog: This release changes how dataclasses are created to make use of the new More info: https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass For example: # This no longer raises a TypeError
@strawberry.type
class MyType:
a: str = "Hi"
b: int
# Before:
MyType("foo", 3)
# After:
MyType(a="foo", b=3) Here's the preview release card for twitter: Here's the tweet text:
|
Codecov Report
@@ Coverage Diff @@
## main #1187 +/- ##
=======================================
Coverage 98.19% 98.20%
=======================================
Files 160 162 +2
Lines 6388 6422 +34
Branches 1205 1216 +11
=======================================
+ Hits 6273 6307 +34
Misses 58 58
Partials 57 57 |
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.
This might be good for now, I wan't to see what @BryceBeagle thinks before merging though 😊
I think we should still vendorize in future :)
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 this is a pretty good solution for now, just a few minor changes I see here
0be0bbf
to
d72d1bd
Compare
@patrick91 @BryceBeagle this is ready for a review again. Sorry for the delay! |
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, I think we need to make this release more visible somehow, to make sure the breaking change is seen by everyone 😊
This release changes how dataclasses are created to make use of the new | ||
`kw_only` argument in Python 3.10 so that fields without a default value can now | ||
follow a field with a default value. This feature is also backported to all other | ||
supported Python versions. |
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.
💯
@patrick91 yep I agree. Any suggestions on how to do that? |
Maybe we can send a newsletter for the end of the year and include it there! I can write something in the next few days |
/pre-release |
Pre-release👋 Releasing commit [50d7463] to PyPi as pre-release! 📦 |
Pre-release👋 Pre-release 0.94.0-dev.1642180413 [50d7463] has been released on PyPi! 🚀 poetry add strawberry-graphql==0.94.0-dev.1642180413 |
@patrick91 is this still relevant? |
yes, I need to merge it! sorry about that, will rebase it tonight and see what we need to do before merging it :) |
1d00daf
to
8370a2a
Compare
8370a2a
to
bbc9ebe
Compare
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.
Hey, so sorry it took me so long to merge this! Thanks for the nudge and all the work @jkimbo 😊
…e behaviour introduced in strawberry-graphql#1187 - Set `kw_only=True` in DataclassAttribute object - Remove code to check that `Attributes without a default cannot follow attributes with one`
* Update Mypy plugin to treat strawberry fields as kw_only, matching the behaviour introduced in #1187 - Set `kw_only=True` in DataclassAttribute object - Remove code to check that `Attributes without a default cannot follow attributes with one` * Fix type issue * Update types * Fix types * Update pyright support Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com>
This introduced a breaking change for us when upgrading from 0.119.1 to 0.131.1. We're using federation, and defined a type that is handled by another subgraph:
After an update we started seeing this error in our logs
It was a simple fix (passing the id as a kwarg) but tracking it down was a bit frustrating, and unexpected for a minor release. Sharing this in case others run into similar issues. |
I tracked down this PR while addressing the issue in our code, and commented without reading the above. The PR clearly explains that its a breaking change. 🤦♂️ I'll pay more attention to release notes when approving changes that bump the strawberry version. |
@jceresini apologies for the inconvenience. We try hard to not make breaking changes but sometimes it's unavoidable. I think this is also an artifact of the quick release cycle that Strawberry has which often results in people upgrading between quite large version ranges and so it's hard to identify all the potential breaking changes. We might benefit from something on the website that allows you show the difference between versions and view all the changes at once. What do you think @patrick91 ? |
yes, I'd love to have something like that! were you thinking of a page with a list of breaking changes and pending deprecations? or something else entirely? @jceresini sorry about this! Ideally we should have done this in a major release, but unfortunately we haven't made the jump to v1 just yet |
Highlighting breaking changes would be ideal but I'm not sure how we would extract that. As a first step it would be great to just list all the titles of the changes and you can open each one to find out more. More like traditional release notes. I'm imagining something like this: https://react-native-community.github.io/upgrade-helper/ |
Description
This PR adds a custom dataclass init function that enforces that all args get passed as keyword arguments. This allows us to avoid the problem where a type cannot define a field with a default value before a field that doesn't have a default value.
Types of Changes
Issues Fixed or Closed by This PR
Checklist