Closed choonyme closed 8 months ago
pls try pydantic 2.0.2
pls try pydantic 2.0.2
Of course it's also broken with 2.0.2 - or anything >1.x - as is_complex
has been removed.
I think for now unfortunately the only way around this is to pin against pydantic==1.*
until flask-pydantic is updated to support pydantic 2.0.
I have a possible solution in #75 that works on at least some examples. To try it out, use flask-pydantic @ git+https://github.com/jkseppan/flask-pydantic@pydantic-v2
as the requirement spec.
Thanks for this PR. I was just working on validating class-based views using Flask and notice the validate() fx was giving me that is_complex issue. Will pull, test it out in my case and see if there's anything I can contribute.
def convert_query_params(
query_params: ImmutableMultiDict, model: Type[BaseModel]
) -> dict:
def convert_query_params(
**{
key: value
for key, value in query_params.to_dict(flat=False).items()
if key in model.model_fields
and field_is_complex(model.model_fields[key])
},
}
Thanks for this PR @jkseppan
Any reason you didnt use the pydantic function is_field_complex
?
https://docs.pydantic.dev/latest/api/pydantic_settings/#pydantic_settings.sources.PydanticBaseSettingsSource.field_is_complex
Any reason you didnt use the pydantic function is_field_complex ?
That's in pydantic_settings
, which would be an extra dependency - my PR adds a conditional dependency on typing_extensions
, but that is required by Pydantic 2 in any case.
Can please someone explain why it takes so long for the pullrequest with fix to be merged and be included in the next version of package? https://github.com/bauerji/flask-pydantic/pull/75 It has been like a month or so
Possible reasons might be that the PR needs more extensive testing, or that it doesn't follow the project's coding style, or anything really. It seems to me that flask-pydantic is maintained by just one person, probably in their free time, so I don't think it is fair to demand or expect any kind of definite timeline.
I imagine that it could help if people reported whether the PR works for their projects. You can check that by using a version specifier like flask-pydantic @ git+https://github.com/jkseppan/flask-pydantic@pydantic-v2
. But of course I can't speak for the project maintainer.
@jkseppan well i dont demand just ask. Your solution fixed the issue for me, but i cant include it in any production environment for sure as it isnt the official version of package. I check during last 2-3 weeks and it seems that verification of PR is stopped, so i would like to know why and how this can be resolved. Maybe we need to tag the lib creator or it is too much?
Its state for the last 2 weeks at least:
HI having the same issue. Any updates ?
Validating against this model produces the following error:
AttributeError: 'FieldInfo' object has no attribute 'is_complex'
I'm using pydantic 2.0.1 with Flask-Pydantic 0.11.0
After a bit checking, I've found that downgrading pydantic to version 1 works. So I think you need to update your support for pydantic version 2.