strawberry icon indicating copy to clipboard operation
strawberry copied to clipboard

Generic parameter in the `strawberry.field` method is over-constrained

Open zwade opened this issue 2 years ago • 2 comments

Describe the Bug

The strawberry.field method conveniently has a generic overload such that the return type of the field method is the return type of the passed function.

However, that overload types the passed function as Callable[[], T], meaning that (in pyright at least) the overload will only take effect when used with a 0-argument thunk causing the return type to be StrawberryField. Instead, if Callable[..., T] were used, then the overload would take effect for any function, properly typing the result.

System Information

  • Strawberry version: 0.114.0
  • Pyright version: 1.1.252

Additional Information

I'm happy to submit a PR for this (especially given the limited change required)

zwade avatar Jun 06 '22 17:06 zwade

+1 for visibility

floydding avatar Jun 09 '22 14:06 floydding

Hi @zwade! thanks for the issue report, a PR would be amazing to have!

patrick91 avatar Jun 23 '22 23:06 patrick91

This should have been fixed in #2172

@zwade let me know if that's not the case 😊

patrick91 avatar Sep 15 '22 11:09 patrick91

Thanks!

zwade avatar Sep 15 '22 22:09 zwade