Type annotations can be Strings and with Python 4.0 will always be handled as such (PEP 484).
As of Python 3.7 you can from __future__ import annotations to replicated Py4.0 behavior.
This package does not work with strings as annotation.
I already stumbled on this.
Referencing to parent or child objects of the same class is rather common (I believe)
from typing import Optional
class Foo:
bar: int # works fine
baz: "str" # does not work, but you could simply remove quotation marks for now
child: "Optional[MyClass]" # does not work
parent: "Optional[MyClass]"
The only solution I see right now is to use eval on the annotations. Please prove me wrong.
Type annotations can be Strings and with Python 4.0 will always be handled as such (PEP 484).
As of Python 3.7 you can
from __future__ import annotationsto replicated Py4.0 behavior.This package does not work with strings as annotation.
I already stumbled on this.
Referencing to parent or child objects of the same class is rather common (I believe)
The only solution I see right now is to use
evalon the annotations. Please prove me wrong.