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

strawberry.ext.mypy_plugin PydanticModelField.to_argument error #3436

Closed
chrisemke opened this issue Apr 3, 2024 · 2 comments
Closed

strawberry.ext.mypy_plugin PydanticModelField.to_argument error #3436

chrisemke opened this issue Apr 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@chrisemke
Copy link
Contributor

chrisemke commented Apr 3, 2024

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

  • Operating system: Linux
    Using version ^0.224.1 for strawberry-graphql
    Using version ^2.6.4 for pydantic
    Using version ^0.0.16 for sqlmodel
    Using version ^1.9.0 for mypy

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

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@chrisemke chrisemke added the bug Something isn't working label Apr 3, 2024
@atatsu
Copy link
Member

atatsu commented Apr 22, 2024

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants