bauerji / flask-pydantic

flask extension for integration with the awesome pydantic package
MIT License
368 stars 58 forks source link

annotations bug #89

Open GrafLearnt opened 9 months ago

GrafLearnt commented 9 months ago

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

yctomwang commented 9 months ago

@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 commented 9 months ago

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