strawberry-graphql / strawberry

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

strawberry.ext.mypy_plugin PydanticModelField.to_argument error #3436

Closed chrisemke closed 7 months ago

chrisemke commented 7 months ago

I think I'm having some issues with strawberry.ext.mypy_plugin when using a pydantic model to make my types When I enable I get this error (image). If I disable it runs.

Describe the Bug

When I enable I get this error. If I disable it runs. image

System Information

Additional Context

this is the file showed in error:

from strawberry import auto, type
from strawberry.experimental.pydantic import type as pydantic_type

from database.models.brazil import Address, City, State

@pydantic_type(name='State', model=State)
class StateType:
    name: auto
    acronym: auto

@pydantic_type(name='City', model=City)
class CityType:
    ibge: auto
    name: auto
    ddd: auto

@type(name='Coordinates')
class CoordinatesType:
    latitude: float
    longitude: float
    altitude: float

@pydantic_type(name='Address', model=Address)
class AddressType:
    zipcode: auto
    city: CityType
    state: StateType
    neighborhood: auto
    complement: auto
    coordinates: CoordinatesType | None = None

Upvote & Fund

Fund with Polar

atatsu commented 7 months ago

I was experiencing this issue as well, however, since updating to strawberry 0.227.2 it appears to be resolved. Gave it a try after seeing the 0.226.2 release mention an update for the plugin to support pydantic >= 2.7.

patrick91 commented 7 months ago

@atatsu thanks! yes, this should be fixed now 😊