flask-pydantic icon indicating copy to clipboard operation
flask-pydantic copied to clipboard

annotations bug

Open GrafLearnt opened this issue 2 years ago • 5 comments

When from __future__ import annotations is imported got following error:

        **{
            key: value
            for key, value in query_params.to_dict(flat=False).items()
>           if key in model.__fields__ and model.__fields__[key].is_complex()
        },
    }
E   AttributeError: 'str' object has no attribute '__fields__'

local model variable became str instead of pydantic class

Virtualenv Python: 3.11.7 Implementation: CPython

System Platform: darwin OS: posix Python: 3.11.7

GrafLearnt avatar Feb 22 '24 10:02 GrafLearnt

@GrafLearnt Hi there, thank you for your bug report. Can you please include some more details? Like the model you are trying to verify against? it be nice if you could include a minimal example for us to look into!

yctomwang avatar Feb 23 '24 02:02 yctomwang

This is my understanding of the problem, is that if you have from future import annotations anywhere in the code, the package will have problem like image

yctomwang avatar Feb 23 '24 02:02 yctomwang