Skip to content
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

Type checking support for PyRight #1135

Closed
rmzr7 opened this issue Aug 9, 2021 · 2 comments
Closed

Type checking support for PyRight #1135

rmzr7 opened this issue Aug 9, 2021 · 2 comments

Comments

@rmzr7
Copy link

rmzr7 commented Aug 9, 2021

Hi,

Given the following type

@strawberry.type
class Person():
   id: int
   name: str

PyRight throws an error on Person(3, "Rob"): Expected no arguments to Person Constructor. The way to get around this is to create an __init__ function. However, when classes are decorated with @strawberry.type the fields within the Strawberry type cannot be selected. If an __init__ is provided, the following gql requests will fail

person {
   id
   name
}

With AttributeError: 'Person' object has no attribute 'id'. What is the preferred way to create initializers for Strawberry Types?

@patrick91 patrick91 changed the title @strawberry.type constructor type error Type checking support for PyRight Aug 9, 2021
@patrick91
Copy link
Member

I want to add support for PyRight here: #922

but I wanted to get in touch with PyRight's maintainer to get some feedback first

Anyway, the error from PyRight is a false positive. You should be able to use the constructor provided by default by Strawberry :)

@DoctorJohn
Copy link
Member

PyRight support has been added in #922 🎉, I'll close this issue for now. Feel free to reopen if needed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants