This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author BTaskaya
Recipients BTaskaya, barry, brett.cannon, eric.smith, gvanrossum, levkivskyi, lukasz.langa, vstinner
Date 2020-05-26.20:27:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
After trying to complete a patch, there are a few issues that immediately showed itself (and this might lead to not to do this in 3.10, I dont know);

First one is double-forward-ref, which is usage of string-annotations when there is postponed evaluatation of annotations:
>>> import typing
>>> from __future__ import annotations
>>> def x(a: 'int'): pass
>>> typing.get_type_hints(x)
{'a': ForwardRef('int')}

If we make annoatations feature default, this would be default behavior. The solution would be a workaround to the compiler;
static int
compiler_visit_annexpr(struct compiler *c, expr_ty annotation)
    if (annotation->kind == Constant_kind && PyUnicode_CheckExact(annotation->v.Constant.value)) {
        PyObject *text = annotation->v.Constant.value;
        ADDOP_LOAD_CONST_NEW(c, text);
    } else {
        ADDOP_LOAD_CONST_NEW(c, _PyAST_ExprAsUnicode(annotation));
    return 1;
But I am not sure if this is too silly or not. 

The second problem is `inspect.signature`. If we don't resolve annotations there and continue it is definitely going to break some code. If we resolve, that would mean that annotations must able to point something real (and this might not be the real case if the user uses a string annotation etc.) and will break code. (both tried and both breaks different modules on the stdlib tests)

The third problem is various dataclass hacks. Like `_type_{}` etc. annotations and how ClassVar/InitVar parsed.

There are also some little parts that need to change. 

Any thoughts on these issues?
Date User Action Args
2020-05-26 20:27:06BTaskayasetrecipients: + BTaskaya, gvanrossum, barry, brett.cannon, vstinner, eric.smith, lukasz.langa, levkivskyi
2020-05-26 20:27:06BTaskayasetmessageid: <>
2020-05-26 20:27:06BTaskayalinkissue38605 messages
2020-05-26 20:27:05BTaskayacreate