strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
3.98k stars 531 forks source link

DeprecationWarning: Argument name-based matching of 'info' is deprecated and will be removed in v1.0. #2851

Open shahar-medigate opened 1 year ago

shahar-medigate commented 1 year ago

When importing strawberry with all waring enabled (-Wall) you get

.../site-packages/strawberry/types/fields/resolver.py:199: DeprecationWarning: Argument name-based matching of 'info' is deprecated and will be removed in v1.0. Ensure that reserved arguments are annotated their respective types (i.e. use value: 'DirectiveValue[str]' instead of 'value: str' and 'info: Info' instead of a plain 'info').
  return {spec: spec.find(parameters, self) for spec in self.RESERVED_PARAMSPEC}

Describe the Bug

While all warnings are enabled and importing strawberry a warning is raised

python -Wall -c 'import strawberry'

System Information

Upvote & Fund

Fund with Polar

lukaspiatkowski commented 8 months ago

It would be nice if you ensure that using subclasses of Info is supported. Our use case is having our own custom class to have better types on the context by default:

class MyInfo(Info[MyCtx[TDetails], Any], Generic[TDetails]):
    ...

And then we use info: MyInfo[SomeDetails]. (Would be nice to be able to use an alias here instead of inheriting as we don't really have instances of MyInfo, but AFAIK it is not supported by python typecheckers.)