-
-
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: Fix an issue preventing typing root
with strawberry.Parent
#3529
Conversation
for more information, see https://pre-commit.ci
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 @bellini666 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
) and len(conflicting_arguments) > 1: | ||
root_parameter is not None | ||
and parent_parameter is not None | ||
and root_parameter.name != parent_parameter.name |
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.
suggestion: Clarify the logic for checking parameter names.
The condition root_parameter.name != parent_parameter.name
might benefit from a comment explaining why the names should not match. This will help future maintainers understand the rationale behind this check.
and root_parameter.name != parent_parameter.name | |
# Ensure the root and parent parameters do not refer to the same argument | |
and root_parameter.name != parent_parameter.name |
tests/fields/test_resolvers.py
Outdated
@@ -453,3 +454,83 @@ def bar(x: str = "bar"): | |||
|
|||
assert len(parameters_map) == 2 | |||
assert len(parameters_set) == 2 | |||
|
|||
|
|||
def test_annotation_using_parent_annotation(): |
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.
suggestion (testing): Consider adding a test for edge cases with null or invalid parent values.
To ensure robustness, it would be beneficial to add tests that handle cases where the parent
parameter is None
or an invalid type. This will help verify that the function behaves correctly under these conditions.
Thanks for adding the Here's a preview of the changelog: This release fixes a typing issue where trying to type a import strawberry
@strawberry.type
class SomeType:
@strawberry.field
def hello(self, root: strawberry.Parent[str]) -> str:
return "world" This should now work as intended. Here's the tweet text:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3529 +/- ##
=======================================
Coverage 96.55% 96.56%
=======================================
Files 523 523
Lines 33364 33404 +40
Branches 5522 5536 +14
=======================================
+ Hits 32215 32255 +40
Misses 914 914
Partials 235 235 |
CodSpeed Performance ReportMerging #3529 will not alter performanceComparing Summary
|
Fixes strawberry-graphql/strawberry-django#538