El sáb, 27 mar 2021 a las 15:37, Guido van Rossum (<guido@python.org>) escribió:
Since my last post on the subject I have pretty much given up on PEP 649 in favor of what we have in 3.10alpha6 -- annotations are always stringified. The two problems brought up by Joseph Perez in particular seem too thorny to try and devise a solution for.

Jelle, could you explain why for your use cases PEP 649 is preferred over PEP 563?

The static(ish) type checker we use internally, https://github.com/quora/pyanalyze, relies on the runtime `__annotations__` object to get types. I also support getting types out of string annotations, but it would make my life simpler if `__annotations__` worked like in PEP 649 so I wouldn't have to worry about scoping.

Consider code like this:

def make_function(return_type):
    def f() -> return_type:
    return f

int_func = make_function(int)

Currently, I can look at int_func.__annotations__ and see that the return type is int, but with stringified annotations it's just "return_type" and I have no way to get int out.

Now, PEP 649 doesn't actually fix this at the moment, since it still resolves all annotations in the global scope, but that's easily fixed by removing the special case in https://github.com/larryhastings/co_annotations/blob/co_annotations/Python/compile.c#L3815.
On Sat, Mar 27, 2021 at 7:35 AM Jelle Zijlstra <jelle.zijlstra@gmail.com> wrote:
Hi Larry, I have the same question as Guido last month. I'd really like to see some version of PEP 649 go into 3.10; is there anything I can do to help? I opened https://github.com/larryhastings/co_annotations/issues/1 to discuss what seems to be the main problem identified in the previous discussion.

El jue, 4 feb 2021 a las 10:59, Guido van Rossum (<guido@python.org>) escribió:
Breaks are good. Looking forward to the next prototype!

On Thu, Feb 4, 2021 at 10:45 AM Larry Hastings <larry@hastings.org> wrote:

After working on it and stressing out about it for some months, I decided to take a break and scratch some other itches.  I'll return to PEP 649 soon, and I have every intention of having the PEP done and the prototype done well in advance of 3.10b1--worry not.

Thanks for checking in,


On 2/4/21 9:17 AM, Guido van Rossum wrote:
Hi Larry,

Can you give us a status update for your PEP 649? I don't recall reading anything about it in the past few weeks. I am super excited about this solution to the problem (even if there are a few issues to work through) and I think it will provide better backwards compatibility than the current plan for Python 3.10 (PEP 563, from __future__ import annotations, causing all annotations to be stringified).

If we don't get this into 3.10, we'd have a much more complicated transition. There are only two more alphas before 3.10b1 gets released! And we'd have to get this approved by the Steering Council, which can take a few weeks (cut them some slack, they have a big backlog). Fortunately you already have an implementation that can be landed quickly once the PEP is accepted.

--Guido van Rossum (python.org/~guido)

--Guido van Rossum (python.org/~guido)
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/IXIAUVSP62HMLCYY6RMALSETIU2UPIAQ/
Code of Conduct: http://python.org/psf/codeofconduct/

--Guido van Rossum (python.org/~guido)