Open huonw opened 2 years ago
The same issue affects @strawberry.mutation
@patrick91 Should this line return a StrawberryField
instead of Any
?
@patrick91 Should this line return a
StrawberryField
instead ofAny
?
I think any makes it work with the dataclass transform decorator, but maybe that was only true when we used our own implementation of it 🤔
Hmm. I'm new here so I know almost nothing. :)
field()
returns a StrawberryField
if a resolver
isn't provided so it seems like using StrawberryField
as a return type is more correct than Any
. I'm not sure what downstream effects that would have, but what do you think of making the type hint more accurate here and making adjustments elsewhere (maybe by casting to Any
) if needed?
field()
returns aStrawberryField
if aresolver
isn't provided
Oh, actually it returns a StrawberryField
no matter what, right?
I've just hit the same issue with strawberry_django.input_mutation
it's fine when there are no args, but as soon as I add a description
I see the mypy error error: Untyped decorator makes function "foo" untyped [misc]
I'm observing this issue as well
Describe the Bug
Using
@strawberry.field
as a decorator is nifty, but it seems like its type annotations only work great if it's called without arguments. If it's called like@strawberry.field(name="whatever")
, mypy considers the decorator untyped and thus gives 'untyped decorator makes function .. untyped' errors in strict mode.For instance, adjust
test_all_field_usage
intest_fields.yml
to use strict mode:There's a whole much of output, but the key lines are towards the end (just before the real
Revealed type
output):This is easily squashed by
# type: ignore[misc]
annotations, but it'd be neat if we could avoid them 😄If the test is additionally edited to remove the arguments to
field
, there's no complains about untyped decorators:System Information
Additional Context
As always, thanks for strawberry! 🍓
Upvote & Fund