support postponed annotations and ForwardRef in python 3.7 #348
support postponed annotations in python 3.7
Related issue number
Also note that the Model will need to be defined in the root of the module so it's included in globals, this is a limitation of
The text was updated successfully, but these errors were encountered:
@@ Coverage Diff @@ ## master #348 +/- ## ===================================== Coverage 100% 100% ===================================== Files 14 14 Lines 1824 1857 +33 Branches 356 364 +8 ===================================== + Hits 1824 1857 +33
Just ran into this issue, and found it works for me!
from __future__ import annotations from pydantic import BaseModel class CalendarRule(BaseModel): id: int calendar: int children: t.List[CalendarRule]
the above no longer crashes when I import
Thanks for your work on this!
Works for me as well, although with a slight catch compared to @StephenBrown2
(Python 3.7.3rc1, Pydantic 0.23)
I have this model :
If I only add
Obviously adding that piece of code just works
I've had some little issues with the documentation regarding this feature though, for which I'm making an issue and a PR.