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
Support ForwardRef in Python 3.6 #463
Comments
Humm, I'm not completely opposed to it, but why not just upgrade to 3.7? 3.7 has been released and stable for some time now, the chance of a bugs from upgrading is tiny, the only reason I can imagine is that you can't upgrade, eg. your tied to an OS with 3.6. |
Unfortunately we are not able to upgrade to 3.7 due to some of our dependencies (i.e. tensorflow and some projects that used the name |
humm, shame. Ok, PR welcome to all |
Thanks. I'll prepare a PR once #464 lands. |
@mooncake4132 Do you have a PR for this in the works? I'm in a place where we want to support both py36 and py37 using ForwardRef. |
@gangefors I'm currently in a situation where I don't easily have internet connection everyday. Feel free to grab it if you need it now. |
I also would love this feature. Even though the technical problems to upgrade to 3.7 may be few, there's plenty of corporate reasons why you wouldn't be able to do so. |
PR welcome. |
Done. |
Currently pydantic only supports
ForwardRef
in Python 3.7. It will be great if it can also be supported in Python 3.6. Although aForwardRef
can't be explicitly created in Python 3.6, it can be implicitly created:If you take a look at the
ForwardRef
class in Python 3.6 and Python 3.7, they share a very similar interface. The only major difference I spotted is that in python 3.6,ForwardRef
is named as_ForwardRef
and the method_evaluate
in python 3.7 is named as_eval_type
in python 3.6.Quickly looking through the code I believe we can change https://github.com/samuelcolvin/pydantic/blob/a704662ae4cde638c0e1b68126a2f89828787641/pydantic/utils.py#L24-L28
to
and
https://github.com/samuelcolvin/pydantic/blob/a704662ae4cde638c0e1b68126a2f89828787641/pydantic/main.py#L456-L459
to
The text was updated successfully, but these errors were encountered: