<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 11, 2017 at 1:21 PM, Yury Selivanov <span dir="ltr"><<a href="mailto:yselivanov.ml@gmail.com" target="_blank">yselivanov.ml@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Sep 11, 2017 at 3:25 PM, Lukasz Langa <<a href="mailto:lukasz@langa.pl">lukasz@langa.pl</a>> wrote:<br>
[..]<br>
<span class="">> This PEP is proposing delaying evaluation until annotations are accessed but<br>
> gives user code the power to decide whether the string form is enough, or<br>
> maybe an AST would be enough, or actual evaluation with get_type_hints() or<br>
> eval() is necessary.<br>
<br>
</span>I'm one of those who used annotations for other purposes than type<br>
hints. And even if annotations became strings in Python 3.7 *without<br>
future import*, fixing my libraries would be easy -- just add an<br>
eval().<br>
<br>
That said, the PEP doesn't cover an alternative solution:<br>
<br>
1. Add another special attribute to functions: __annotations_text__.<br>
<br>
2. __annotations__ becomes a dynamic Mapping, which evaluates stuff<br>
from __annotations_text__ *lazily*.<br>
<br>
3. Recommend linters and IDEs to support "# pragma: annotations", as a<br>
way to say that the Python files follows the new Python 3.7<br>
annotations semantics.<br>
<br></blockquote><div><br></div><div>I really like this proposal! I agree the linters should understand the semantics of if TYPE_CHECKING, Python 2.7-3.6 will continue to need it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That would maintain full backwards compatibility with all existing<br>
Python libraries and would not require a future import.<br>
<span class="HOEnZb"><font color="#888888"><br>
Yury<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</div></div></blockquote></div><br></div></div>