[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2021-04-21 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset b0544ba77cf86074fb1adde00558c67ca75eeea1 by Pablo Galindo in 
branch 'master':
bpo-38605: Revert making 'from __future__ import annotations' the default 
(GH-25490)
https://github.com/python/cpython/commit/b0544ba77cf86074fb1adde00558c67ca75eeea1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2021-04-20 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution: fixed -> postponed
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2021-04-20 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +pablogsal
nosy_count: 13.0 -> 14.0
pull_requests: +24214
pull_request: https://github.com/python/cpython/pull/25490

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2021-04-06 Thread miss-islington


miss-islington  added the comment:


New changeset 1be456ae9d53bb1cba2b24fc86175c282d1c2169 by Saiyang Gou in branch 
'master':
bpo-38605: Update "Future statements" docs since PEP 563 is always enabled 
(GH-25236)
https://github.com/python/cpython/commit/1be456ae9d53bb1cba2b24fc86175c282d1c2169


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2021-04-06 Thread Saiyang Gou


Change by Saiyang Gou :


--
nosy: +gousaiyang
nosy_count: 11.0 -> 12.0
pull_requests: +23974
pull_request: https://github.com/python/cpython/pull/25236

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 0ae216b11644b23511c6287a52e7d28aeb9f by Batuhan Taskaya in 
branch 'master':
bpo-38605: bump the magic number for 'annotations' future (#22630)
https://github.com/python/cpython/commit/0ae216b11644b23511c6287a52e7d28aeb9f


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +21607
pull_request: https://github.com/python/cpython/pull/22630

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

test_grammar and test_pydoc became failed on my machine until I removed all 
.pyc files. We need to bump the magic number for .pyc files.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-06 Thread STINNER Victor


STINNER Victor  added the comment:

Good! I'm happy to see yet another "Python 4.0 change" going away :-) Let's 
make "Python 4.0" as compatible as possible ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

I'm marking this fixed, but there are some subtle edge cases. That's what alpha 
releases are for.

@BTaskaya, adding those arguments to various inspect functions sounds like a 
nice thing to do. You could either open a new issue or just reference this 
(closed) issue in your PR -- up to you.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-06 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 044a1048ca93d466965afc027b91a5a9eb9ce23c by Batuhan Taskaya in 
branch 'master':
bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)
https://github.com/python/cpython/commit/044a1048ca93d466965afc027b91a5a9eb9ce23c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-06 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

@gvanrossum should I draft a patch to convert this
inspect.signature(callable, *, follow_wrapped=True) (and also things like 
inspect.Signature.from_callable) into inspect.signature(callable, *, 
follow_wrapped=True, globalns=None, localns=None) in order to pass them to 
get_type_hints (for resolving in different namespaces)?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-10-01 Thread STINNER Victor


STINNER Victor  added the comment:

> Issue 41314 changed the __future__ annotations default version to 3.10.  
> 3.10.0a1 is scheduled for next Oct 5, less than 2 months from now.  It would 
> be good if PR 20434 were merged before that.

Python 3.9.0 final is also around the corner. Any update on this issue?

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-08-11 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Issue 41314 changed the __future__ annotations default version to 3.10.  
3.10.0a1 is scheduled for next Oct 5, less than 2 months from now.  It would be 
good if PR 20434 were merged before that.

--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-08-01 Thread Inada Naoki


Change by Inada Naoki :


--
nosy: +inada.naoki

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

There will still be a lot of code written that way, because people need 
compatibility with earlier versions of Python. So I think it should be fixed in 
get_type_hints().

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-28 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-28 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

An example would be this 
https://github.com/python/cpython/blob/24bddc1b3b58f6899b2d412e51b37f68536e4fe2/Lib/test/test_typing.py#L2744-L2745.
 Either I can change tests in order to reflect now everything is a forward ref 
by default
class Loop:
attr: Final['Loop']
to
class Loop:
attr: Final[Loop]
or resolve everything on get_type_hints.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

I think in general it is more insightful to discuss the behavior of 
get_type_hints() given specific things in annotations.

We generally don't write forward refs inside forward refs, like 
"SomeClass['int']". So maybe that code was wrong? Where did you find it?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-28 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

>From now on, should typing.get_type_hints automatically resolve arguments too? 
>An example would be this;

import typing
T = typing.TypeVar("T")
class Loop(typing.Generic[T]):
subloop: typing.Final["Loop[int]"]
print(typing.get_type_hints(Loop))
>>> {'subloop': typing.Final[__main__.Loop[int]]}
If we run the same code under future annotations
>>> {'subloop': typing.Final[ForwardRef('Loop[int]')]}

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

To my knowledge, dataclasses works with `from __future__ import annotations`. 
If there are specific examples of problems, I'd like to hear about it: please 
open a separate issue.

There is a hack (discussed at PyCon 2018 with all of the relevant players) 
where it avoids importing typing to look at typing.ClassVar, but I think that 
code is all correct. Maybe I should just bite the bullet and import typing, 
since I believe importing it is faster than it used to be.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread Guido van Rossum

Guido van Rossum  added the comment:

- Double forward ref: IMO this can be resolved in the get_type_hints() 
functions. (Łukasz do you agree?)

- inspect.signature(): Maybe this could switch to using 
typing.get_type_hints()? Then again if performance is important here maybe we 
cannot change anything.

- dataclasses hacks: these should just be resolved.

Another thought: maybe some of these issues can be considered bugs in 3.9 as 
well, and we should fix them there too? That might help us decide the right 
path forward. After all we should really encourage people to start using `from 
__future__ import annotations` in their code, to help them get ready for these 
issues in 3.10.

Final thought: I know at least the Dropbox client team, and possibly also 
Instagram, has already turned on `from __future__ import annotations` by 
default in their local fork of Python. Maybe we can ask them if they ever felt 
the need to change inspect.signature or typing.get_type_hints.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread STINNER Victor


STINNER Victor  added the comment:

> The second problem is `inspect.signature`. If we don't resolve annotations 
> there and continue it is definitely going to break some code.

Would you mind to elaborate why would it break some code? Consumers of 
annotations should already be prepared to get directly types or strings, no?

> 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)

I expect that resolving has an impact on performance, whereas the caller may 
not use annotations at all but only cares of the number of parameters or their 
name.

It would be resonable to not resolve annotations in signature() by default. If 
someone cares, maybe a new parameter can be added to resolve annotations?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

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;
Py_INCREF(text);
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_{field.name}` etc. 
annotations and how ClassVar/InitVar parsed.

There are also some little parts that need to change. 

Any thoughts on these issues?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

I opened the PR 20434 as draft, but from what I understand, there is going to 
be some breakage (on our test suite). I'll try to narrow it down (currently ~4 
tests instead of ~20) but I dont want to prevent anyone else from working on 
this, so feel free to ignore my PR if you have a working test suite with a low 
breakage level.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
Removed message: https://bugs.python.org/msg370003

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +19691
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/20434

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

I'm starting it if anyone else already prepared a patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread STINNER Victor


Change by STINNER Victor :


--
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-26 Thread STINNER Victor


STINNER Victor  added the comment:

Is there anyone interested to implement this change in Python 3.10?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-18 Thread Łukasz Langa

Łukasz Langa  added the comment:

We'll make this an announced 3.10 feature early on. The discussion at the 
Summit wasn't as clear cut to me: 35% of participants would rather see this 
default later than 3.9.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-18 Thread STINNER Victor


STINNER Victor  added the comment:

> Too bad nobody took any action here after the positive outcome of the 
> discussion at the summit.

I didn't understand it this way. I understood that some people were not 100% 
comfortable to target 3.9. The question was 3.9 or 3.10. Since the release 
cycle is now shorter (1 years), only targeting 3.10 is not a big deal ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-18 Thread Guido van Rossum


Guido van Rossum  added the comment:

Too bad nobody took any action here after the positive outcome of the 
discussion at the summit.

--
components: +Interpreter Core -Library (Lib)
stage:  -> needs patch
type:  -> behavior
versions:  -Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10

2020-05-18 Thread STINNER Victor


Change by STINNER Victor :


--
title: [typing] PEP 563: Postponed evaluation of annotations: enable it by 
default before Python 4.0 -> [typing] PEP 563: Postponed evaluation of 
annotations: enable it by default in Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com